Inheritance: MonoBehaviour
Example #1
0
    public Main()
    {
      InitializeComponent();
      paper = pctPlayField.CreateGraphics();
      muren = new Muren();
      rndAngle = new Random();
      splash = new Splash();
      #region initialize pacman & ghosts
      //pacman
      pacman = new Pacman();
      pacman.X = 10;
      pacman.Y = 12;
      pacman.Angle = 0;
      pacman.Wall = 0;
      pacman.PrevX = 10;
      pacman.PrevY = 12;
      pacman.Sprites = pacman.pacmanUp;

      //red ghost
      redGhost = new Monster();
      redGhost.X = 10;
      redGhost.Y = 10;
      redGhost.Angle = 3;
      redGhost.Wall = 0;
      redGhost.PrevX = 10;
      redGhost.PrevY = 10;
      redGhost.PrevAngle = 0;
      redGhost.Sprites = Image.FromFile("../../images/ghostRed.png");

      //green ghost
      greenGhost = new Monster();
      greenGhost.X = 11;
      greenGhost.Y = 10;
      greenGhost.Angle = 3;
      greenGhost.Wall = 0;
      greenGhost.PrevX = 11;
      greenGhost.PrevY = 10;
      greenGhost.PrevAngle = 0;
      greenGhost.Sprites = Image.FromFile("../../images/ghostGreen.png");

      //yellow ghost
      yellowGhost = new Monster();
      yellowGhost.X = 9;
      yellowGhost.Y = 10;
      yellowGhost.Angle = 3;
      yellowGhost.Wall = 0;
      yellowGhost.PrevX = 9;
      yellowGhost.PrevY = 10;
      yellowGhost.PrevAngle = 0;
      yellowGhost.Sprites = Image.FromFile("../../images/ghostYellow.png");
      #endregion


    }
Example #2
0
        void _game_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "PacMan")
            {
                if (_Pacman != null)
                    _Pacman.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(_Pacman_PropertyChanged);

                _Pacman = _game.PacMan;
                     if (_Pacman != null)
                     {
                         _Pacman.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_Pacman_PropertyChanged);
                         Pacman.xyList = xyList;
                     }

                NotifyPropertyChanged("Pacman");
            }
        }
Example #3
0
        public void newGame()
        {
            pacman = new Pacman();
            this.Width = pacman.radius * 2 * (WORLD_WIDTH + 1);
            this.Height = pacman.radius * 2 * (WORLD_HEIGHT + 1);

            //centar
            pacman.posX = WORLD_WIDTH / 2;
            pacman.posY = WORLD_HEIGHT / 2;

            for (int i = 0; i < foodWorld.Length; i++)
            {
                for (int j = 0; j < foodWorld[i].Length; j++)
                {
                    foodWorld[i][j] = true;
                }
            }

            timer.Start();
        }
Example #4
0
        public ConsoleManager(IInputDevice inputDevice, int sleepTimeout)
        {
            this.inputDevice = inputDevice;
            this.sleepTimeout = sleepTimeout;

            this.inputDevice.LeftArrowKeyPressed += new EventHandler(this.inputDevice_LeftArrowKeyPressed);
            this.inputDevice.RightArrowKeyPressed += new EventHandler(this.inputDevice_RightArrowKeyPressed);
            this.inputDevice.UpArrowKeyPressed += new EventHandler(this.inputDevice_UpArrowKeyPressed);
            this.inputDevice.DownArrowKeyPressed += new EventHandler(this.inputDevice_DownArrowKeyPressed);

            InitMaze();

            pacman = new Pacman(new Location(15, 18), '>', ConsoleColor.Yellow);
            pacman.ScoreUpdated += new ScoreUpdatedEventHandler(this.pacman_ScoreUpdated);
            Draw(pacman);

            IMovingStrategy strategy = new BfsStrategy();

            // Shadow, the red guy
            Ghost blinky = new Ghost(new Location(8, 18), ConsoleColor.Red, strategy);
            // Bashful, the blue guy
            Ghost inky = new Ghost(new Location(11, 16), ConsoleColor.Cyan, strategy);
            // Speedy, the pink guy
            Ghost pinky = new Ghost(new Location(11, 18), ConsoleColor.Magenta, strategy);
            // Pokey, the slow guy
            Ghost clyde = new Ghost(new Location(11, 20), ConsoleColor.Green, strategy);

            ghosts = new Ghost[4];
            ghosts[0] = blinky;
            ghosts[1] = inky;
            ghosts[2] = pinky;
            ghosts[3] = clyde;

            foreach (Ghost ghost in ghosts)
            {
                ghost.EndOfRouteReached += new EventHandler(this.ghost_EndOfRouteReached);
                ghost.CalcRoute(routeTargets[targetSelector.Next(routeTargets.Length)], maze);
            }
        }
Example #5
0
    // Use this for initialization
    public void Start()
    {
        isFirstMove   = true;
        currentMode   = startMode;
        houseMode     = startHouseMode;
        nextDirection = startDirection;
        anim          = GetComponent <Animator>();

        UpdateTile();

        if (gameController == null)
        {
            GameObject Camera = GameObject.Find("Main Camera");
            gameController = Camera.GetComponent <GameController>();
        }

        if (player == null)
        {
            player = gameController.player;
        }


        //InitializePathFinder();
    }
Example #6
0
 void Start()
 {
     pacmanScript = (Pacman)target.GetComponent(typeof(Pacman));
     agent        = GetComponent <NavMeshAgent>();
 }
Example #7
0
    // Update is called once per frame
    void Update()
    {
        //Left click to place Pacman
        if (Input.GetMouseButtonDown(0) && !hoveringOnGUI)
        {
            Vector2 rayPos = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
            RaycastHit2D hit = Physics2D.Raycast(rayPos, Vector2.zero, 0f);

            if (hit.transform.tag == "Pellet")
            {
                //Spawn Pacman
                pacman = Instantiate(pacmanPrefab, new Vector3(hit.transform.position.x, hit.transform.position.y, hit.transform.position.z - 1), Quaternion.identity) as GameObject;
                pacmanScript = pacman.GetComponent<Pacman>();
                pacmanScript.currentRow = hit.transform.gameObject.GetComponent<PelletInfo>().row;
                pacmanScript.currentCol = hit.transform.gameObject.GetComponent<PelletInfo>().col;
                pacmanScript.text = text;
                pacmanScript.finalMap = finalMap;
                pacmanScript.maxCol = colNum;
                pacmanScript.thePellets = thePellets;
                pacmanScript.groupSize = groupSize;

                pacmanPlaced = true;

            }
        }

        //If we have placed pacman and hit start
        if (begin)
        {

        }

        //Move Camera
        if (Input.GetKey(KeyCode.RightArrow))
        {
            Vector3 cameraPos = theCamera.transform.position;
            cameraPos.x += 1;
            theCamera.transform.position = cameraPos;
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            Vector3 cameraPos = theCamera.transform.position;
            cameraPos.x -= 1;
            theCamera.transform.position = cameraPos;
        }

        if (Input.GetKey(KeyCode.UpArrow))
        {
            Vector3 cameraPos = theCamera.transform.position;
            cameraPos.y += 1;
            theCamera.transform.position = cameraPos;
        }

        if (Input.GetKey(KeyCode.DownArrow))
        {
            Vector3 cameraPos = theCamera.transform.position;
            cameraPos.y -= 1;
            theCamera.transform.position = cameraPos;
        }
    }
Example #8
0
 public void RegisterPlayer(Pacman pacman)
 {
     _pacman = pacman;
     _pacman.SubscribeOnGetCaughtByGhosts(OnPacmanGetCaughtByGhosts);
 }
        public PacmanController(Game game, Pacman pacMan) : base(game)
        {
            Game.Components.Add(this);

            this.pacman = pacMan;
        }
Example #10
0
 public WhiteBorderDecorator(Pacman decoratedPacman) : base(decoratedPacman)
 {
 }
Example #11
0
 public GhostFullyRandom(Pacman pacman, Level level) : base(pacman, level)
 {
 }
Example #12
0
 public void Initialize(Pacman pacman, TileUtility tileUtility)
 {
     this.pacman      = pacman;
     this.tileUtility = tileUtility;
 }
Example #13
0
 private void PacmanGoUpCommand(object parameter)
 {
     Pacman.Direction = Direction.Right;
     Pacman.Step();
 }
Example #14
0
        public void StartMoveTest()
        {
            var strategyStr =
                "00000:3,00001:4,00002:0,00010:3,00011:4,00012:2,00020:1,00021:4,00022:0,00100:2,00101:4,00102:0,00110:2,00111:4,00112:0,00120:2,00121:4,00122:0,00200:0,00201:4,00202:0,00210:0,00211:4,00212:0,00220:0,00221:4,00222:1,01000:3,01001:4,01002:0,01010:0,01011:4,01012:0,01020:2,01021:0,01022:2,01100:1,01101:4,01102:1,01110:1,01111:1,01112:1,01120:1,01121:1,01122:4,01200:1,01201:4,01202:1,01210:3,01211:1,01212:0,01220:0,01221:1,01222:6,02000:3,02001:4,02002:4,02010:3,02011:4,02012:1,02020:1,02021:1,02022:1,02100:3,02101:4,02102:1,02110:6,02111:4,02112:1,02120:1,02121:2,02122:2,02200:0,02201:4,02202:2,02210:0,02211:4,02212:4,02220:2,02221:4,02222:2,10000:0,10001:4,10002:4,10010:0,10011:4,10012:2,10020:2,10021:4,10022:2,10100:2,10101:4,10102:0,10110:2,10111:2,10112:6,10120:2,10121:4,10122:6,10200:1,10201:4,10202:0,10210:6,10211:4,10212:2,10220:6,10221:3,10222:0,11000:3,11001:4,11002:2,11010:3,11011:3,11012:3,11020:0,11021:4,11022:3,11100:3,11101:3,11102:3,11110:3,11111:3,11112:3,11120:1,11121:4,11122:3,11200:3,11201:3,11202:0,11210:3,11211:3,11212:3,11220:3,11221:4,11222:4,12000:0,12001:4,12002:4,12010:3,12011:4,12012:4,12020:0,12021:4,12022:0,12100:3,12101:4,12102:4,12110:4,12111:4,12112:0,12120:4,12121:4,12122:4,12200:6,12201:4,12202:4,12210:6,12211:4,12212:0,12220:6,12221:4,12222:0,20000:3,20001:4,20002:4,20010:3,20011:4,20012:4,20020:1,20021:4,20022:6,20100:2,20101:4,20102:5,20110:5,20111:5,20112:5,20120:2,20121:5,20122:1,20200:6,20201:4,20202:3,20210:5,20211:4,20212:5,20220:5,20221:5,20222:5,21000:2,21001:4,21002:2,21010:5,21011:5,21012:5,21020:1,21021:5,21022:2,21100:5,21101:5,21102:5,21110:5,21111:4,21112:3,21120:5,21121:4,21122:2,21200:5,21201:6,21202:6,21210:6,21211:6,21212:6,21220:6,21221:6,21222:6,22000:2,22001:4,22002:6,22010:3,22011:4,22012:3,22020:6,22021:6,22022:2,22100:6,22101:6,22102:6,22110:6,22111:6,22112:6,22120:2,22121:6,22122:6,22200:6,22201:4,22202:3,22210:6,22211:6,22212:4,22220:6,22221:6,22222:6,";
            var dicAction = new Dictionary <int, string>
            {
                { 0, "up" },
                { 1, "right" },
                { 2, "down" },
                { 3, "left" },
                { 4, "eat" },
                { 5, "freeze" },
                { 6, "random" }
            };
            var pacman = new Pacman {
                Strategy = StringHelper.ConvertStringToStarategy(strategyStr), Points = new int[1]
            };
            var generateChecker = new GenerateChecker();
            var checker         = generateChecker.GenerateEmptyChecker();

            foreach (var line in pacman.Strategy.Lines)
            {
                Console.WriteLine($"Key: {line.Key} Value:{dicAction[line.Value]}");
            }

            var beanPosition = new List <int[]>
            {
                new[] { 1, 3 },
                new [] { 1, 5 },
                new [] { 1, 7 },
                new [] { 1, 9 },
                new [] { 2, 1 },
                new [] { 2, 4 },
                new [] { 2, 6 },
                new [] { 2, 7 },
                new [] { 2, 9 },
                new [] { 3, 2 },
                new [] { 3, 5 },
                new [] { 3, 8 },
                new [] { 3, 10 },
                new [] { 4, 1 },
                new [] { 4, 3 },
                new [] { 4, 6 },
                new [] { 4, 10 },
                new [] { 5, 2 },
                new [] { 5, 4 },
                new [] { 5, 8 },
                new [] { 5, 9 },
                new [] { 6, 1 },
                new [] { 6, 3 },
                new [] { 6, 5 },
                new [] { 6, 7 },
                new [] { 6, 9 },
                new [] { 7, 1 },
                new [] { 7, 3 },
                new [] { 7, 4 },
                new [] { 7, 5 },
                new [] { 7, 8 },
                new [] { 7, 10 },
                new [] { 8, 2 },
                new [] { 8, 3 },
                new [] { 8, 4 },
                new [] { 8, 6 },
                new [] { 8, 7 },
                new [] { 8, 9 },
                new [] { 8, 10 },
                new [] { 9, 1 },
                new [] { 9, 2 },
                new [] { 9, 4 },
                new [] { 9, 5 },
                new [] { 9, 6 },
                new [] { 9, 8 },
                new [] { 9, 9 },
                new [] { 10, 3 },
                new [] { 10, 5 },
                new [] { 10, 8 },
                new [] { 10, 10 }
            };

            generateChecker.MakeChangeAfterBeans(checker, beanPosition);

            var startPosition = new CheckPosition {
                Position = new[] { 4, 4 }
            };

            var runTheGame = new RunTheGame(new RandomProvider());

            runTheGame.StartMove(ref pacman, startPosition, checker, 0);

            Assert.IsTrue(pacman.Points[0] == 130);
        }
Example #15
0
 public PacmanDecorator(Pacman p)
 {
     _wrappee = p;
 }
Example #16
0
 private void InstantiatePacman()
 {
     player = (Pacman)Instantiate(pacmanPrefab, pacmanPrefab.startPosition, pacmanPrefab.gameObject.transform.rotation);
     player.gameController = this;
     Destroy(lifeSprites[lifes-1]);
     lifes--;
 }
Example #17
0
 public Chat(Pacman game) : this(game.Game, game.Player1, game.Players, game.Parameters)
 {
 }
Example #18
0
 public StopInvincibilityEvent(Pacman pacman)
 {
     this.pacman = pacman;
 }
Example #19
0
 public void PlayerMoveSpeed(Pacman pacman)
 {
     pacman.GetTimer().Interval = 200;
     pacman.GetStateTimer().Start();
 }
Example #20
0
        /// <summary>
        /// changes the game's state
        /// </summary>
        /// <param name="newMode"></param>
        private void SetMode(GameMode newMode)
        {
            turn   = 0;
            Status = newMode;
            switch (Status)
            {
            case GameMode.GAME_OVER:
                // copie le niveau dans le labyrinthe courant
                numLaby = 0;
                SetLabyrinth(numLaby);
                SleepTime = INITIAL_SLEEP_TIME;
                if (Timer != null && Timer.IsStarted)
                {
                    Timer.Stop();
                }
                //draw.drawGameOver();
                //drawScore();
                break;

            case GameMode.READY:
                // copie le niveau dans le labyrinthe courant
                DrawReady();
                // init du laby courant
                SetLabyrinth(numLaby);
                DrawLives();
                if (Timer == null)
                {
                    throw new Exception("You must provide a timer, fill 'Timer' property");
                }
                if (!Timer.IsStarted)
                {
                    Timer.Start();
                }
                break;

            case GameMode.PLAY:
                //draw.drawBack();
                if (PacMan == null)
                {
                    PacMan = new Pacman();
                }
                else
                {
                    PacMan.Init();
                }
                List <Ghost> tmpList = new List <Ghost>();
                CurrentBonus = null;
                for (int i = 0; i < FANTOME_COUNT; i++)
                {
                    tmpList.Add(new Ghost(FANTOME_FIRST + i));
                }
                Ghosts = tmpList;
                break;

            case GameMode.DEATH:
                Lives--;
                _FlyingScores.Clear();
                if (PacMan != null)
                {
                    PacMan.Dead();
                }
                break;
            }
        }
Example #21
0
 public void Initialize()
 {
     pacman = Instantiate(pacmanPrefab) as Pacman;
     pacman.Initialize(OnHit);
 }
Example #22
0
 public Simulator(Pacman pacman, Grid grid)
 {
     _pacman = pacman;
     _grid   = grid;
 }
Example #23
0
 private void PacmanGoDownCommand(object parameter)
 {
     Pacman.Direction = Direction.Left;
     Pacman.Step();
 }
Example #24
0
 public void PacmanHasInitialDirection(Pacman.Direction testDirection)
 {
     var pacman = new Pacman();
     pacman.Turn(testDirection);
     Assert.Equal(testDirection, pacman.GetDirection());
 }
Example #25
0
 private void Start()
 {
     _pacman = GameManager.singlton.pacman;
 }
Example #26
0
 public GhostPatrolling(Pacman pacman, Level level) : base(pacman, level)
 {
 }
 private void TimerEventProcessor(Object myObject, EventArgs myEventArgs, Pacman p, Food f)
 {
     Update();
 }
Example #28
0
 public void Setup()
 {
     _pacman = new Pacman();
     _grid   = new Grid(5, 5);
     _pacman.Place(_grid, 1, 1, Directions.Face.NORTH);
 }
Example #29
0
 public ActionResult Post([FromBody] Pacman p)
 {
     _pacmanContext.Pacmans.Add(p);
     return(Ok());
 }
Example #30
0
        public void IsPlaced_WhenNotPlaced_ShouldReturnFalse()
        {
            var pacman = new Pacman();

            Assert.Null(pacman.Grid);
        }
Example #31
0
 public PacmanLogAdapter(Pacman p)
 {
     _adaptee = p;
 }
Example #32
0
        public SymbolicConstant ASPMove()
        {
            //PRENDE LA POSIZIONE DEL PACMAN
            Vector3 currentPos  = new Vector3(Pacman.transform.position.x + 0.499f, Pacman.transform.position.y + 0.499f);
            var     currentTile = Tiles[manager.Index((int)currentPos.x, (int)currentPos.y)];

            //Debug.Log("PACMAN POS --> X:" + currentPos.x + " Y: " + currentPos.y + "\n\nTile --> X: " + currentTile.x + " Y: " + currentTile.y);

            //FIND ADJACENT TILES TO THE CURRENT ONE
            TileManager.Tile down  = currentTile.down;
            TileManager.Tile up    = currentTile.up;
            TileManager.Tile left  = currentTile.left;
            TileManager.Tile right = currentTile.right;

            InputProgram  facts       = new ASPInputProgram();
            StringBuilder disjunction = new StringBuilder();

            Pacman myPacman = new Pacman((int)currentPos.x, (int)currentPos.y);

            if (down != null)
            {
                if (disjunction.Length > 0)
                {
                    disjunction.Append("|");
                }
                disjunction.Append("next(down)");
            }

            if (left != null)
            {
                if (disjunction.Length > 0)
                {
                    disjunction.Append("|");
                }
                disjunction.Append("next(left)");
            }

            if (up != null)
            {
                if (disjunction.Length > 0)
                {
                    disjunction.Append("|");
                }
                disjunction.Append("next(up)");
            }

            if (right != null)
            {
                if (disjunction.Length > 0)
                {
                    disjunction.Append("|");
                }
                disjunction.Append("next(right)");
            }
            disjunction.Append(".");
            facts.AddProgram(disjunction.ToString());
            if (PreviousMove != null)
            {
                facts.AddProgram("previous_action(" + PreviousMove.Value + ").");
            }
            facts.AddObjectInput(myPacman);


            GameObject[] pacdots = GameObject.FindGameObjectsWithTag("pacdot");
            //Debug.Log("SIZE DOT: " + pacdots.Length);

            int count = 0;

            foreach (TileManager.Tile t in Tiles)
            {
                if (!t.occupied)
                {
                    count++;
                }
            }
            //Debug.Log("SIZE TILE: " + count);
            //GameObject[] energizer; // sono pacdot anche loro

            //energizer = GameObject.FindGameObjectsWithTag("energizer");

            //CHECK THE CONTENT OF A TILE
            //Debug.Log("PacDot[0].pos = (" + pacdots[0].transform.position.x + "," + pacdots[0].transform.position.y + ")");

            //for (int i = 0; i < 28; i++)
            //  for (int j = 0; j < 32; j++)
            //    foreach (Distance d in distances[i,j])
            //      facts.AddObjectInput(d);


            for (int i = -1; i <= 1; i++)
            {
                if (myPacman.getX() + i > 0 && myPacman.getX() + i < 28)
                {
                    if (GameManager.scared)
                    {
                        foreach (Distance d in distances_10[myPacman.getX() + i, myPacman.getY()])
                        {
                            facts.AddObjectInput(d);
                        }
                    }
                    else
                    {
                        foreach (Distance d in distances_5[myPacman.getX() + i, myPacman.getY()])
                        {
                            facts.AddObjectInput(d);
                        }
                    }
                }
                if (myPacman.getY() + i > 0 && myPacman.getY() + i < 32)
                {
                    if (GameManager.scared)
                    {
                        foreach (Distance d in distances_10[myPacman.getX(), myPacman.getY() + i])
                        {
                            facts.AddObjectInput(d);
                        }
                    }
                    else
                    {
                        foreach (Distance d in distances_5[myPacman.getX(), myPacman.getY() + i])
                        {
                            facts.AddObjectInput(d);
                        }
                    }
                }
            }

            if (GameManager.scared)
            {
                facts.AddProgram("powerup.");
            }


            foreach (GameObject p in pacdots)
            {
                facts.AddProgram("pellet(" + (int)p.transform.position.x + "," + (int)p.transform.position.y + ").");
            }

            facts.AddProgram("ghost(" + (int)blinky.transform.position.x + "," + (int)blinky.transform.position.y + ",blinky).");
            facts.AddProgram("ghost(" + (int)inky.transform.position.x + "," + (int)inky.transform.position.y + ",inky).");
            facts.AddProgram("ghost(" + (int)clyde.transform.position.x + "," + (int)clyde.transform.position.y + ",clyde).");
            facts.AddProgram("ghost(" + (int)pinky.transform.position.x + "," + (int)pinky.transform.position.y + ",pinky).");


            TileManager.Tile pacmanTile = new TileManager.Tile((int)Pacman.transform.position.x, (int)Pacman.transform.position.y);

            TileManager.Tile first_min = new TileManager.Tile((int)pacdots[0].transform.position.x, (int)pacdots[0].transform.position.y);
            var minDistance            = 10E6;// manager.distance(pacmanTile, first_min);



            foreach (GameObject p in pacdots)
            {
                TileManager.Tile pacdotsTile = new TileManager.Tile((int)p.transform.position.x, (int)p.transform.position.y);
                var myDistance = manager.distance(pacmanTile, pacdotsTile);
                if (myDistance < minDistance)
                {
                    minDistance = myDistance;
                    first_min   = pacdotsTile;
                }
            }

            facts.AddProgram("closestPellet(" + first_min.x + "," + first_min.y + ").");
            facts.AddProgram("distanceClosestPellet(" + (int)minDistance + ").");


            foreach (TileManager.Tile p in Tiles)
            {
                if (!p.occupied)
                {
                    facts.AddProgram("tile(" + p.x + "," + p.y + ").");
                }
            }

            SymbolicConstant move = GetNextMove(facts);

            PreviousMove = move;
            //Debug.Log("CurrentMove: " + move);
            return(move);
        }
Example #33
0
        /// <summary>
        /// changes the game's state
        /// </summary>
        /// <param name="newMode"></param>
        private void SetMode(GameMode newMode)
        {
            oturn = oturn + 10000;
            turn  = 0;
            GameMode oldStatus = Status;

            switch (newMode)
            {
            case GameMode.GAME_OVER_DEATH:
            case GameMode.GAME_OVER_ESC:
                if (newMode == GameMode.GAME_OVER_DEATH)
                {
                    cfg.playerCfg.scoreNo = cfg.scores.add(cfg.playerName, Score) + 1;
                }
                if (Audio != null)
                {
                    if (newMode == GameMode.GAME_OVER_DEATH)
                    {
                        Audio.PlayDeath();
                    }
                    Audio.MusicMenu();
                }
                numLaby = 0;
                SetLabyrinth(numLaby);
                if ((oldStatus == GameMode.PLAY) || (oldStatus == GameMode.DEATH))
                {
                    save();
                }
                SleepTime = Constants.INITIAL_SLEEP_TIME;
                if (Timer != null && Timer.IsStarted)
                {
                    Timer.Stop();
                }
                break;

            case GameMode.READY:
                if (Audio != null)
                {
                    Audio.PlayIntro();
                    Audio.MusicGame();
                }
                // copie le niveau dans le labyrinthe courant
                DrawReady();
                // init du laby courant
                SetLabyrinth(numLaby);
                DrawLives();
                if (Timer == null)
                {
                    throw new Exception("You must provide a timer, fill 'Timer' property");
                }
                if (!Timer.IsStarted)
                {
                    Timer.Start();
                }
                break;

            case GameMode.PLAY:
                //draw.drawBack();
                if (PacMan == null)
                {
                    PacMan = new Pacman();
                }
                else
                {
                    PacMan.Init();
                }
                //					taskBox.tskProvider.checkSpeed(-1);//init with default speed value
                List <Ghost> tmpList = new List <Ghost>();
                CurrentBonus = null;
                for (int i = 0; i < cfg.ghostCount; i++)
                {
                    tmpList.Add(new Ghost(FANTOME_FIRST + i));
                }
                Ghosts = tmpList;
                break;

            case GameMode.DEATH:
                Lives--;
                Audio.PlayKill();
                _FlyingScores.Clear();
                if (PacMan != null)
                {
                    PacMan.Dead();
                }
                break;
            }
            Status = newMode;
        }
Example #34
0
 private void InitPlayers()
 {
     this.enemeis = new HashSet <Enemy>(this.gameMap.InitEnemies());
     this.pacman  = this.gameMap.InitPacMan();
     this.fruit   = null;
 }
Example #35
0
        /// <summary>Processes every tick of the game base on directions of each entity passed in the array
        /// p should be passed 5 directions
        /// p[0] represents Pacman
        /// p[1] through p[4] represent ghosts in order passed </summary>
        public void UpdateGame(PacmanPacman.Direction p)
        {
            SpawnGhost();
            if (FruitSpawnCounter >= 450)
            {
                CurrentGameEvent.Add(new KeyValuePair <EventType, string>(EventType.FruitSpawn, Board.SpawnFruit().ToString()));
                FruitSpawnCounter = -1;
            }
            FruitSpawnCounter++;


            // Move ghosts
            for (int i = 0; i < Ghosts.Length; i++)
            {
                if (Ghosts[i].IsDead)
                {
                    continue;
                }
                ProcessGhostMove(i);
            }
            PacmanGhostCollide();

            // Move Pacman
            if (Pacman.Location.Xpos % 1 != 0)
            {
                if (p == PacmanPacman.Direction.left || p == PacmanPacman.Direction.right)
                {
                    Pacman.Facing = p;
                }
                Pacman.Move();
                CheckTile(Pacman.GetPosition());
            }
            else if (Pacman.Location.Ypos % 1 != 0)
            {
                if (p == PacmanPacman.Direction.up || p == PacmanPacman.Direction.down)
                {
                    Pacman.Facing = p;
                }
                Pacman.Move();
                CheckTile(Pacman.GetPosition());
            }
            else if (Pacman.Location.Xpos % 1 == 0 && Pacman.Location.Ypos % 1 == 0)
            {
                if (Board.ValidMove(p, Pacman.GetPosition()))
                {
                    Pacman.Facing = p;
                }
                if (Board.ValidMove(Pacman.Facing, Pacman.GetPosition()))
                {
                    Pacman.Move();
                    CheckTile(Pacman.GetPosition());
                }
            }
            PacmanGhostCollide();

            if (PoweredUpCounter == 0)
            {
                foreach (var g in Ghosts)
                {
                    g.IsVulnerable = false;
                }
                GhostScoreMultiplier = 1;
            }
            if (PoweredUpCounter > -1)
            {
                PoweredUpCounter--;
            }

            for (var i = 0; i < Ghosts.Length; i++)
            {
                CurrentGameEvent.Add(new KeyValuePair <EventType, string>(EventType.GhostUpdate, $"{i} {Ghosts[i].GetPosition().ToString()} {Ghosts[i].IsDead} {Ghosts[i].IsVulnerable}"));
            }
            CurrentGameEvent.Add(new KeyValuePair <EventType, string>(EventType.PacmanUpdate, $"{Pacman.GetPosition().ToString()}"));
        }
Example #36
0
        public void PacmanShouldDisplayCorrectlyGivenItsCurrentDirection(Direction direction, string display)
        {
            var pacman = new Pacman(0, 0, direction, new ConsoleOutput());

            Assert.Equal(display, pacman.Sprite);
        }
Example #37
0
 public Bot(string filename, Pacman game)
 {
     commands = System.IO.File.ReadAllLines(@filename);
     updateCurrentCommand();
     this.game = game ?? throw new ArgumentNullException(nameof(game));
 }
Example #38
0
    // Use this for initialization
    public void Start()
    {
        isFirstMove = true;
        currentMode = startMode;
        houseMode = startHouseMode;
        nextDirection = startDirection;
        anim = GetComponent<Animator>();

        UpdateTile();

        if (gameController == null)
        {
            GameObject Camera = GameObject.Find("Main Camera");
            gameController = Camera.GetComponent<GameController>();
        }

        if (player == null)
        {
            player = gameController.player;
        }

        //InitializePathFinder();
    }