示例#1
0
        private void OnCollisionEnter(Collision collision)
        {
            Player testplayer = collision.collider.gameObject.GetComponent <Player>();

            if (testplayer != null)
            {
                Rigidbody rb = collision.collider.gameObject.GetComponent <Rigidbody>();
                if (rb != null)
                {
                    Vector3 newV = rb.velocity;
                    newV.y = bounce;
                    if (collision.GetContact(0).point.y < transform.position.y)
                    {
                        newV.y *= -1;
                    }

                    rb.velocity = newV;
                }
                Jump jump = collision.collider.gameObject.GetComponent <Jump>();
                if (jump != null)
                {
                    jump.JumpState = Jump.PlayerJumpState.SlowFalling;
                }
            }
            WKAudio.PlayAudio("Pop");
            Invis();
            TimerManager.AddTask(Vis, 3);
        }
示例#2
0
        private void OnCollisionEnter(Collision collision)
        {
            Debug.Log(collision.collider.gameObject);
            Player testplayer = collision.collider.gameObject.GetComponent <Player>();

            if (testplayer != null)
            {
                Rigidbody rb = collision.collider.gameObject.GetComponent <Rigidbody>();
                if (rb != null)
                {
                    rb.velocity = rb.velocity + (Vector3.up * bounce);
                }

                /*
                 * Jump jump = collision.collider.gameObject.GetComponent<Jump>();
                 * if (jump != null)
                 * {
                 *  jump.JumpState = Jump.PlayerJumpState.SlowFalling;
                 *
                 * }*/
            }

            WKAudio.PlayAudio("Pop");
            Die();
        }
示例#3
0
        // Update is called once per frame
        void Update()
        {
            time -= Time.deltaTime;
            time  = Mathf.Max(0, time);

            GetComponent <Text>().text = "Time " + Mathf.Floor(time / 60) + ":" + Mathf.Floor(time % 60).ToString("00");

            for (int i = 0; i < 5; i++)
            {
                if (((int)Mathf.Floor(time) == i + 1) && (!signed[i]))
                {
                    TimerManager.AddLoopedTask(Throb, 1);
                    signed[i] = true;
                    WKAudio.PlayAudio("" + Alarms[i]);
                }
            }


            if (time <= 0)
            {
                TimerManager.AddLoopedTask(Throb, 1);
                WKAudio.PlayAudio("Death");
                AudioManager.instance.StopSound("Music");
                WKAudio.PlayAudio("GameOver");
                SceneManager.LoadScene("GameOver");
            }
        }
示例#4
0
 public void Die()
 {
     WKAudio.PlayAudio("Death");
     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 }
示例#5
0
        void Update()
        {
            Vector3 CurrentVelocity = PlayerRB.velocity;
            Vector3 NewVelocity     = CurrentVelocity;

            bool JumpPressed = WKInput.instance.Jump.Down();
            bool JumpHeld    = WKInput.instance.Jump.Held();

            Vector3 GroundVelocity = Vector3.zero;
            bool    Grounded       = CurrentPlayer.CheckIfGrounded();//out GroundVelocity);

            if (Grounded)
            {
                AvailableJumps = MaxAvailableJumps;
            }

            if (((JumpPressed) && (AvailableJumps > 0)) || Input.GetKey("p"))
            {
                AvailableJumps -= 1;
                JumpState       = PlayerJumpState.Jumping;

                WKAudio.PlayAudio("Jump");

                if (Grounded)
                {
                    NewVelocity.y = GroundJumpVelocity;
                }
                else
                {
                    NewVelocity.y = AirJumpVelocity;
                }
            }

            switch (JumpState)
            {
            case PlayerJumpState.Standing:
                if (Grounded)
                {
                    NewVelocity.y += -1f * Time.deltaTime;
                }
                else
                {
                    JumpState = PlayerJumpState.SlowFalling;
                    goto case PlayerJumpState.SlowFalling;
                }
                break;

            case PlayerJumpState.Jumping:
                if (!JumpHeld)
                {
                    JumpState = PlayerJumpState.FreeFalling;
                    goto case PlayerJumpState.FreeFalling;
                }
                if (CurrentVelocity.y < 0)
                {
                    JumpState = PlayerJumpState.SlowFalling;
                    goto case PlayerJumpState.SlowFalling;
                }
                goto case PlayerJumpState.SlowFalling;
            //break;

            case PlayerJumpState.SlowFalling:
                if (!JumpHeld)
                {
                    JumpState = PlayerJumpState.FreeFalling;
                    goto case PlayerJumpState.FreeFalling;
                }
                if (CurrentVelocity.y < FreefallVelocity)
                {
                    JumpState = PlayerJumpState.FreeFalling;
                    goto case PlayerJumpState.FreeFalling;
                }
                if ((Grounded) && (CurrentVelocity.y - GroundVelocity.y) < 0)
                {
                    JumpState = PlayerJumpState.Standing;
                    goto case PlayerJumpState.Standing;
                }
                NewVelocity.y += -RisingGravity * Time.deltaTime;
                break;

            case PlayerJumpState.FreeFalling:
                if ((Grounded) && (CurrentVelocity.y - GroundVelocity.y) < 0)
                {
                    JumpState = PlayerJumpState.Standing;
                    goto case PlayerJumpState.Standing;
                }
                NewVelocity.y += -FallingGravity * Time.deltaTime;
                break;
            }

            PlayerRB.velocity = NewVelocity;
        }