Пример #1
0
 public void obtainMushRoom()
 {
     if (currentState.Equals(StateEnum.SMALL))
     {
         this.currentState = StateEnum.SUPER;
         this.score       += 100;
     }
 }
Пример #2
0
    public void OnTriggerEnter2D(Collider2D collider)
    {
        timeLeft -= Time.deltaTime;
        if (timeLeft < 0)
        {
            MinigameController.instance.GameOver();
        }
        var cowState     = cow.GetComponent <Cow>().StateEnum;
        var cowDirection = cow.GetComponent <Cow>().Horisontal;
        var foodInfo     = collider.GetComponent <FoodInfo>();

        if (!State.Equals(cowState))
        {
            return;
        }

        if (!HandlerDirection.Equals(cowDirection))
        {
            return;
        }

        if (foodInfo.IsPoisoned)
        {
            cow.GetComponent <Cow>().Event(StateEnum.Death);
            isGameOver = true;
        }
        else
        {
            score++;
            cow.GetComponent <Cow>().Event(StateEnum.Happy);
            Destroy(collider.gameObject);

            if (score == 10)
            {
                MinigameController.instance.GameComplete();
            }
        }
    }
Пример #3
0
    void PositiveMovement()
    {
        if (!canMove)
        {
            return;
        }

        if (state.Equals(StateEnum.WallGrab) || state.Equals(StateEnum.WallSlice))
        {
            return;
        }

        float horizontalMove = Input.GetAxisRaw("Horizontal") * speed;


        if (Mathf.Abs(rb.velocity.x) > Mathf.Abs(horizontalMove))                                                      // 超速状态下 减速
        {
            if (horizontalMove * rb.velocity.x <= 0 || state.Equals(StateEnum.Ground) || state.Equals(StateEnum.Drop)) // 只有按住按键才能保持超速,否则减速,落地减速
            {
                float drag = 0;
                switch (state)
                {
                case StateEnum.Drop:
                case StateEnum.Jump:
                case StateEnum.ReleaseJump:
                case StateEnum.WallJump:
                    drag = speed / airDrag;
                    break;

                case StateEnum.Default:
                case StateEnum.Ground:
                    drag = speed / moveDragTime;
                    break;
                }
                rb.velocity = new Vector2(Mathf.Lerp(rb.velocity.x, horizontalMove, drag * Time.fixedDeltaTime), rb.velocity.y);
            }
        }
        else // 加速
        {
            float accelerate = 0;
            switch (state)
            {
            case StateEnum.Drop:
            case StateEnum.Jump:
            case StateEnum.ReleaseJump:
            case StateEnum.WallJump:
                accelerate = speed / airMoveAccelerationTime;
                break;

            case StateEnum.Default:
            case StateEnum.Ground:
                accelerate = speed / moveAccelerationTime;
                break;
            }
            rb.velocity = new Vector2(Mathf.Lerp(rb.velocity.x, horizontalMove, accelerate * Time.fixedDeltaTime), rb.velocity.y);
        }
    }