Exemplo n.º 1
0
 /// <summary>
 /// Set the BattlerState of a Battler character.
 /// </summary>
 /// <param name="newState">Ready = ready to battle, Defeated = already defeated,
 /// Locked = not able to battle yet, possibly need to finish a Quest first.</param>
 public void SetBattlerState(BattlerState newState)
 {
     _state = newState;
     if (_state == BattlerState.Ready)
     {
         _los.gameObject.SetActive(true);
     }
     else if (_state == BattlerState.Defeated)
     {
         _los.gameObject.SetActive(false);
         //TODO - have the battler return to its starting position
     }
     else if (_state == BattlerState.Locked)
     {
         _los.gameObject.SetActive(false);
         //TODO - implement locked/later quest features
     }
 }
Exemplo n.º 2
0
    //Co-routine for handling the termination of knockback
    public IEnumerator KnockCo(Transform tr, Battler b)
    {
        if (rb != null)
        {
            currentState = BattlerState.hitStun;
            Vector2 difference = transform.position - tr.position;
            difference = difference.normalized * 3f * ((b.baseAttack / Battler.MAX_BASEATTACK) + 1);
            rb.AddForce(difference, ForceMode2D.Impulse);
            yield return(new WaitForSeconds(.4f));

            rb.velocity = Vector2.zero;
            //knockback coroutine may reset the switch to death state
            if (currentState != BattlerState.dead)
            {
                currentState = BattlerState.idle;
            }
        }
    }
Exemplo n.º 3
0
    protected void Update()
    {
        if (health <= 0 && currentState != BattlerState.dead)
        {
            currentState = BattlerState.dead;
            Die();
        }

        //stamina regen
        if (stamina < maxStamina)
        {
            StaminaRegen();
        }

        //health regen
        if (health < maxHealth)
        {
            HealthRegen();
        }
    }
Exemplo n.º 4
0
    //Initialize the battler with default values
    protected void Awake()
    {
        maxHealth     = health = MIN_MAXHEALTH;
        maxStamina    = stamina = MIN_MAXSTAMINA;
        baseAttack    = MIN_BASEATTACK;
        movementSpeed = MIN_MAXMOVEMENTSPEED;
        dexterity     = MIN_DEXTERITY;
        vitality      = MIN_VITALITY;

        currentState = BattlerState.idle;

        animator = GetComponent <Animator>();
        rb       = GetComponent <Rigidbody2D>();
        aud      = GetComponentsInChildren <AudioSource>();
        sr       = GetComponent <SpriteRenderer>();

        lastAttackTime = -1;

        //movement direction (Regardless of implementation of movement)
        movementDirection     = new Vector3(0, 0, 0);
        lastTransformPosition = transform.position;
    }
Exemplo n.º 5
0
 public void ChangeState(BattlerState state)
 {
     currentState = state;
 }