Beispiel #1
0
    public void DoAction(Action action)
    {
        switch (action)
        {
        case Action.Attack:
            if (!ball.Starting)
            {
                ball.SetStart(player);
                break;
            }
            if (_attack.IsTouching(ball.GetComponent <BoxCollider2D>()))
            {
                ball.IncreaseSpeed();
            }
            break;

        case Action.Up:
            if (!_boxCollider.IsTouching(TopWall))
            {
                transform.Translate(new Vector3(0, Speed));
            }
            break;

        case Action.Down:
            if (!_boxCollider.IsTouching(BottomWall))
            {
                transform.Translate(new Vector3(0, -Speed));
            }

            break;
        }
    }
Beispiel #2
0
 void Notifie(Action action)
 {
     foreach (IPlayable playable in _playables)
     {
         playable.DoAction(action);
     }
 }
Beispiel #3
0
    public void DoAction(Action action)
    {
        if (_etat != Etat.None)
        {
            return;
        }
        switch (action)
        {
        case Action.Attack:
            _animator.SetTrigger("attack");
            _etat = Etat.Attack;;
            break;

        case Action.Up:
            if (_position < 3)
            {
                _position++;
            }
            _animator.SetInteger("position", _position);
            break;

        case Action.Down:
            if (_position > 1)
            {
                _position--;
            }
            _animator.SetInteger("position", _position);
            break;

        case Action.Left:
            transform.Translate(Vector3.left * Time.deltaTime * Speed);
            _animator.SetBool("walk", true);
            break;

        case Action.Right:
            transform.Translate(Vector3.right * Time.deltaTime * Speed);
            _animator.SetBool("walk", true);
            break;

        case Action.None:
            _animator.SetBool("walk", false);
            break;

        default:
            throw new ArgumentOutOfRangeException("action", action, null);
        }
    }