Beispiel #1
0
 public Ghost(Game game)
     : base(game)
 {
     // TODO: Construct any child components here
     this.pacMan     = ((Game1)game).GetPacMan();
     gameConsole     = (GameConsole)game.Services.GetService(typeof(IGameConsole));
     strGhostTexture = "RedGhost";
     StartLoc        = new Vector2(50, 50);
     this.ghostState = GhostState.Roving;
 }
Beispiel #2
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            input   = new InputHandler(this);
            console = new GameConsole(this);

            pac       = new PacMan(this);
            redGhost  = new Ghost(this);
            tealGhost = new Ghost(this);
            tealGhost.strGhostTexture = "TealGhost";
            purpleGhost = new Ghost(this);
            purpleGhost.strGhostTexture = "PurpleGhost";
            food1 = new Food(this);
            food2 = new Food(this);
            food3 = new Food(this);
            food4 = new Food(this);

            foods = new List <Food>();
            foods.Add(food1);
            foods.Add(food2);
            foods.Add(food3);
            foods.Add(food4);

            this.Components.Add(input);
            this.Components.Add(console);
            this.Components.Add(pac);
            this.Components.Add(redGhost);
            this.Components.Add(tealGhost);
            this.Components.Add(purpleGhost);
            foreach (Food f in foods)
            {
                this.Components.Add(f);
                f.FoodHit        += new FoodHitEventHandler(pac.OnFoodHit);
                f.FoodHit        += new FoodHitEventHandler(redGhost.OnFoodHit);
                f.FoodHitTimeOut += new FoodHitEventHandler(redGhost.OnFoodHitTimeOut);
                f.FoodHit        += new FoodHitEventHandler(tealGhost.OnFoodHit);
                f.FoodHitTimeOut += new FoodHitEventHandler(tealGhost.OnFoodHitTimeOut);

                //Or better yet
                f.AddGhostHitEvents(purpleGhost);
            }
        }
Beispiel #3
0
 public GhostCollideEventArgs(Ghost ghost, PacMan pacMan)
 {
     this.ghost          = ghost;
     this.pacMan         = pacMan;
     ghost.spriteTexture = ghost.ghostHit;
 }