Exemple #1
0
        public Level(Form form, LevelDecoder decoder)
        {
            Form                             = form;
            RendererPanel                    = new RendererPanel(Render);
            RendererPanel.Width              = 512;
            RendererPanel.Height             = 512;
            RendererPanel.Location           = new Point(0, 0);
            Player                           = new Player(RendererPanel, this, RendererPanel.Width / 32, RendererPanel.Height / 32);
            Pinky                            = new Pinky(RendererPanel, this, RendererPanel.Width / 32, RendererPanel.Height / 32);
            Inky                             = new Inky(RendererPanel, this, RendererPanel.Width / 32, RendererPanel.Height / 32);
            Blinky                           = new Blinky(RendererPanel, this, RendererPanel.Width / 32, RendererPanel.Height / 32);
            Clyde                            = new Clyde(RendererPanel, this, RendererPanel.Width / 32, RendererPanel.Height / 32);
            RendererPanel.PlayerRenderAction = Player.Render;
            RendererPanel.PinkyRenderAction  = Pinky.Render;
            RendererPanel.InkyRenderAction   = Inky.Render;
            RendererPanel.BlinkyRenderAction = Blinky.Render;
            RendererPanel.ClydeRenderAction  = Clyde.Render;
            RendererPanel.DoRender();
            form.Controls.Add(RendererPanel);
            KeyInputHandler = new KeyInputHandler(form, true, ThreadingMode.None);
            EventKeyInput eventKeyInput = new EventKeyInput();

            eventKeyInput.KeyInput += EventKeyInput_KeyInput;
            KeyInputHandler.RegisterKeyInput(eventKeyInput);
            KeyInputHandler.Start();
            form.FormClosing += Form_FormClosing;
            Grid              = decoder.DecodeLevel();
            Player.Spawn(16, 16);
            Pinky.Spawn(32, 80);
            Inky.Spawn(48, 80);
            Blinky.Spawn(64, 80);
            Clyde.Spawn(80, 80);
        }
 public GameEngine(Blinky blinky, Clyde clyde, Inky inky, Pinky pinky)
 {
     ghosts.Add(blinky);
     ghosts.Add(clyde);
     ghosts.Add(inky);
     ghosts.Add(pinky);
 }
Exemple #3
0
    public virtual void Restart()
    {
        isCanMove = true;
        SetDifficultyForStage(GameManager.stage);

        nowMode = Mode.Scatter;

        moveSpeed = normalMoveSpeed;
        oldMode   = 0;


        ghostReleaseTimer = 0;
        modeChangeNum     = 1;
        modeChangeTimer   = 0;
        animator.SetBool("Frightened", false);
        animator.SetBool("Blink", false);
        animator.SetBool("Eaten", false);
        animator.enabled = true;

        Blinky tempBlinky = GetComponent <Blinky>();

        if (tempBlinky == null)
        {
            isInGhostHouse = true;
        }

        nowWayPoint = startWayPoint;
    }
Exemple #4
0
 // Start is called before the first frame update
 void Start()
 {
     state         = GhostState.Disabled;
     directionFrom = DirectionsFromWhichTheGhostCame.noDirection;
     Player        = GameObject.FindGameObjectWithTag("Player").GetComponent <PackManPlayer>();
     blinky        = GameObject.FindGameObjectWithTag("Blinky").GetComponent <Blinky>();
     GetOptimalPathOutOfGivenFour(GetDestination());
 }
Exemple #5
0
 public Collision(Pinky pinky, Blinky blinky, Inky inky, Clyde clyde, IPacMan pacMan, GUI gui)
 {
     this.gui = gui;
     pacman   = pacMan;
     ghosts.Add(pinky);
     ghosts.Add(inky);
     ghosts.Add(blinky);
     ghosts.Add(clyde);
 }
Exemple #6
0
        public static BaseGameObject CreateOGameObject(PointData point)
        {
            BaseGameObject res = null;

            switch (point.InitData)
            {
            case InitialData.Pacman:
                res = new Pacman();
                res.Animation.Location = point.Crdnt;
                res.Name = InitialData.Pacman.ToString();

                break;

            case InitialData.Blinky:
                res = new Blinky();
                res.Animation.Location = point.Crdnt;
                res.Name = InitialData.Blinky.ToString();
                break;

            /*case InitialData.Inky:
             *  res = new Inky();
             *  res.Animation.Location = point.Crdnt;
             *  res.Name = InitialData.Inky.ToString();
             *  break;
             *
             * case InitialData.Pinky:
             *  res = new Pinky();
             *  res.Animation.Location = point.Crdnt;
             *  res.Name = InitialData.Pinky.ToString();
             *  break;
             *
             * case InitialData.Clyde:
             *  res = new Clyde();
             *  res.Animation.Location = point.Crdnt;
             *  res.Name = InitialData.Clyde.ToString();
             *  break;*/

            case InitialData.BigCoin:
                res = new BigCoin();
                res.Animation.Location = point.Crdnt;
                res.Name = InitialData.BigCoin.ToString();
                break;

            case InitialData.SmallCoin:
                res = new SmallCoin();
                res.Animation.Location = point.Crdnt;
                res.Name = InitialData.SmallCoin.ToString();
                break;
            }

            return(res);
        }
Exemple #7
0
 public Game(string Id)
 {
     ID         = Id;
     map        = new Maze();
     pacMan     = new PacMan(map, new Position(13, 17));
     blinky     = new Blinky(pacMan, map, new Position(10, 11));
     pinky      = new Pinky(pacMan, map, new Position(11, 14));
     gui        = new GUI(map);
     clyde      = new Clyde(pacMan, map, new Position(11, 15));
     inky       = new Inky(pacMan, map, new Position(12, 15));
     collision  = new Collision(pinky, blinky, inky, clyde, pacMan, gui);
     gameEngine = new GameEngine(blinky, clyde, inky, pinky);
 }
Exemple #8
0
        public void TestCalculateTargetCell1()
        {
            Game   game   = new Game();
            Inky   inky   = (Inky)game.Ghosts[2];
            Blinky blinky = (Blinky)game.Ghosts[0];

            blinky.SetX(10);
            blinky.SetY(16);

            Cell cell = inky.CalculateTargetCell();

            Assert.AreEqual(cell, game.Level.Map[27, 30]);
        }
Exemple #9
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        player        = FindObjectOfType <Pacman>();
        blinky        = FindObjectOfType <Blinky>();
        scatterTarget = new Vector2(13.5f, -2.5f);

        speed       = 2.5f;
        normalSpeed = speed;

        waiting  = true;
        spawning = false;
    }
Exemple #10
0
        public void SetupBoard(TileInfo[][] boardTiles, Vector pacmanPosition, Vector positionInFrontOfPrision, Vector positionInsideOfPrision)
        {
            this.pacmanPosition           = pacmanPosition;
            this.positionInFrontOfPrision = positionInFrontOfPrision;
            this.positionInsideOfPrision  = positionInsideOfPrision;

            Board  = new Board(boardTiles, positionInFrontOfPrision, positionInsideOfPrision);
            Pacman = new Pacman(pacmanPosition, Board);
            Blinky = new Blinky(positionInFrontOfPrision, Board);
            Pinky  = new Pinky(positionInsideOfPrision, Board);
            Inky   = new Inky((positionInsideOfPrision + (Vector.LEFT * 2)), Board);
            Clyde  = new Clyde((positionInsideOfPrision + (Vector.RIGHT * 2)), Board);
            XpItem = new XpItem(positionInFrontOfPrision, Board);
        }
Exemple #11
0
        public void TestCalculateTargetCell6()
        {
            Game   game   = new Game();
            Inky   inky   = (Inky)game.Ghosts[2];
            Blinky blinky = (Blinky)game.Ghosts[0];

            blinky.SetX(25);
            blinky.SetY(16);
            game.Player.Direction = Direction.Right;

            Cell cell = inky.CalculateTargetCell();

            Assert.AreEqual(cell, game.Level.Map[12, 30]);
        }
        public MainPage()
        {
            this.InitializeComponent();
            _blinky = new Blinky();
            _dht = new DhtSensor();
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                _honorQuietTime = false;
                _checkInterval = TimeSpan.FromSeconds(5);
                _announceInterval = TimeSpan.FromMinutes(15);
                //_useTubes = false;
            }
#endif
        }
 void Start()
 {
     Application.targetFrameRate = 60;
     map           = Map.instance;
     canvasManager = UI_CanvasManager.instance;
     SerializeSystem.LoadGame(scoreData);
     points = (uint)scoreData.currentScore;
     canvasManager.UpdateScore(points);
     canvasManager.UpdateHighScore((uint)scoreData.highScore);
     player     = FindObjectOfType <PaxMan>();
     blinky     = FindObjectOfType <Blinky>();
     ghosts     = FindObjectsOfType <Ghost>();
     gameOver   = false;
     initedGame = false;
     InitGame();
 }
Exemple #14
0
        public void TestUpdateChasePath2()
        {
            Game   game   = new Game();
            Blinky blinky = (Blinky)game.Ghosts[0];
            Player pacman = game.Player;

            pacman.IsPassedLeftTunnel = true;

            blinky.UpdateChasePath();

            IPathfindingAlgorithm algorithm = new AStarAlgorithm();
            List <Cell>           path      = algorithm.CalculatePath(blinky.CurrentCell(), game.Level.Map[0, 15], game.Level.Map);

            Assert.AreEqual(blinky.TargetCell, game.Level.Map[32, 15]);
            Assert.IsFalse(pacman.IsPassedLeftTunnel);
            CollectionAssert.AreEqual(blinky.ChasePath, path);
        }
Exemple #15
0
        public void InitiateGame()
        {
            processColision = false;
            GameOver        = false;
            Pacman.Start(pacmanPosition);

            Blinky.Start(positionInFrontOfPrision);
            Pinky.Start(positionInsideOfPrision);
            Inky.Start(positionInsideOfPrision + Vector.LEFT * 2);
            Clyde.Start(positionInsideOfPrision + Vector.RIGHT * 2);


            WaitAndCall((int)TIME_TO_RELEASE_GHOSTS * 1000, Pinky.Unlock);
            WaitAndCall((int)TIME_TO_RELEASE_GHOSTS * 1000 * 2, Inky.Unlock);
            WaitAndCall((int)TIME_TO_RELEASE_GHOSTS * 1000 * 3, Clyde.Unlock);


            WaitAndCall((int)TIME_TO_DROP_XP_ITEM * 1000, DropXpItem);
        }
Exemple #16
0
        /// <summary>
        /// Create a new instance of the game by initilizing all game components
        /// </summary>
        public void NewGame()
        {
            // Clear the list of all game components
            this.Components.Clear();

            // Stop all musics
            SoundManager.Instance.StopMusic();
            SoundManager.Instance.StopInvincible();

            // Create new instances of game components
            menu   = new Menu(this, pacDied ? MenuType.GAMEOVER : MenuType.START);
            maze   = new Maze(this);
            blinky = new Blinky(this);
            pinky  = new Pinky(this);
            inky   = new Inky(this);
            clyde  = new Clyde(this);

            pac = new Pac(this, maze);

            // If there was a previous level before this new game, do not reset pac's life
            if (lastPacLife > 0)
            {
                pac.Life = lastPacLife;
            }

            // (Re)-initialize GhostManager
            GhostManager.Instance.Initialize(maze, pac, blinky, new Ghost[] { pinky, inky, clyde });

            // Initialize all game components
            menu.Initialize();
            maze.Initialize();
            blinky.Initialize();
            pinky.Initialize();
            inky.Initialize();
            clyde.Initialize();
            pac.Initialize();

            // Reset pacDied attribute
            pacDied = false;
        }
Exemple #17
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            GraphicsDevice.DepthStencilState = new DepthStencilState();
            GraphicsDevice.Clear(background);

            if (currentScene == scenes["Play"])
            {
                foreach (Camera camera in cameras)
                {
                    effect.Parameters["NormalMap"].SetValue(terrain.NormalMap);
                    effect.Parameters["World"].SetValue(terrain.Transform.World);
                    effect.Parameters["View"].SetValue(camera.View);
                    effect.Parameters["Projection"].SetValue(camera.Projection);
                    effect.Parameters["CameraPosition"].SetValue(camera.Transform.Position);
                    effect.Parameters["LightPosition"].SetValue(light.Transform.Position);
                    foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                    {
                        pass.Apply();
                        terrain.Draw();
                    }

                    pacman.Draw();
                    Inky.Draw();
                    Blinky.Draw();
                    Pinky.Draw();
                    Clyde.Draw();
                    powerUp.Draw();
                }
                spriteBatch.Begin();
                spriteBatch.DrawString(font, "# of Hits: " + hits, new Vector2(100, 50), Color.White);
                spriteBatch.DrawString(font, "Time left: " + Time.TotalGameTime, new Vector2(100, 70), Color.White);
                spriteBatch.DrawString(font, "WASD to move", new Vector2(100, 90), Color.White);
                spriteBatch.End();
            }
            currentScene.Draw();

            base.Draw(gameTime);
        }
Exemple #18
0
 void ConfigureGhosts()
 {
     GameObject[] blinkyGameObjects = GameObject.FindGameObjectsWithTag("Blinky");
     foreach (GameObject blinkyGameObject in blinkyGameObjects)
     {
         Blinky blinky = blinkyGameObject.GetComponent <Blinky>();
         blinky.timeFrightened = Settings.ghostTimeFrightened;
     }
     GameObject[] inkyGameObjects = GameObject.FindGameObjectsWithTag("Inky");
     foreach (GameObject inkyGameObject in inkyGameObjects)
     {
         Inky inky = inkyGameObject.GetComponent <Inky>();
         inky.moveSpeed      = Settings.ghostMoveSpeed;
         inky.timeFrightened = Settings.ghostTimeFrightened;
     }
     GameObject[] pinkyGameObjects = GameObject.FindGameObjectsWithTag("Pinky");
     foreach (GameObject pinkyGameObject in pinkyGameObjects)
     {
         Pinky pinky = pinkyGameObject.GetComponent <Pinky>();
         pinky.moveSpeed      = Settings.ghostMoveSpeed;
         pinky.timeFrightened = Settings.ghostTimeFrightened;
     }
 }
Exemple #19
0
    void InstantiateCell(char value, int x, int y)
    {
        GameObject cellToInstantiate = null;
        CellType?  instantiatedType  = null;
        GameObject instantiatedBox   = null;

        switch (value)
        {
        case '.':
        {
            cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            instantiatedType  = CellType.Floor;
            break;
        }

        case 'g':
        {
            cellToInstantiate = Instantiate(Gate, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            Gate     = cellToInstantiate;
            EyesCell = new Cell {
                XCoordinate = y, YCoordinate = x - 1
            };
            instantiatedType = CellType.Gate;
            break;
        }

        case 'w':
        {
            cellToInstantiate = Instantiate(Wall, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            instantiatedType  = CellType.Wall;
            break;
        }

        case 'b':
        {
            cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);

            blinky           = Instantiate(blinky, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            instantiatedType = CellType.Floor;
            mapData[y, x]    = new Cell {
                Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x
            };
            blinky.currentCell = mapData[y, x];
            break;
        }

        case 'p':
        {
            cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            instantiatedType  = CellType.Floor;
            pinky             = Instantiate(pinky, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            mapData[y, x]     = new Cell {
                Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x
            };
            pinky.currentCell = mapData[y, x];
            break;
        }

        case 'i':
        {
            cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            instantiatedType  = CellType.Floor;
            inky          = Instantiate(inky, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            mapData[y, x] = new Cell {
                Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x
            };
            inky.currentCell = mapData[y, x];
            break;
        }

        case 'c':
        {
            cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            instantiatedType  = CellType.Floor;
            clyde             = Instantiate(clyde, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            mapData[y, x]     = new Cell {
                Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x
            };
            clyde.currentCell = mapData[y, x];
            break;
        }

        case 'P':
        {
            cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity, SuperParentContainer.transform);
            var playerGameobject = Instantiate(Player, new Vector3(1 * x, 0, 1 * y), Quaternion.identity);
            mainPlayer               = playerGameobject.GetComponent <PackManPlayer>();
            instantiatedType         = CellType.Floor;
            mainPlayer.ScoreText     = ScoreText;
            mainPlayer.RestartButton = RestartButton;
            mainPlayer.DeadText      = YouAreDead;
            mapData[y, x]            = new Cell {
                Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x
            };
            mainPlayer.CellPosition = mapData[y, x];
            Debug.Log(mainPlayer.CellPosition);
            break;
        }

        default:
        {
            Debug.Log("Can't instantiate");
            break;
        }
        }
        mapData[y, x] = new Cell {
            Item = instantiatedBox, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x
        };
        cellToInstantiate.transform.SetParent(SuperParentContainer.transform);
    }
Exemple #20
0
        public void move_Ghosts()
        {
            Blinky.find_target(ai_state);
            Pinky.find_target(ai_state);
            Inky.find_target(ai_state);
            Clyde.find_target(ai_state);

            //from one side to the other***********************************************************************
            //*************************************BLINKY******************************************************
            if (Blinky.x == 0 && Blinky.y == 17 && Blinky.direction == 0)
            {
                Blinky.x = 28;
            }
            if (Blinky.x == 27 && Blinky.y == 17 && Blinky.direction == 2)
            {
                Blinky.x = 0;
            }

            if (Map.intersections[Blinky.x, Blinky.y])
            {
                Blinky.direction = check_intersections(Blinky.x, Blinky.y, Blinky.target_x, Blinky.target_y, Blinky.direction);
            }
            else
            {
                Blinky.direction = check_walls(Blinky.x, Blinky.y, Blinky.target_x, Blinky.target_y, Blinky.direction);
            }


            /***********************************************************************************************
             * *******************************PINKY***************************************************/
            if (Pinky.x == 0 && Pinky.y == 17 && Pinky.direction == 0)
            {
                Pinky.x = 28;
            }
            if (Pinky.x == 27 && Pinky.y == 17 && Pinky.direction == 2)
            {
                Pinky.x = 0;
            }

            if (Map.intersections[Pinky.x, Pinky.y])
            {
                Pinky.direction = check_intersections(Pinky.x, Pinky.y, Pinky.target_x, Pinky.target_y, Pinky.direction);
            }
            else
            {
                Pinky.direction = check_walls(Pinky.x, Pinky.y, Pinky.target_x, Pinky.target_y, Pinky.direction);
            }

            //from one side to the other***********************************************************************
            //*************************************INKY******************************************************
            if (Inky.x == 0 && Inky.y == 17 && Inky.direction == 0)
            {
                Inky.x = 28;
            }
            if (Inky.x == 27 && Inky.y == 17 && Inky.direction == 2)
            {
                Inky.x = 0;
            }

            if (Map.intersections[Inky.x, Inky.y])
            {
                Inky.direction = check_intersections(Inky.x, Inky.y, Inky.target_x, Inky.target_y, Inky.direction);
            }
            else
            {
                Inky.direction = check_walls(Inky.x, Inky.y, Inky.target_x, Inky.target_y, Inky.direction);
            }


            //from one side to the other***********************************************************************
            //*************************************CLYDE******************************************************
            if (Clyde.x == 0 && Clyde.y == 17 && Clyde.direction == 0)
            {
                Clyde.x = 28;
            }
            if (Clyde.x == 27 && Clyde.y == 17 && Clyde.direction == 2)
            {
                Clyde.x = 0;
            }

            if (Map.intersections[Clyde.x, Clyde.y])
            {
                Clyde.direction = check_intersections(Clyde.x, Clyde.y, Clyde.target_x, Clyde.target_y, Clyde.direction);
            }
            else
            {
                Clyde.direction = check_walls(Clyde.x, Clyde.y, Clyde.target_x, Clyde.target_y, Clyde.direction);
            }

            Blinky.move(Blinky.direction);
            Pinky.move(Pinky.direction);
            Inky.move(Inky.direction);
            Clyde.move(Clyde.direction);
        }
 //EnterState Start timer for scatter state and find the blinky ghost if it exists
 public override void EnterState(FSMAgent agent)
 {
     agent.SetTimer(20f);
     blinky = GameObject.FindObjectOfType <Blinky>();
 }
Exemple #22
0
    void Update()
    {
        playerController.Run();
        if (delay <= 0) {
            if (rowNum < levelRows.Length) {
                string levelRow = levelRows[rowNum];
                rowNum++;
                string[] enemyIds = levelRow.Split(',');
                for (int i = 0; i < enemyIds.Length; i++) {
                    DbItem enemyItem = null;
                    EnemyBehaviour enemy = null;
                    string enemyId = enemyIds[i];
                    string movementId = null;
                    if (enemyIds[i].Contains(":")) {
                        enemyId = enemyIds[i].Split(':')[0];
                        movementId = enemyIds[i].Split(':')[1];
                        //enemyId = enemyIds[i].Substring(0, enemyIds[i].IndexOf(':'));
                        //movementId = enemyIds[i].Substring(enemyIds[i].IndexOf(':') + 1);
                    }
                    switch (enemyId) {
                        case "0":
                            break;
                        case "1": {
                                enemyItem = ItemDatabase.GetItemByFileId("0");
                                enemy = new Blinky();
                                enemy.SetHealth(3);
                                break;
                            }
                        case "2": {
                                enemyItem = ItemDatabase.GetItemByFileId("1");
                                enemy = new Skrull();
                                enemy.SetHealth(5);
                                break;
                            }
                        case "3": {
                                enemyItem = ItemDatabase.GetItemByFileId("2");
                                enemy = new RedReaper();
                                enemy.SetHealth(5);
                                break;
                            }
                        case "4": {
                                enemyItem = ItemDatabase.GetItemByFileId("6");
                                enemy = new Striker();
                                enemy.SetHealth(8);
                                enemy.SetExplosionFX(ItemDatabase.GetItemByName("ExplosionOrange").gameModel);
                                break;
                            }
                        default:
                            Debug.Log("Unknown Item ID: " + enemyIds[i]);
                            break;
                    }
                    if (enemy != null && enemyItem != null) {
                        enemy.SetModel((GameObject)GameObject.Instantiate(enemyItem.gameModel, new Vector3((screenWidth * (float)i) / 8f - screenWidth / 2f + screenWidth / 16f, screenHeight + 2f), enemyItem.gameModel.transform.rotation));
                        enemy.GetModel().GetComponent<CollisionController>().SetObject(enemy);
                        //print("EnemyObject: " + enemy);
                        if (movementId != null) {
                            //print("MoveId: " + movementId);
                            EnemyMovement movement = null;
                            switch (movementId) {
                                case "0":
                                    break;
                                case "1":
                                    {
                                        movement = new MoveDown();
                                        movement.SetEnemy(enemy.GetModel());
                                        //enemy.SetMovement(movement);
                                        //enemyObject.AddComponent<MoveDown>();
                                        break;
                                    }
                                case "2":
                                    {
                                        //MoveRightAngle moveRightAngle = new MoveRightAngle();
                                        movement = new MoveRightAngle();
                                        movement.SetEnemy(enemy.GetModel());
                                        //moveRightAngle.SetScreenDimensions(GetScreenWidth(), GetScreenHeight());
                                        //movement = moveRightAngle;
                                        //enemy.SetMovement(movement);
                                        //enemyObject.AddComponent<MoveRightAngle>();
                                        break;
                                    }
                                case "3":
                                    {
                                        movement = new MoveLeftAngle();
                                        movement.SetEnemy(enemy.GetModel());

                                        //MoveLeftAngle moveLeftAngle = new MoveLeftAngle();
                                        //EnemyMovement movement = moveLeftAngle;
                                        //movement.SetEnemy(enemy.GetModel());
                                        //moveLeftAngle.SetScreenDimensions(GetScreenWidth(), GetScreenHeight());
                                        //movement = moveLeftAngle;
                                        //enemy.SetMovement(movement);

                                        //enemyObject.AddComponent<MoveLeftAngle>();
                                        break;
                                    }
                                default:
                                    Debug.Log("Unkown Movement ID: " + movementId);
                                    break;
                            }
                            if (movement is ScreenAware) {
                                ((ScreenAware)movement).SetScreenDimensions(GetScreenWidth(), GetScreenHeight());
                            }
                            enemy.SetMovement(movement);
                        }
                    }
                    if (enemy != null) {
                        //GameObject enemyModel = enemyItem.gameModel;
                        //GameObject enemyObject = Instantiate(enemyModel, new Vector3((screenWidth * (float)i) / 8f - screenWidth / 2f + screenWidth / 16f, screenHeight + 2f), enemyModel.transform.rotation) as GameObject;

                        //enemyObject = Instantiate(enemyModel, new Vector3((screenWidth * (float)i) / 8f - screenWidth / 2f + screenWidth / 16f, screenHeight + 2f), enemyModel.transform.rotation) as GameObject;
                        //enemyObject.GetComponent<EnemyBehaviour>().SetHealth(enemyItem.health);
                        //enemyObject.GetComponent<EnemyBehaviour>().SetMovement(movement);

                        //enemyObject.AddComponent<MoveDown>();

                        //spawnedObjects.Add(enemy);
                        GarbageCollector.AddGameObject(enemy);
                    }
                }
            }
            delay = spawnDelay * Time.deltaTime;
        } else {
            delay -= Time.deltaTime;
        }

        //List<EnemyBehaviour> markedObjects = new List<EnemyBehaviour>();
        List<ObjectModel> om = GarbageCollector.GetObjects();
        foreach (ObjectModel o in om) {
            if (o is EnemyBehaviour) {
                ((EnemyBehaviour)o).Move(2.5f);
            }
        }
        List<GameObject> markedItems = new List<GameObject>();
        foreach (KeyValuePair<GameObject, Vector3> item in SpawnItem.GetItems()) {
            GameObject spawnedItem = (GameObject)Instantiate(item.Key, item.Value, Quaternion.identity);
            markedItems.Add(item.Key);
        }
        foreach (GameObject g in markedItems) {
            SpawnItem.RemoveItem(g);
        }

        GarbageCollector.Clean();
    }
 private void AjouterBlinky()
 {
     Blinky.MettreAJourCoordonnée(Grille.TrouverCoordonnéeCase(14, 11));
     m_listeFantômesActifs.Add(Blinky);
     m_ia.RéinitialiserBlinky();
 }
Exemple #24
0
 //Metodo  virtual:
 //Un metodo virtual se puede sobrecargar, como los
 //metodos abstractos
 //pero a direferncia de lo abstractos, este debe tener
 //implementacion en la clase padre.
 public virtual void Start()
 {
     blinky = GetComponent <CompBlinky>().b;
 }
Exemple #25
0
 private void STVarChanged(Topic snd, TopicChanged p) {
   if(p.Visited(_owner, true)) {
     return;
   }
   for(int i=_drivers.Count-1; i>=0; i--) {
     if(_drivers[i].VarChanged(snd, p.Art==TopicChanged.ChangeArt.Remove)) {
       if(p.Art==TopicChanged.ChangeArt.Remove) {
         lock(_drivers) {
           _drivers.RemoveAt(i);
         }
       }
       return;
     }
   }
   if(p.Art==TopicChanged.ChangeArt.Remove) {
     return;
   }
   TWICommon drv=null;
   switch(snd.name) {
   case "LM75_T0":
   case "LM75_T1":
   case "LM75_T2":
   case "LM75_T3":
     drv=new LM75(snd);
     break;
   case "CC2D_T":
   case "CC2D_H":
     drv=new CC2D(snd);
     break;
   case "HIH61_T":
   case "HIH61_H":
     drv=new HIH61xx(snd);
     break;
   case "SI7020_T":
   case "SI7020_H":
     drv=new SI7020(snd);
     break;
   case "BMP180_T":
   case "BMP180_P":
     drv=new BMP180(snd);
     break;
   case "BME280_T":
   case "BME280_P":
   case "BME280_H":
     drv=new BME280(snd);
     break;
   case "BLINKM_8":
   case "BLINKM_9":
   case "BLINKM_10":
     drv=new Blinky(snd);
     break;
   case "BH1750_0":
   case "BH1750_1":
     drv=new BH1750(snd);
     break;
   case "EXP_0":
   case "EXP_1":
   case "EXP_2":
   case "EXP_3":
   case "EXP_4":
   case "EXP_5":
   case "EXP_6":
   case "EXP_7":
     drv=new Expander(snd);
     break;
   //case "SI1143":
   //  drv=new SI1143(snd);
   //  break;
   default:
     if(snd.name.Length>2 && snd.name.Length<6 && (snd.name.StartsWith("Sa") || snd.name.StartsWith("Ra"))) {
       drv=new RawDevice(snd);
     }
     break;
   }
   if(drv!=null) {
     lock(_drivers) {
       for(int i=_drivers.Count-1; i>=0; i--) {
         if(_drivers[i].VarChanged(snd, false)) {
           drv=null;
           break;
         }
       }
       if(drv!=null) {
         _drivers.Add(drv);
       }
     }
   }
 }
Exemple #26
0
    void Init(bool reset)
    {
        lives = pacMan.GetComponent <Controller>().life;
        if (reset)
        {
            for (int i = 0; i < ghosts.Length; i++)
            {
                if (ghosts[i].GetComponent <Pinky>() != null)
                {
                    Pinky pinky = ghosts[i].GetComponent <Pinky>();
                    pinky.resetLevel  = true;
                    pinky.currentNode = null;
                    ghosts[i].GetComponent <Pinky>().Init(ghostSpeed, ghostFrightSpeed, ghostTunnelSpeed, frightDuration);
                }
                else if (ghosts[i].GetComponent <Blinky>() != null)
                {
                    Blinky blinky = ghosts[i].GetComponent <Blinky>();
                    blinky.currentNode = null;
                    blinky.resetLevel  = true;
                    blinky.Init(ghostSpeed, ghostFrightSpeed, ghostTunnelSpeed, frightDuration);
                }
                else if (ghosts[i].GetComponent <Inky>() != null)
                {
                    Inky inky = ghosts[i].GetComponent <Inky>();
                    inky.currentNode = null;
                    inky.resetLevel  = true;
                    inky.Init(ghostSpeed, ghostFrightSpeed, ghostTunnelSpeed, frightDuration);
                }
                else if (ghosts[i].GetComponent <Clyde>() != null)
                {
                    Clyde clyde = ghosts[i].GetComponent <Clyde>();
                    clyde.resetLevel  = true;
                    clyde.currentNode = null;
                    clyde.Init(ghostSpeed, ghostFrightSpeed, ghostTunnelSpeed, frightDuration);
                }
            }
        }
        else
        {
            for (int i = 0; i < ghosts.Length; i++)
            {
                if (ghosts[i].GetComponent <Pinky>() != null)
                {
                    Pinky pinky = ghosts[i].GetComponent <Pinky>();
                    pinky.resetLevel = false;
                    ghosts[i].GetComponent <Pinky>().Init(ghostSpeed, ghostFrightSpeed, ghostTunnelSpeed, frightDuration);
                }
                else if (ghosts[i].GetComponent <Blinky>() != null)
                {
                    Blinky blinky = ghosts[i].GetComponent <Blinky>();
                    blinky.resetLevel = false;
                    blinky.Init(ghostSpeed, ghostFrightSpeed, ghostTunnelSpeed, frightDuration);
                }
                else if (ghosts[i].GetComponent <Inky>() != null)
                {
                    Inky inky = ghosts[i].GetComponent <Inky>();
                    inky.resetLevel = false;
                    inky.release    = inkyReleaseCounter;
                    inky.Init(ghostSpeed, ghostFrightSpeed, ghostTunnelSpeed, frightDuration);
                }
                else if (ghosts[i].GetComponent <Clyde>() != null)
                {
                    Clyde clyde = ghosts[i].GetComponent <Clyde>();
                    clyde.resetLevel = false;
                    clyde.release    = clydeReleaseCounter;
                    clyde.Init(ghostSpeed, ghostFrightSpeed, ghostTunnelSpeed, frightDuration);
                }
            }

            foreach (GameObject o in objects)
            {
                if (!pacManLost)
                {
                    if (o.tag == "Pellets" || o.tag == "PelletsInner" || o.tag == "PelletsSpecial")
                    {
                        Tile tile = o.GetComponent <Tile>();
                        if (tile != null)
                        {
                            if (tile.isPellet || tile.isSuperPellet)
                            {
                                tile.GetComponent <SpriteRenderer>().enabled = true;
                                tile.isConsumed = false;
                            }
                        }
                    }
                }
            }
        }

        pacMan.Init(pacManSpeed, frightPacManSpeed, pacManDotsSpeed, frightDuration);
    }
Exemple #27
0
    public void ParseLevel()
    {
        foreach (var go in m_objects)
        {
            Destroy(go);
        }

        m_objects   = new List <GameObject>();
        m_text.text = string.Empty;

        string path = m_input.text;

        if (!path.EndsWith(".pac"))
        {
            path = path + ".pac";
        }
        m_input.text = path;

        path = Path.Combine(@"Assets\levels", path);

        if (!File.Exists(path))
        {
            m_text.text += "file not available!" + Environment.NewLine;
            return;
        }

        Tile[,] tiles = new Tile[0, 0];
        //int[] characterPositions = new int[10];
        List <Vector3> charpos;

        m_text.text += "parsing started:" + Environment.NewLine;
        string level, figures;

        if (Parser.IsValidLevel(path, out level, out figures, ref m_text))
        {
            m_text.text += Environment.NewLine + "start building" + Environment.NewLine;
            tiles        = Parser.ParseValidLevel(level, ref m_text);

            //characterPositions = Parser.getCharacterPositions(figures);

            charpos      = Parser.GetCharPositions();
            m_text.text += " got positions" + Environment.NewLine;

            m_text.text += level + Environment.NewLine;
        }
        else
        {
            m_input.text = "level structure not valid" + Environment.NewLine;
            return;
        }

        GameObject[,] objs = new GameObject[tiles.GetLength(0), tiles.GetLength(1)];


        // build prefabs
        for (int r = 0; r < tiles.GetLength(0); r++)
        {
            for (int c = 0; c < tiles.GetLength(1); c++)
            {
                Vector3    pos = new Vector3(c, 0f, -r);
                Quaternion rot = Quaternion.Euler(0f, tiles[r, c].Rotation, 0f);

                GameObject go = null;
                #region switch
                switch (tiles[r, c].Type)
                {
                case Tile.Element.Block:
                    go = Block;
                    break;

                case Tile.Element.Corner:
                    go = Corner;
                    break;

                case Tile.Element.Corridor:
                    go = Corridor;
                    break;

                case Tile.Element.Cross:
                    go = Cross;
                    break;

                case Tile.Element.Deadend:
                    go = DeadEnd;
                    break;

                case Tile.Element.TCross:
                    go = TCross;
                    break;

                default:
                    break;
                }
                #endregion

                var inst = Instantiate(go, pos, rot);
                m_objects.Add(inst);
                objs[r, c] = inst;
            }
        }

        m_text.text += "level building finished w/success" + Environment.NewLine;

        for (int r = 0; r < tiles.GetLength(0); r++)
        {
            for (int c = 0; c < tiles.GetLength(1); c++)
            {
                if (tiles[r, c].ltrb_open[0])
                {
                    objs[r, c].GetComponent <WayPoint>().leftWaypoint = objs[r, c - 1].GetComponent <WayPoint>();
                }

                if (tiles[r, c].ltrb_open[1])
                {
                    objs[r, c].GetComponent <WayPoint>().upWaypoint = objs[r - 1, c].GetComponent <WayPoint>();
                }

                if (tiles[r, c].ltrb_open[2])
                {
                    objs[r, c].GetComponent <WayPoint>().rightWaypoint = objs[r, c + 1].GetComponent <WayPoint>();
                }

                if (tiles[r, c].ltrb_open[3])
                {
                    objs[r, c].GetComponent <WayPoint>().downWaypoint = objs[r + 1, c].GetComponent <WayPoint>();
                }
            }
        }
        m_text.text += "added waypoints to GameObjects" + Environment.NewLine;

        for (int i = 0; i < charpos.Count; i++)
        {
            m_text.text += "  char pos fig " + (i + 1) + ": " + charpos [i].x + " " + charpos [i].y + " " + charpos [i].z + objs[(int)charpos[0].x, -(int)charpos[0].z].GetComponent <WayPoint>() + Environment.NewLine;
        }
        m_text.text += "" + objs.GetLength(0) + " - " + objs.GetLength(1) + " / " + objs.Length;

        transform.position = new Vector3((tiles.GetLength(1) - 1) / 2f, 10, -(tiles.GetLength(0) - 1) / 2f);

        Pacman = Instantiate(Pacman, charpos[0], qempty);
        Blinky = Instantiate(Blinky, charpos[1], qempty);
        Inky   = Instantiate(Inky, charpos[2], qempty);
        Pinky  = Instantiate(Pinky, charpos[3], qempty);
        Clyde  = Instantiate(Clyde, charpos[4], qempty);

        Pacman.transform.position = charpos[0];
        Blinky.transform.position = charpos[1];
        Inky.transform.position   = charpos[2];
        Pinky.transform.position  = charpos[3];
        Clyde.transform.position  = charpos[4];

        m_objects.Add(Pacman);
        m_objects.Add(Blinky);
        m_objects.Add(Inky);
        m_objects.Add(Pinky);
        m_objects.Add(Clyde);

        //Pacman = Instantiate(Pacman, new Vector3(characterPositions[0], 0, -characterPositions[1]),  new Quaternion(0, 0, 0, 0));
        //Blinky = Instantiate(Blinky, new Vector3(characterPositions[2], 0, -characterPositions[3]), new Quaternion(0, 0, 0, 0));
        //Inky = Instantiate(Inky, new Vector3(characterPositions[4], 0, -characterPositions[5]), new Quaternion(0, 0, 0, 0));
        //Pinky = Instantiate(Pinky, new Vector3(characterPositions[6], 0, -characterPositions[7]), new Quaternion(0, 0, 0, 0));
        //Clyde = Instantiate(Clyde, new Vector3(characterPositions[8], 0, -characterPositions[9]), new Quaternion(0, 0, 0, 0));


        //Pacman.GetComponent<PlayerControlScript>().currentWaypoint = m_obj[characterPositions[0], characterPositions[1]].GetComponent<WayPoint>();
        //Blinky.GetComponent<EnemyBehaviourScript>().currentWaypoint = m_obj[characterPositions[2], characterPositions[3]].GetComponent<WayPoint>();
        //Inky.GetComponent<EnemyBehaviourScript>().currentWaypoint = m_obj[characterPositions[4], characterPositions[5]].GetComponent<WayPoint>();
        //Pinky.GetComponent<EnemyBehaviourScript>().currentWaypoint = m_obj[characterPositions[6], characterPositions[7]].GetComponent<WayPoint>();
        //Clyde.GetComponent<EnemyBehaviourScript>().currentWaypoint = m_obj[characterPositions[8], characterPositions[9]].GetComponent<WayPoint>();

        Pacman.GetComponent <PlayerControlScript>().currentWaypoint  = objs[-(int)charpos[0].z, (int)charpos[0].x].GetComponent <WayPoint>();
        Blinky.GetComponent <EnemyBehaviourScript>().currentWaypoint = objs[-(int)charpos[1].z, (int)charpos[1].x].GetComponent <WayPoint>();
        Inky.GetComponent <EnemyBehaviourScript>().currentWaypoint   = objs[-(int)charpos[2].z, (int)charpos[2].x].GetComponent <WayPoint>();
        Pinky.GetComponent <EnemyBehaviourScript>().currentWaypoint  = objs[-(int)charpos[3].z, (int)charpos[3].x].GetComponent <WayPoint>();
        Clyde.GetComponent <EnemyBehaviourScript>().currentWaypoint  = objs[-(int)charpos[4].z, (int)charpos[4].x].GetComponent <WayPoint>();


        m_text.text += "instanziated characters" + Environment.NewLine;
    }
Exemple #28
0
        protected override void Update(GameTime gameTime)
        {
            Time.Update(gameTime);
            InputManager.Update();

            currentScene.Update();
            background = (currentScene == scenes["Play"] ? Color.Black : Color.Black);

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (gameTime.ElapsedGameTime.TotalSeconds == 60)
            {
                Exit();
            }

            //if (InputManager.IsKeyDown(Keys.Up)) camera.Transform.Rotate(Vector3.Right, Time.ElapsedGameTime);
            //if (InputManager.IsKeyDown(Keys.Down)) camera.Transform.Rotate(Vector3.Left, Time.ElapsedGameTime);

            if (Inky.CheckCollision(pacman))
            {
                hits++;
            }
            if (Blinky.CheckCollision(pacman))
            {
                hits++;
            }
            if (Pinky.CheckCollision(pacman))
            {
                hits++;
            }
            if (Clyde.CheckCollision(pacman))
            {
                hits++;
            }
            if (Blue.CheckCollision(pacman))
            {
                hits++;
            }

            pacman.Update();
            Inky.Update();
            Blinky.Update();
            Pinky.Update();
            Clyde.Update();
            Blue.Update();
            powerUp.Update();

            Vector3 normal;

            if (pacman.Get <Collider>().Collides(powerUp.Get <Collider>(), out normal))
            {
                Console.WriteLine("HitBox");
                (powerUp.Get <Renderer>().ObjectModel.Meshes[0].Effects[0] as BasicEffect).DiffuseColor = Color.Red.ToVector3();
                pacmanHealth--;
            }
            else
            {
                Console.WriteLine("NotHitBox");
                (powerUp.Get <Renderer>().ObjectModel.Meshes[0].Effects[0] as BasicEffect).DiffuseColor = Color.Blue.ToVector3();
                pacmanHealth--;
            }

            base.Update(gameTime);
        }