Ejemplo n.º 1
0
 public void Clear()
 {
     attackInProgress = null;
     comboCool.Clear();
     meal.Clear();
     acceptInput = true;
 }
Ejemplo n.º 2
0
    void Update()
    {
        Vector2 movement = target.position - transform.position;

        switch (state)
        {
        case State.Flee:
            mover.Move(-movement.normalized);
            // TODO move faster and clear when off screen
            if (cam != null)
            {
                var screenPos = cam.WorldToScreenPoint(transform.position);
                if (!cam.pixelRect.Contains(screenPos))
                {
                    state = State.Seeking;
                    health.Heal();
                }
            }
            break;

        case State.Seeking:
            if (movement.SqrMagnitude() > radius * radius)
            {
                mover.Move(movement.normalized);
            }
            else
            {
                mover.Move(Vector2.zero, movement.normalized);
                if (attackCooldown.cool)
                {
                    attackInProgress = (new Attack(2f)).Trigger(hitbox, (t) => t.target.CompareTag("Enemy"));
                    attackCooldown.Trigger();
                    anim.SetTrigger("Attack");
                    anim.SetBool("VaryAttack", !anim.GetBool("VaryAttack"));
                }
            }
            break;

        case State.Anim:
            mover.Move(Vector2.zero);
            break;
        }
    }
Ejemplo n.º 3
0
 public void Enqueue(FoodType food)
 {
     if (!inventory[food])
     {
         Debug.Log(string.Format("discarding, {0} (inv)", food));
         return;
     }
     else if (!acceptInput)
     {
         Debug.Log(string.Format("discarding, {0} (eat)", food));
         return;
     }
     else
     {
         Debug.Log(string.Format("got a food, {0}", food));
     }
     acceptInput = false;
     comboCool.Pause();
     meal.Enqueue(food);
     anim?.SetTrigger(Enum.GetName(typeof(FoodType), food));
     // TODO attack gets made somewhere else
     attackInProgress = (new Attack(2f)).Trigger(hitbox, (t) => t.target.CompareTag("Player"));
 }
Ejemplo n.º 4
0
 public void AttackEnd()
 {
     attackInProgress = null;
 }