Пример #1
0
    public void FireDirection(Vector2 position)
    {
        Quaternion rotation;

        switch (_movementComp.GetDirection())
        {
        case Direction.Back:
            rotation = Quaternion.Euler(0f, 0f, 0f);
            break;

        case Direction.Front:
            rotation = Quaternion.Euler(0f, 0f, 180f);
            break;

        case Direction.Left:
            rotation = Quaternion.Euler(0f, 0f, 90f);
            break;

        case Direction.Right:
            rotation = Quaternion.Euler(0f, 0f, 270f);
            break;

        default:
            rotation = Quaternion.Euler(0f, 0f, 180f);
            break;
        }
        CalcFireRate();
        PoolManager.Instance.ReuseObject(prefabSelected, position, rotation);
    }
Пример #2
0
    void Update()
    {
        // Set target to player
        if (!_aim.targetAim)
        {
            _aim.targetAim = GameManager.Instance.m_Player.transform;
        }

        if (_anim.isActiveAndEnabled)
        {
            _anim.SetFloat("MoveX", _move.x);
            _anim.SetFloat("MoveY", _move.y);
            _anim.SetFloat("Velocity", _move.Rigid2D.velocity.magnitude);
        }

        // Update Aim Direction
        switch (_move.GetDirection())
        {
        case (Direction.Back):
            _aim.SetAimRotation(180f);
            break;

        case (Direction.Front):
            _aim.SetAimRotation(0f);
            break;

        case (Direction.Left):
            _aim.SetAimRotation(270f);
            break;

        case (Direction.Right):
            _aim.SetAimRotation(90f);
            break;
        }

        if (healthCanvas.activeSelf && _healthTimer <= 0)
        {
            HideHealthCanvas();
        }
        else
        {
            _healthTimer -= Time.deltaTime;
        }
    }