Exemplo n.º 1
0
Arquivo: Player.cs Projeto: Awenc/Jump
        private void FixedUpdate()
        {
            m_Rayhit = Physics2D.Raycast(CachedTransform.localPosition, Vector2.down, 0.35f, 1 << 8);

            if (m_Rayhit.collider != null && !m_IsJump)
            {
                if (m_Rayhit.collider.tag == "DeathGround")
                {
                    Log.Info("GameOver");
                    GameEntry.Event.Fire(this, ReferencePool.Acquire <GameOverEventArgs>());
                    GameEntry.Entity.HideEntity(this);
                }
                else
                {
                    m_Rigidbody2D.bodyType = RigidbodyType2D.Static;
                    m_IsJump = true;
                    CachedTransform.DOLocalMoveY(transform.localPosition.y + m_DefaultMoveDistance, 0.4f).SetEase(Ease.OutCubic).OnComplete(() =>
                    {
                        m_IsJump = false;
                        m_Rigidbody2D.bodyType = RigidbodyType2D.Dynamic;
                        CheckeUpScore();
                    });
                }
            }
            CameraChange();
            float Hor = Input.GetAxis("Horizontal");//当你按‘a’'d'键返回一个[-1,1]的值

            CachedTransform.localPosition += Vector3.right * Hor * Time.deltaTime * 5;
        }