Android Open Source - zomblind Jugador






From Project

Back to project page zomblind.

License

The source code is released under:

Apache License

If you think the Android project zomblind listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*******************************************************************************
 * Copyright 2013 Antonio Fern?ndez Ares (antares.es@gmail.com)
 * /*  w  w w  .ja  v a  2 s. c om*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package antares.zomblind.core;

import android.content.Context;
import antares.zomblind.ZomblindActivity;
import antares.zomblind.core.objetos.ArmaLista;


/**
 * @author antares
 * 
 */
public class Jugador {
  
  public class infeccion{
    public int _max = 100;
    public int _actual = 0;
    
    @Override
    public String toString() {
      return "infeccion [_max=" + _max + ", _actual=" + _actual + "]";
    }
    
    public void sumar(int a){
      _actual = _actual+a>=_max ? _max : _actual+a;
    }
    
    public void restar(int a){
      _actual = _actual-a<=0 ? 0 : _actual-a;
    }
    
  }
  
  public class resistencia{
    public int _max = 100;
    public int _actual = _max;
    
    public int _ratio_regeneracion = 2;
    
    @Override
    public String toString() {
      return "resistencia [_max=" + _max + ", _actual=" + _actual + "]";
    }  
    
    public void sumar(int a){
      _actual = _actual+a>=_max ? _max : _actual+a;
    }
    
    public void restar(int a){
      _actual = _actual-a<=0 ? 0 : _actual-a;
    }
    
    public void regenerar(){
      this.sumar(_ratio_regeneracion);
    }
  }
  
  public infeccion _infeccion = new infeccion();
  public resistencia _resistencia = new resistencia();
  public ArmaLista _armas;
  
  private ZomblindActivity _z;
  
  
  public Jugador (Context ctx){
    _z = (ZomblindActivity) ctx;
    
    _armas = new ArmaLista(_z);
  }
  
  public String toString(){
    return "VIDA: " + _infeccion.toString() + "  ESTAMINA: " + _resistencia.toString();
  }
  
  public void atacado(int a){
    _infeccion.sumar(a);
  }
//  
//  public void disparado(){
//    _vida = _vida==0 ? 0 : _vida--;
//  }
//  
  public boolean esVivo(){
    return _infeccion._actual>0;
  }
//  
//  public void curar(){
//    _vida = _vida == 5? 5 : _vida+1;
//    
//  }
//  
  public void info(){
    if (_infeccion._actual==_infeccion._max){
      _z._habladora.decir("Infectado");
    }
    //long t = (_infeccion._max - _infeccion._actual+10)*4;
    //long it = (_infeccion._actual + 10)*4;
    long t = (long) (200*Math.exp(-0.03*_infeccion._actual));
    long it = (long) (200*Math.exp(-0.03*(_infeccion._max-_infeccion._actual)));
    
    //_z._habladora.say(_infeccion._actual + " % de infecci?n" );
    _z._vibrador.vibrarpattern(new long []{10, t, it, t/2, it,t, it, t/2});
  }
  

}




Java Source Code List

antares.zomblind.ZomblindActivity.java
antares.zomblind.core.Jugador.java
antares.zomblind.core.Nucleo.java
antares.zomblind.core.levels.L000_menu.java
antares.zomblind.core.levels.NivelInfo.java
antares.zomblind.core.levels.checker.GolpeFrontal.java
antares.zomblind.core.levels.checker.Todos.java
antares.zomblind.core.levels.checker._Chequeador.java
antares.zomblind.core.levels.conditions.SinZombies.java
antares.zomblind.core.levels.conditions._Condicion.java
antares.zomblind.core.levels.generate.AleatorioFlojos.java
antares.zomblind.core.levels.generate.AleatorioTodos.java
antares.zomblind.core.levels.generate._Generador.java
antares.zomblind.core.levels.instancia.java
antares.zomblind.core.npcs.NpcData.java
antares.zomblind.core.npcs.NpcLista.java
antares.zomblind.core.npcs.npc.java
antares.zomblind.core.objetos.ArmaData.java
antares.zomblind.core.objetos.ArmaLista.java
antares.zomblind.core.objetos.Arma.java
antares.zomblind.core.objetos.Municion.java
antares.zomblind.core.opciones.java
antares.zomblind.in.acelerometro.java
antares.zomblind.in.orientacion.java
antares.zomblind.in.pantalla.java
antares.zomblind.in.teclado.java
antares.zomblind.out.debug.java
antares.zomblind.out.habladora.java
antares.zomblind.out.interfaz.java
antares.zomblind.out.vibrador.java