Пример #1
0
    //public ParticleSystem trailPartSys;
    //private Vector2 projDirNorm;
    //public SpriteAnim chargeArrowSpriteAnim;
    //public AnimationClip chargeArrowAnimClip;

    public void StopAndReset()
    {
        // Stops all coroutines.
        this.StopAllCoroutines();
        // Stop bow and arrow attack animation.
        bowSpriteAnim.Stop();
        // Restore walking bow. Sprite and rotation.
        bowSpriteR.sprite = defaultBowSprite;
        bowAndArrowGameObject.transform.eulerAngles = Vector3.zero;
        // Turn off charging projectile.
        //arrowSpriteR.sprite = null;
    }
Пример #2
0
    public void StopInputMove(bool stopSpriteAnim = true, bool setIdlePlayerSprite = true)
    {
        canInputMove  = false;
        running       = false;
        lastMoveLeft  = true;
        lastMoveRight = true;
        moveLeft      = false;
        moveRight     = false;

        if (stopSpriteAnim)
        {
            mySpriteAnim.Stop();
        }
        if (setIdlePlayerSprite)
        {
            spriteRend.sprite = idleSprite;
        }
        //animator.SetBool("Running", false);
        //SetRunAnimation();
    }
Пример #3
0
 void DeactivateProjectile()
 {
     inUse      = false;
     colStarted = false;
     colEnded   = false;
     collidersDamaged.Clear();
     myCol.enabled = false;
     mySpriteAnim.Stop();
     mySpriteR.sortingOrder = 0;
     mySpriteR.flipX        = false;
     //HitImpact.PlayImpactFX()
     // if (partSys != null) {
     //     partSys.Stop();
     // }
     // if (partSysParent != null) {
     //     partSys.transform.parent = partSysParent;
     // }
     // partSys = null;
     // partSysParent = null;
     this.gameObject.SetActive(false);
 }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetAxis("Horizontal") <= -0.9)
        {
            JoyLeftActive = true;
        }
        else
        {
            JoyLeftActive = false;
        }
        if (Input.GetAxis("Horizontal") >= 0.9)
        {
            JoyRightActive = true;
        }
        else
        {
            JoyRightActive = false;
        }

        if (Input.GetKeyDown(SprintButton))
        {
            MovementSpeed = SetSpeed + SprintBoost;
        }

        if (Input.GetKeyUp(SprintButton))
        {
            MovementSpeed = SetSpeed;
        }

        if (LeftKeyActive || RightKeyActive)
        {
            if (WalkAnimActive && !Anim.Active())
            {
                Debug.Log("AnimStart");
                Anim.PlayAnimation(0, AnimSpeed);
            }
        }

        PlayerRigid.velocity = new Vector2(Mathf.Clamp(PlayerRigid.velocity.x, -MovementSpeed, MovementSpeed), Mathf.Clamp(PlayerRigid.velocity.y, -9999, 6));

        if (Input.GetKey(LeftButton) || JoyLeftActive)
        {
            LeftKeyActive = true;
            if (MovementActive && LeftMovementActive)
            {
                PlayerRigid.velocity = new Vector2(-MovementSpeed, PlayerRigid.velocity.y);
            }

            //Flips the sprite so that it reflects the direction the player is facing.
            PlayerRenderer.flipX = true;
        }
        else
        {
            LeftKeyActive = false;
        }


        if (Input.GetKey(RightButton) || JoyRightActive)
        {
            RightKeyActive = true;
            if (MovementActive && RightMovementActive)
            {
                PlayerRigid.velocity = new Vector2(MovementSpeed, PlayerRigid.velocity.y);
            }

            //Flips the sprite so that it reflects the direction the player is facing.
            PlayerRenderer.flipX = false;
        }
        else
        {
            RightKeyActive = false;
        }

        if (!LeftKeyActive && !RightKeyActive)
        {
            //Stops the player from moving (sliding due to physics)
            Anim.Stop();
            PlayerRigid.velocity = new Vector2(0, PlayerRigid.velocity.y);

            if (CanJump)
            {
                PlayerRenderer.sprite = NormalSprite;
            }
        }

        if ((Input.GetKeyDown(JumpButton) || Input.GetButton("Jump")) && CanJump)
        {
            Anim.Stop();
            WalkAnimActive        = false;
            CanJump               = false;
            PlayerRenderer.sprite = JumpSprite;
            PlayerRigid.AddForce(new Vector2(0, JumpForce));
        }

        if (Left.Collided())
        {
            LeftMovementActive = false;
        }
        else
        {
            LeftMovementActive = true;
        }

        if (Right.Collided())
        {
            RightMovementActive = false;
        }
        else
        {
            RightMovementActive = true;
        }
    }