示例#1
0
 private void OnTriggerEnter(Collider other)
 {
     SnakeCollisionHandler.Allowed();
     // Debug.Log(other.gameObject.tag);
     if (other.gameObject.tag != "SnakeBodyPart" && other.gameObject.tag != "InputSurface")
     {
         SnakeCollisionHandler.Handle(other.gameObject);
     }
     SnakeCollisionHandler.Forbidden();
 }
示例#2
0
 // Update is called once per frame
 void Update()
 {
     if (!RotationHandler.IsRotating())
     {
         if (IsTouchingBody())
         {
             SnakeCollisionHandler.Allowed();
             SnakeCollisionHandler.Handle(this.gameObject);
             SnakeCollisionHandler.Forbidden();
         }
     }
 }
    IEnumerator LevelPlay()
    {
        InputManager.Allowed();
        WorldObjectManager.UpdateState("play");
        RotationHandler.Allowed();
        SnakeCollisionHandler.Allowed();
        Debug.Log("Level State: Play!\n");
        while (sLevelState == "play")
        {
            GameObject oCollision = SnakeCollisionHandler.CollisionObject();
            if (oCollision != null)
            {
                if (oCollision.tag == "Cube")
                {
                    sReason = "die_cube";
                    UpdateLevelState("die");
                    yield break;
                }
                else if (oCollision.tag == "SnakeBodyPart")
                {
                    sReason = "die_snake";
                    UpdateLevelState("die");
                    yield break;
                }
                else if (oCollision.tag == "Endpoint")
                {
                    UpdateLevelState("win");
                    yield break;
                }
                // }else if(oCollision.tag == "Obstacle"){
                //     oSnake.GetComponent<WorldObject_Snake>().UpdateState("decrease");
                //     oCollision.GetComponent<WorldObject_Obstacle>().UpdateState("into");

                //     GameObject currCollision = SnakeCollisionHandler.CollisionObject();

                //     while(oCollision == currCollision /*|| oCollision.GetComponent<WorldObject_Obstacle>().CurrentState()!="wait"*/){
                //         currCollision = SnakeCollisionHandler.CollisionObject();
                //         yield return null;
                //     }
                //     // Debug.Log("Leave the Obstacle!\n");
                // }
            }
            yield return(null);
        }
    }