Exemple #1
0
    private IEnumerator PlayPickUpAnimation(ItemBase item)
    {
        item.transform.parent        = transform;
        item.transform.localPosition = Vector3.zero + new Vector3(0, 3.0f, 0);
        item.GetComponent <SpriteRenderer>().sortingLayerName = "Player";
        item.GetComponent <SpriteRenderer>().sortingOrder     = 10;
        Animator.Play("PickUpItem");
        _headObject.SetHeadDirection(PlayerHeadController.HeadDirection.Down);
        DisableCharacter();
        yield return(new WaitForSeconds(1f));

        EnableCharacter();
        _headObject.SetHeadDirection(PlayerHeadController.HeadDirection.Down);
        item.Disable();
        yield return(null);
    }
Exemple #2
0
    /*
     * private IEnumerator PlayPickUpAnimation(ItemBase item) {
     * item.transform.parent = transform;
     * item.transform.localPosition = Vector3.zero + new Vector3(0, 3.0f, 0);
     * item.GetComponent<SpriteRenderer>().sortingLayerName = "Player";
     * item.GetComponent<SpriteRenderer>().sortingOrder = 10;
     * Animator.Play("PickUpItem");
     * _headObject.SetHeadDirection(PlayerHeadController.HeadDirection.Down);
     * DisableCharacter();
     * yield return new WaitForSeconds(1f);
     * EnableCharacter();
     * _headObject.SetHeadDirection(PlayerHeadController.HeadDirection.Down);
     * item.Disable();
     * yield return null;
     * }
     */

    protected override Vector3 DetermineMovement()
    {
        var movement = new Vector3();

        if (!IsDead && InputHelpers.IsAnyKey("w", "s", "a", "d"))
        {
            ShouldMove         = true;
            _gunObject.enabled = false;

            var headDirection = PlayerHeadController.HeadDirection.Down;

            if (Input.GetKey("w") && Input.GetKey("a"))
            {
                movement     += new Vector3(-1, 1, 0);
                headDirection = PlayerHeadController.HeadDirection.Left;
            }
            else if (Input.GetKey("w") && Input.GetKey("d"))
            {
                movement     += new Vector3(1, 1, 0);
                headDirection = PlayerHeadController.HeadDirection.Right;
            }
            else if (Input.GetKey("s") && Input.GetKey("a"))
            {
                movement     += new Vector3(-1, -1, 0);
                headDirection = PlayerHeadController.HeadDirection.Left;
            }
            else if (Input.GetKey("s") && Input.GetKey("d"))
            {
                movement     += new Vector3(1, -1, 0);
                headDirection = PlayerHeadController.HeadDirection.Right;
            }
            else if (Input.GetKey("w"))
            {
                movement     += new Vector3(0, 1, 0);
                headDirection = PlayerHeadController.HeadDirection.Up;
            }
            else if (Input.GetKey("s"))
            {
                movement          += new Vector3(0, -1, 0);
                _gunObject.enabled = true;
                headDirection      = PlayerHeadController.HeadDirection.Down;
            }
            else if (Input.GetKey("a"))
            {
                movement     += new Vector3(-1, 0, 0);
                headDirection = PlayerHeadController.HeadDirection.Left;
            }
            else if (Input.GetKey("d"))
            {
                movement     += new Vector3(1, 0, 0);
                headDirection = PlayerHeadController.HeadDirection.Right;
            }

            movement.Normalize();

            if (!_shootController.IsShooting)
            {
                _headObject.SetHeadDirection(headDirection);
            }
        }
        else if (IsDead)
        {
            ShouldMove = false;
        }
        else
        {
            _headObject.SetHeadDirection(PlayerHeadController.HeadDirection.Down);
        }
        return(movement);
    }