Example #1
0
        //Function to fire event
        // return the Pacman state.....
        public PacManState FireEvent(int eventNumber)
        {
            PacManEvents triggerEvent = (PacManEvents)eventNumber;

            if (PacmanCurrentState.Equals(PacManState.START_PAC))
            {
                switch (triggerEvent)
                {
                case PacManEvents.ToEatCheeze:
                    PacmanCurrentState = PacManState.START_PAC;
                    return(PacmanCurrentState);

                    break;

                case PacManEvents.ToEatSuperTab:
                    PacmanCurrentState = PacManState.SUPERMAN;
                    return(PacmanCurrentState);

                    break;

                case PacManEvents.EatByGhost:
                    PacmanCurrentState = PacManState.DEAD;
                    return(PacmanCurrentState);

                    break;

                case PacManEvents.ToEatLastCheeze:
                    PacmanCurrentState = PacManState.LEVELUP;
                    return(PacmanCurrentState);

                    break;

                default:
                    inValid = true;
                    return(PacmanCurrentState);

                    break;
                }
            }
            else if (PacmanCurrentState.Equals(PacManState.SUPERMAN))
            {
                switch (triggerEvent)
                {
                case PacManEvents.ToEatCheeze:
                    PacmanCurrentState = PacManState.SUPERMAN;
                    return(PacmanCurrentState);

                case PacManEvents.ToEatSuperTab:
                    PacmanCurrentState = PacManState.SUPERMAN;
                    return(PacmanCurrentState);

                case PacManEvents.PacmanEatsSacredGhost:
                    PacmanCurrentState = PacManState.SUPERMAN;
                    return(PacmanCurrentState);

                case PacManEvents.BraveGhostEatsPacman:
                    PacmanCurrentState = PacManState.DEAD;
                    return(PacmanCurrentState);

                case PacManEvents.SuperPacmanTimeOut:
                    PacmanCurrentState = PacManState.START_PAC;
                    return(PacmanCurrentState);

                default:
                    inValid = true;
                    return(PacmanCurrentState);
                }
            }
            else if (PacmanCurrentState.Equals(PacManState.DEAD))
            {
                switch (triggerEvent)
                {
                case PacManEvents.NoLifeLeft:
                    PacmanCurrentState = PacManState.GAMEOVER;
                    return(PacmanCurrentState);

                case PacManEvents.LifeLeft:
                    PacmanCurrentState = PacManState.START_PAC;
                    return(PacmanCurrentState);

                default:
                    inValid = true;
                    return(PacmanCurrentState);
                }
            }
            else if (PacmanCurrentState.Equals(PacManState.LEVELUP))
            {
                switch (triggerEvent)
                {
                case PacManEvents.NextLevel:
                    PacmanCurrentState = PacManState.START_PAC;
                    return(PacmanCurrentState);

                case PacManEvents.LastLevelGameUp:
                    PacmanCurrentState = PacManState.GAMEOVER;
                    return(PacmanCurrentState);

                default:
                    inValid = true;
                    return(PacmanCurrentState);
                }
            }
            else
            {
                switch (triggerEvent)
                {
                case PacManEvents.LastLevelGameUp:
                    PacmanCurrentState = PacManState.GAMEOVER;
                    return(PacmanCurrentState);

                default:
                    inValid = true;
                    return(PacmanCurrentState);
                }
            }
        }
Example #2
0
    //pac fire event function
    public void pacFireEvent(PacManEvents e)
    {
        if (this.PacmanCurrentState == PacManState.Start_Pacman)
        {
            switch (e)
            {
            case PacManEvents.EatCheese:
                this.PacmanCurrentState = PacManState.Start_Pacman;
                this.color = Color.green;
                break;

            case PacManEvents.Eat_SuperTablet:
                this.PacmanCurrentState = PacManState.Super_Pacman;
                this.color = Color.blue;
                break;

            case PacManEvents.Eaten_by_ghost:
                this.PacmanCurrentState = PacManState.DEAD;
                this.color = Color.red;
                break;

            case PacManEvents.ToEatLastCheeze:
                this.PacmanCurrentState = PacManState.LEVELUP;
                this.color = Color.yellow;
                break;

            default:
                this.PacmanCurrentState = PacManState.Start_Pacman;
                this.color = Color.green;
                break;
            }
        }
        else if (this.PacmanCurrentState == PacManState.Super_Pacman)
        {
            switch (e)
            {
            case PacManEvents.EatCheese:
                this.PacmanCurrentState = PacManState.Super_Pacman;
                this.color = Color.blue;
                break;

            case PacManEvents.Eat_SuperTablet:
                this.PacmanCurrentState = PacManState.Super_Pacman;
                this.color = Color.blue;
                break;

            case PacManEvents.ToEatLastCheeze:
                this.PacmanCurrentState = PacManState.LEVELUP;
                this.color = Color.yellow;
                break;

            case PacManEvents.Pacman_Eats_Sacred_Ghost:
                this.PacmanCurrentState = PacManState.Super_Pacman;
                this.color = Color.blue;
                break;

            case PacManEvents.Brave_Ghost_Eats_Pacman:
                this.PacmanCurrentState = PacManState.DEAD;
                this.color = Color.red;
                break;

            case PacManEvents.SuperPacman_Timeout:
                this.PacmanCurrentState = PacManState.Start_Pacman;
                this.color = Color.green;
                break;

            default:
                this.PacmanCurrentState = PacManState.Super_Pacman;
                this.color = Color.blue;
                break;
            }
        }
        else if (this.PacmanCurrentState == PacManState.DEAD)
        {
            switch (e)
            {
            case PacManEvents.NoLifeLeft:
                this.PacmanCurrentState = PacManState.GAMEOVER;
                this.color = Color.black;
                break;

            case PacManEvents.LifeLeft:
                this.PacmanCurrentState = PacManState.Start_Pacman;
                this.color = Color.green;
                break;

            default:
                this.PacmanCurrentState = PacManState.DEAD;
                this.color = Color.red;
                break;
            }
        }
        else if (this.PacmanCurrentState == PacManState.LEVELUP)
        {
            switch (e)
            {
            case PacManEvents.NextLevel:
                this.PacmanCurrentState = PacManState.Start_Pacman;
                this.color = Color.green;
                break;

            case PacManEvents.LastLevel:
                this.PacmanCurrentState = PacManState.GAMEOVER;
                this.color = Color.black;
                break;

            default:
                this.PacmanCurrentState = PacManState.LEVELUP;
                this.color = Color.yellow;
                break;
            }
        }
        else
        {
            switch (e)
            {
            case PacManEvents.LastLevel:
                this.PacmanCurrentState = PacManState.GAMEOVER;
                this.color = Color.black;
                break;

            default:
                inValid = true;
                break;
            }
        }
    }