Beispiel #1
0
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.CompareTag("SuperTablet"))
     {
         PacState          = PacManStates.SuperPM;
         isTabletCollision = true;
         Destroy(col.gameObject);
     }
     if (col.gameObject.CompareTag("Enemy"))
     {
         isGhostCollision = true;
         _ghostObject     = col;
     }
 }
Beispiel #2
0
    //end of states



    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Pick_Up"))
        {
            other.gameObject.SetActive(false);

            totalCrums = totalCrums + 1;
        }

        if (other.CompareTag("Enemy"))
        {
            deadStateCondition();
        }

        if (other.CompareTag("SuperTablet"))
        {
            superPMStateCondition();
            PacState = PacManStates.SuperPM;
        }
    }
    public void EventCheck(string ColliderName, string CollidedWith, GameObject ob)
    {
        if (ColliderName == "claire" && power == 1)
        {
            PacState = PacManStates.SuperPM;
        }

        if (CollidedWith == "claire" && power == 0)
        {
            CurrentEvent = GameEvents.Hunting;
            player.gameObject.transform.position = new Vector3(4, 2, 1);
            player.SetActive(false);
            //   Ghosthunting();
        }
        if (ColliderName == "claire")
        {
            if (CollidedWith == "Sphere (11)" || CollidedWith == "Sphere (12)" || CollidedWith == "Sphere (13)" || CollidedWith == "Sphere (14)" ||
                CollidedWith == "Sphere (15)" || CollidedWith == "Sphere (16)" || CollidedWith == "Sphere (17)" || CollidedWith == "Sphere (18)" || CollidedWith == "Sphere (19)")
            {
                CurrentEvent = GameEvents.EatCrum;
            }
        }

        if (ColliderName == "claire")
        {
            //  Debug.Log("collider = " + col + " other obj = " + target);
            if (CollidedWith == "Capsule" || CollidedWith == "Capsule (1)" || CollidedWith == "Capsule (2)")
            {
                ob.gameObject.SetActive(false);
                CurrentEvent = GameEvents.EatSuperTab;
            }
        }



        switch (PacState)
        {
        case PacManStates.Spawned:

            //       stateOFpac.text = "Spawned";
            player.SetActive(true);

            //  Spawned();
            Debug.Log("Spawned entered");


            CurrentEvent = GameEvents.GameStart;
            break;

        case PacManStates.Roaming:



            break;

        case PacManStates.SuperPM:
            if (CollidedWith == "StoneMonster (9)" && power == 1)
            {
                SM9.SetActive(false);
                SMtime = 500;
            }
            if (CollidedWith == "StoneMonster (8)" && power == 1)
            {
                //  Debug.Log("here in power mode " + otherObj);
                SMtime = 500;
                SM8.SetActive(false);
            }
            if (CollidedWith == "StoneMonster (7)" && power == 1)
            {
                //  Debug.Log("here in power mode " + otherObj);
                SM7.SetActive(false);

                SMtime = 500;
            }
            if (CollidedWith == "StoneMonster (6)" && power == 1)
            {
                //   Debug.Log("here in power mode " + otherObj);
                SMtime = 500;
                SM6.SetActive(false);
            }
            break;

        case PacManStates.WinState:

            break;

        case PacManStates.Dead:
            if (life > 0)
            {
                // player.transform.position = new Vector3(4, 2, 1);
                //  collision.gameObject.transform.position = new Vector3(4, 2, 1);
                life--;

                Debug.Log("Life Lost , lifes left =" + (life));


                //  PacState = PacManStates.Spawned;
                CurrentEvent = GameEvents.NewLife;
                //  PacState = PacManStates.Spawned;
            }


            else if (life == 0)
            {
                life--;

                Destroy(player);
            }

            break;

        default:

            break;
        }


        switch (GhState)
        {
        case GhostStates.ghostrespawn:

            Ghostrespawn();

            break;

        case GhostStates.Ghostroaming:
            //   Debug.Log("roam ghost  ");
            SM6.transform.Translate(Vector3.forward * Time.deltaTime / 3);
            SM7.transform.Translate(Vector3.forward * Time.deltaTime / 3);
            SM8.transform.Translate(Vector3.forward * Time.deltaTime / 3);
            SM9.transform.Translate(Vector3.forward * Time.deltaTime / 3);

            break;

        case GhostStates.Ghostscared:

            SM6.transform.Translate(Vector3.forward * Time.deltaTime / 2);
            SM7.transform.Translate(Vector3.forward * Time.deltaTime / 2);
            SM8.transform.Translate(Vector3.forward * Time.deltaTime / 2);
            SM9.transform.Translate(Vector3.forward * Time.deltaTime / 2);

            break;

        case GhostStates.GhostDead:
            CurrentEvent = GameEvents.TimeOut;

            break;
        }

        switch (CurrentEvent)
        {
        case GameEvents.NewLife:

            PacState = PacManStates.Spawned;
            break;

        case GameEvents.GameStart:
            PacState = PacManStates.Roaming;
            break;

        case GameEvents.EncByPacMan:

            //   GhState = GhostStates.GhostDead;
            break;

        case GameEvents.EncByGhost:
            if (life > 0)
            {
                // player.transform.position = new Vector3(4, 2, 1);
                //  collision.gameObject.transform.position = new Vector3(4, 2, 1);
                life--;
                Debug.Log("Life Lost , lifes left =" + (life));



                //  PacState = PacManStates.Spawned;
            }


            else if (life == 0)
            {
                life--;
                // Dead();

                //   PacState = PacManStates.Dead;
            }
            PacState = PacManStates.Dead;
            break;

        case GameEvents.EatCrum:
            if (ColliderName == "claire")
            {
                if (CollidedWith == "Sphere (11)" || CollidedWith == "Sphere (12)" || CollidedWith == "Sphere (13)" || CollidedWith == "Sphere (14)" ||
                    CollidedWith == "Sphere (15)" || CollidedWith == "Sphere (16)" || CollidedWith == "Sphere (17)" || CollidedWith == "Sphere (18)" || CollidedWith == "Sphere (19)")
                {
                    //  Debug.Log(crums);


                    ob.gameObject.SetActive(false);
                    //Destroy(col.gameObject);
                    // transform.Rotate(0, 180, 0);
                    //    Debug.Log("rotated" + otherObj);
                    crums = crums + 1;
                    if (crums == 18)
                    {
                        CurrentEvent = GameEvents.CrumsFinished;
                        //  Winstate();
                    }
                }
            }

            break;

        case GameEvents.EatSuperTab:

            //Debug.Log("here " + otherObj);
            player.transform.localScale = new Vector3(2, 2, 2);
            //  ob.gameObject.SetActive(false);
            time  = 1000;
            power = 1;

            GhState = GhostStates.Ghostscared;


            break;

        case GameEvents.AllLivesLost:

            break;

        case GameEvents.CrumsFinished:

            break;

        case GameEvents.Run:

            break;

        case GameEvents.TimeOut:


            if (GhState == GhostStates.Ghostscared)
            {
                GhState = GhostStates.Ghostroaming;
            }
            //if (time < 0 && life >= 0)
            //{
            //    player.transform.localScale = new Vector3(1, 1, 1);
            //    power = 0;
            //   // GhostRoaming();
            //}
            //else
            //{
            //    power = 1;
            //   // Ghostscared();
            //}
            break;

        case GameEvents.Hunting:


            PacState = PacManStates.Dead;
            break;
        }
    }
Beispiel #4
0
    public void EventCheck(string ColliderName, string CollidedWith, GameObject ob)
    {
        // states
        switch (CurrentEvent)
        {
        case GameEvents.NewLife:

            PacState = PacManStates.Spawned;
            break;

        case GameEvents.GameStart:
            PacState = PacManStates.Roaming;
            break;

        case GameEvents.EncByPacMan:

            GhState = GhostStates.GhostDead;
            break;

        case GameEvents.EatCrum:
            if (ColliderName == "pacman")
            {
                totalCrums = totalCrums + 1;
                if (totalCrums == 200)
                {
                    CurrentEvent = GameEvents.CrumsFinished;
                    //  Winstate();
                    PacState = PacManStates.WinState;
                }
            }

            break;

        case GameEvents.EatSuperTab:


            GhState  = GhostStates.Ghostscared;
            PacState = PacManStates.SuperPM;

            break;

        case GameEvents.AllLivesLost:
            PacState = PacManStates.Dead;
            break;

        case GameEvents.CrumsFinished:
            PacState = PacManStates.WinState;
            break;

        case GameEvents.Run:
            PacState = PacManStates.Roaming;
            break;

        case GameEvents.TimeOut:


            if (GhState == GhostStates.Ghostscared)
            {
                GhState = GhostStates.Ghostroaming;
            }

            break;

        case GameEvents.Hunting:


            PacState = PacManStates.Dead;
            break;
        }
    }