Esempio n. 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);
        }
Esempio n. 2
0
 public GameEngine(Blinky blinky, Clyde clyde, Inky inky, Pinky pinky)
 {
     ghosts.Add(blinky);
     ghosts.Add(clyde);
     ghosts.Add(inky);
     ghosts.Add(pinky);
 }
Esempio n. 3
0
    private void PlaceGhost()
    {
        akabei = Instantiate(akabeiPrefab, maze.transform);
        akabei.Initialize(maze, pacman);

        pinky = Instantiate(pinkyPrefab, maze.transform);
        pinky.Initialize(maze, pacman);

        aosuke = Instantiate(aosukePrefab, maze.transform);
        aosuke.Initialize(maze, pacman, akabei);

        guzuta = Instantiate(guzutaPrefab, maze.transform);
        guzuta.Initialize(maze, pacman);

        ghosts = new List <AGhost>
        {
            akabei, pinky, aosuke, guzuta
        };

        ghosts.ForEach(g =>
        {
            //ゴーストが食べられたときの処理。
            g.OnEaten += (s, e) =>
            {
                //パックマン、ゴーストを一時停止。
                PauseAll(eatSpan);

                //食べたゴーストの数により、点数が変化する。
                var scr = g.Score * (1 << eatenGhost);
                //得点の更新。
                score         += scr;
                scoreText.text = score.ToString();
                //得点を表示。
                scorer.Set(scr, g.transform.position, eatSpan);

                eatenGhost++;

                soundManager.PlaySE("EatGhost", 0.6f);
            };

            //ゴーストが食べたときの処理。
            g.OnEat += (s, e) =>
            {
                pacman.Dead();
                //ゴーストを停止。
                ghosts.ForEach(g2 => g2.Stop());
                isScare = false;
                lives--;

                if (fruits != null)
                {
                    fruits.Destroy();
                }

                soundManager.PlaySE("Dead", 0.6f);
                soundManager.StopBGM();
            };
        });
    }
Esempio n. 4
0
 // Method
 public void Assign(int GetPointofView, string callback, Pinky pinky, int soundID)
 {
     if (GetPointofView > 7)
     {
         GetPointofView = GetPointofView / 4500;
     }
     this.direction[GetPointofView].Assign(callback, pinky, soundID);
 }
 public override void editing(PropEditController propEditController)
 {
     findHandBehavior();
     Thumb.apply();
     Index.apply();
     Middle.apply();
     Ring.apply();
     Pinky.apply();
 }
Esempio n. 6
0
 public void UpdateHand(FingerModel thumb, FingerModel index, FingerModel middle, FingerModel pinky,
                        FingerModel ring)
 {
     Thumb.UpdateFinger(thumb);
     Index.UpdateFinger(index);
     Middle.UpdateFinger(middle);
     Ring.UpdateFinger(ring);
     Pinky.UpdateFinger(pinky);
 }
Esempio n. 7
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);
 }
Esempio n. 8
0
        private void KeyMappingGrid_KeyDown()
        {
            bool Shift           = false;
            bool Ctrl            = false;
            bool Alt             = false;
            int  catchedScanCode = 0;

            directInputDevice.GetCurrentKeyboardState();
            for (int i = 1; i < 238; i++)
            {
                if (directInputDevice.KeyboardState[(Microsoft.DirectX.DirectInput.Key)i])
                {
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftShift |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightShift)
                    {
                        Shift = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftControl |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightControl)
                    {
                        Ctrl = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftAlt |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightAlt)
                    {
                        Alt = true;
                        continue;
                    }
                    catchedScanCode = i;
                }
            }
            if (catchedScanCode == 0)
            {
                return;
            }

            Pinky pinkyStatus = Pinky.UnShift;

            if (Select_PinkyShift.IsChecked == false)
            {
                pinkyStatus = Pinky.Shift;
            }

            if (pinkyStatus == Pinky.UnShift)
            {
                tmpCallback.SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
            }
            if (pinkyStatus == Pinky.Shift)
            {
                tmpCallback.Setkeycombo(catchedScanCode, Shift, Ctrl, Alt);
            }
        }
Esempio n. 9
0
        public void TestCalculateTargetCell4()
        {
            Game   game   = new Game();
            Player pacman = game.Player;
            Pinky  pinky  = (Pinky)game.Ghosts[1];

            pacman.Direction = Direction.Right;

            Cell cell = pinky.CalculateTargetCell();

            Assert.IsFalse(cell.IsWall());
        }
Esempio n. 10
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);
 }
Esempio n. 11
0
        public void TestCalculateTargetCell1()
        {
            Game   game   = new Game();
            Player pacman = game.Player;
            Pinky  pinky  = (Pinky)game.Ghosts[1];

            pacman.Direction = Direction.Left;

            Cell cell = pinky.CalculateTargetCell();

            Assert.AreEqual(cell.GetX(), pacman.GetX() - 3);
            Assert.IsFalse(cell.IsWall());
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
        }
        private void findHandBehavior()
        {
            hand = (PoseableHand)PropSimObject.getElement(PoseableHand.PoseableHandBehavior);

            Thumb.setFinger(hand.Thumb);
            Thumb.getStartingValues();

            Index.setFinger(hand.Index);
            Index.getStartingValues();

            Middle.setFinger(hand.Middle);
            Middle.getStartingValues();

            Ring.setFinger(hand.Ring);
            Ring.getStartingValues();

            Pinky.setFinger(hand.Pinky);
            Pinky.getStartingValues();
        }
Esempio n. 15
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;
        }
Esempio n. 16
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);
        }
Esempio n. 17
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;
     }
 }
Esempio n. 18
0
        public int CountFingers()
        {
            int fingers = 4;

            if (Index.IsFingerFolded())
            {
                fingers--;
            }
            if (Middle.IsFingerFolded())
            {
                fingers--;
            }
            if (Ring.IsFingerFolded())
            {
                fingers--;
            }
            if (Pinky.IsFingerFolded())
            {
                fingers--;
            }

            return(fingers);
        }
Esempio n. 19
0
        /// <summary>
        /// You pressed a joystick button to search which callback is it assigned to? OK let's go there.
        /// </summary>
        public void JumptoAssignedKey()
        {
            string target = "";

            switch (statusAssign)
            {
            case Status.GetNeutralPos:
                for (int i = 0; i < deviceControl.devList.Count; i++)
                {
                    neutralButtons[i] = new NeutralButtons(deviceControl.joyStick[i]);
                }
                statusAssign = Status.WaitingforInput;
                break;

            case Status.WaitingforInput:
                for (int i = 0; i < deviceControl.devList.Count; i++)
                {
                    buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons();
                    for (int ii = 0; ii < 32; ii++)
                    {
                        if (buttons[ii] == neutralButtons[i].buttons[ii])
                        {
                            continue;
                        }
                        statusAssign = Status.GetNeutralPos;
                        if (buttons[ii] == 0)     // RELEASE SHIFT
                        {
                            continue;
                        }

                        Pinky     pinkyStatus     = Pinky.UnShift;
                        Behaviour behaviourStatus = Behaviour.Press;
                        if (Select_PinkyShift.IsChecked == false)
                        {
                            pinkyStatus = Pinky.Shift;
                        }
                        if (Select_DX_Release.IsChecked == false)
                        {
                            behaviourStatus = Behaviour.Release;
                        }

                        target = deviceControl.joyAssign[i].dx[ii].assign[(int)pinkyStatus + (int)behaviourStatus].GetCallback();
                        Label_AssgnStatus.Content = "DX" + (ii + 1) + "\t: " + deviceControl.joyAssign[i].GetProductName();
                    }
                    povs = deviceControl.joyStick[i].CurrentJoystickState.GetPointOfView();
                    for (int ii = 0; ii < 4; ii++)
                    {
                        if (povs[ii] == neutralButtons[i].povs[ii])
                        {
                            continue;
                        }
                        statusAssign = Status.GetNeutralPos;
                        if (povs[ii] == -1)
                        {
                            continue;
                        }

                        Pinky pinkyStatus = Pinky.UnShift;
                        if (Select_PinkyShift.IsChecked == false)
                        {
                            pinkyStatus = Pinky.Shift;
                        }

                        target = deviceControl.joyAssign[i].pov[ii].direction[povs[ii] / 4500].GetCallback(pinkyStatus);

                        string direction = deviceControl.joyAssign[i].pov[ii].GetDirection(povs[ii]);
                        Label_AssgnStatus.Content = "POV" + (ii + 1) + "." + direction + "\t: " + deviceControl.joyAssign[i].GetProductName();
                    }
                }
                break;
            }
            if (target == "")
            {
                return;
            }
            if (target == "SimDoNothing")
            {
                return;
            }
            // If the key assignment was found, jump to the mapping for it and highlight it.
            var key = keyFile.keyAssign.FirstOrDefault(x => x.GetCallback() == target);

            if (key != null)
            {
                Label_AssgnStatus.Content += "   / " + key.Mapping;

                KeyMappingGrid.ScrollIntoView(key);
                KeyMappingGrid.SelectedIndex = KeyMappingGrid.Items.IndexOf(key);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// You pressed keyboard keys? I will check which key was pressed with Shift/Ctrl/Alt.
        /// </summary>
        private void KeyMappingGrid_KeyDown()
        {
            if (currentIndex < 0)
            {
                currentIndex = 1;
                statusSearch = Search.Search;
                return;
            }
            if (SearchBox.IsSelectionActive == true)
            {
                return;
            }
            if (SearchBox.IsFocused == true)
            {
                return;
            }
            if (SearchBox.IsKeyboardFocused == true)
            {
                return;
            }

            bool Shift = false;
            bool Ctrl  = false;
            bool Alt   = false;

            int catchedScanCode = 0;

            directInputDevice.GetCurrentKeyboardState();

            for (int i = 1; i < 238; i++)
            {
                if (directInputDevice.KeyboardState[(Microsoft.DirectX.DirectInput.Key)i])
                {
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftShift |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightShift)
                    {
                        Shift = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftControl |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightControl)
                    {
                        Ctrl = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftAlt |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightAlt)
                    {
                        Alt = true;
                        continue;
                    }
                    catchedScanCode = i;
                }
            }
            if (catchedScanCode == 0)
            {
                return;
            }
            if (statusSearch == Search.Search)
            {
                if (Select_PinkyShift.IsChecked == false)
                {
                    return;
                }

                KeyAssgn keytmp = new KeyAssgn("SimDoNothing - 1 0 0XFFFFFFFF 0 0 0 - 1 \"nothing\"");
                keytmp.SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
                Label_AssgnStatus.Content = "INPUT " + keytmp.GetKeyAssignmentStatus();

                // If the key assignment was found, jump to the mapping for it and highlight it.
                var key = keyFile.keyAssign.FirstOrDefault(x => x.GetKeyAssignmentStatus() == keytmp.GetKeyAssignmentStatus());
                if (key != null)
                {
                    Label_AssgnStatus.Content += "\t/" + key.Mapping;

                    KeyMappingGrid.UpdateLayout();
                    KeyMappingGrid.ScrollIntoView(key);
                    KeyMappingGrid.SelectedIndex = KeyMappingGrid.Items.IndexOf(key);
                }

                return;
            }
            if (KeyMappingGrid.SelectedIndex == -1)
            {
                return;
            }

            var selectedItem = (KeyAssgn)KeyMappingGrid.SelectedItem;

            if (selectedItem.Visibility != "White")
            {
                return;
            }

            Pinky pinkyStatus = Pinky.UnShift;

            if (Select_PinkyShift.IsChecked == false)
            {
                pinkyStatus = Pinky.Shift;
            }

            KeyMappingGrid.ScrollIntoView(selectedItem);
            KeyMappingGrid.SelectedIndex = currentIndex;

            if (pinkyStatus == Pinky.UnShift)
            {
                selectedItem.SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
            }
            if (pinkyStatus == Pinky.Shift)
            {
                selectedItem.Setkeycombo(catchedScanCode, Shift, Ctrl, Alt);
            }

            // Unassign the previous mapping that was assigned to this key/key combo.
            var oldKey = keyFile.keyAssign.FirstOrDefault(x => (x != selectedItem) && x.GetKeyAssignmentStatus() == selectedItem.GetKeyAssignmentStatus());

            if (oldKey != null)
            {
                oldKey.UnassignKeyboard();
            }

            KeyMappingGrid.Items.Refresh();
            KeyMappingGrid.UnselectAllCells();
            statusSearch = Search.Search;
        }
Esempio n. 21
0
        /// <summary>
        /// Check your keyboard/joysticks button behaviour every 60 frames per seconds.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void KeyMappingTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                directInputDevice.GetCurrentKeyboardState();
                for (int i = 1; i < 238; i++)
                {
                    if (directInputDevice.KeyboardState[(Microsoft.DirectX.DirectInput.Key)i])
                    {
                        KeyMappingGrid_KeyDown();
                    }
                }

                int Rows         = KeyMappingGrid.SelectedIndex;
                var selectedItem = (KeyAssgn)KeyMappingGrid.SelectedItem;

                if (Rows == -1 || statusSearch == Search.Search)
                {
                    JumptoAssignedKey();
                    return;
                }
                if (KeyMappingGrid.CurrentColumn == null)
                {
                    return;
                }
                if (selectedItem.GetVisibility() != "White")
                {
                    return;
                }


                switch (statusAssign)
                {
                case Status.GetNeutralPos:
                    for (int i = 0; i < deviceControl.devList.Count; i++)
                    {
                        neutralButtons[i] = new NeutralButtons(deviceControl.joyStick[i]);
                    }
                    statusAssign = Status.WaitingforInput;
                    break;

                case Status.WaitingforInput:
                    for (int i = 0; i < deviceControl.devList.Count; i++)
                    {
                        buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons();
                        for (int ii = 0; ii < 32; ii++)
                        {
                            if (buttons[ii] == neutralButtons[i].buttons[ii])
                            {
                                continue;
                            }
                            statusAssign = Status.GetNeutralPos;
                            if (buttons[ii] == 0)
                            {
                                continue;
                            }

                            Pinky     pinkyStatus     = Pinky.UnShift;
                            Behaviour behaviourStatus = Behaviour.Press;
                            if (Select_PinkyShift.IsChecked == false)
                            {
                                pinkyStatus = Pinky.Shift;
                            }
                            if (Select_DX_Release.IsChecked == false)
                            {
                                behaviourStatus = Behaviour.Release;
                            }

                            // Construct DX button instance.
                            if (selectedItem.GetCallback() == "SimHotasPinkyShift")
                            {
                                deviceControl.joyAssign[i].dx[ii].Assign(selectedItem.GetCallback(), Pinky.UnShift, Behaviour.Press, Invoke.Default, 0);
                                deviceControl.joyAssign[i].dx[ii].Assign(selectedItem.GetCallback(), Pinky.Shift, Behaviour.Press, Invoke.Default, 0);
                            }
                            else
                            {
                                deviceControl.joyAssign[i].dx[ii].Assign(selectedItem.GetCallback(), pinkyStatus, behaviourStatus, invokeStatus, 0);
                            }

                            KeyMappingGrid.Items.Refresh();
                            KeyMappingGrid.UnselectAllCells();
                        }
                        povs = deviceControl.joyStick[i].CurrentJoystickState.GetPointOfView();
                        for (int ii = 0; ii < 4; ii++)
                        {
                            if (povs[ii] == neutralButtons[i].povs[ii])
                            {
                                continue;
                            }
                            statusAssign = Status.GetNeutralPos;
                            if (povs[ii] == -1)
                            {
                                continue;
                            }

                            Pinky pinkyStatus = Pinky.UnShift;
                            if (Select_PinkyShift.IsChecked == false)
                            {
                                pinkyStatus = Pinky.Shift;
                            }

                            // Construct POV button instance.
                            deviceControl.joyAssign[i].pov[ii].Assign(povs[ii], selectedItem.GetCallback(), pinkyStatus, 0);

                            KeyMappingGrid.Items.Refresh();
                            KeyMappingGrid.UnselectAllCells();
                        }
                    }
                    break;
                }
            }
            catch (System.IO.FileNotFoundException ex)
            {
                System.Console.WriteLine(ex.Message);

                System.IO.StreamWriter sw = new System.IO.StreamWriter(appReg.GetInstallDir() + "\\Error.txt", false, System.Text.Encoding.GetEncoding("shift_jis"));
                sw.Write(ex.Message);
                sw.Close();

                MessageBox.Show("Error Log Saved To " + appReg.GetInstallDir() + "\\Error.txt", "WARNING", MessageBoxButton.OK, MessageBoxImage.Information);

                this.Close();
            }
        }
Esempio n. 22
0
        private void JoystickButtonMonitor()
        {
            for (int i = 0; i < deviceControl.devList.Count; i++)
            {
                byte[] buttons;
                int[]  povs;

                buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons();
                for (int ii = 0; ii < 32; ii++)
                {
                    if (buttons[ii] == 128 && deviceControl.joyAssign[i].dx[ii].assign[0].GetCallback() == "SimHotasPinkyShift" && pressedByHand == false)
                    {
                        Select_PinkyShift.IsChecked = false;
                    }
                    if (buttons[ii] == 0 && deviceControl.joyAssign[i].dx[ii].assign[0].GetCallback() == "SimHotasPinkyShift" && pressedByHand == false)
                    {
                        Select_PinkyShift.IsChecked = true;
                    }

                    if (buttons[ii] == neutralButtons[i].buttons[ii])
                    {
                        continue;
                    }
                    if (buttons[ii] == 0)
                    {
                        getNeutralPosition();
                        continue;
                    }

                    if (deviceControl.joyAssign[i].dx[ii].assign[0].GetCallback() == "SimHotasPinkyShift" && pressedByHand == false)
                    {
                        continue;
                    }

                    Pinky     pinkyStatus     = Pinky.UnShift;
                    Behaviour behaviourStatus = Behaviour.Press;
                    if (Select_PinkyShift.IsChecked == false)
                    {
                        pinkyStatus = Pinky.Shift;
                    }
                    if (Select_DX_Release.IsChecked == false)
                    {
                        behaviourStatus = Behaviour.Release;
                    }

                    // Construct DX button instance.
                    if (tmpCallback.GetCallback() == "SimHotasPinkyShift")
                    {
                        tmpJoyStick[i].dx[ii].Assign(tmpCallback.GetCallback(), Pinky.UnShift, Behaviour.Press, Invoke.Default, 0);
                        tmpJoyStick[i].dx[ii].Assign(tmpCallback.GetCallback(), Pinky.Shift, Behaviour.Press, Invoke.Default, 0);
                    }
                    else
                    {
                        tmpJoyStick[i].dx[ii].Assign(tmpCallback.GetCallback(), pinkyStatus, behaviourStatus, invokeStatus, 0);
                    }
                    //while (buttons[ii] != neutralButtons[i].buttons[ii])
                    //{
                    //    buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons();
                    //}
                    getNeutralPosition();
                    return;
                }
                povs    = deviceControl.joyStick[i].CurrentJoystickState.GetPointOfView();
                buttons = deviceControl.joyStick[i].CurrentJoystickState.GetButtons();
                for (int ii = 0; ii < 4; ii++)
                {
                    if (povs[ii] == neutralButtons[i].povs[ii])
                    {
                        continue;
                    }
                    if (povs[ii] == -1)
                    {
                        getNeutralPosition();
                        continue;
                    }

                    Pinky pinkyStatus = Pinky.UnShift;
                    if (Select_PinkyShift.IsChecked == false)
                    {
                        pinkyStatus = Pinky.Shift;
                    }

                    // Construct POV button instance.
                    tmpJoyStick[i].pov[ii].Assign(povs[ii], tmpCallback.GetCallback(), pinkyStatus, 0);
                    //while (povs[ii] != neutralButtons[i].povs[ii])
                    //{
                    //    povs = deviceControl.joyStick[i].CurrentJoystickState.GetPointOfView();
                    //}
                    getNeutralPosition();
                    return;
                }
            }
        }
Esempio n. 23
0
 // Method
 public string GetCallback(Pinky pinky)
 {
     return(this.callback[(int)pinky]);
 }
Esempio n. 24
0
 // Method
 public void Assign(string callback, Pinky pinky, Behaviour behaviour, Invoke invoke, int soundID)
 {
     assign[(int)pinky + (int)behaviour] = new Assgn(callback, invoke, soundID);
 }
Esempio n. 25
0
 public int GetSoundID(Pinky pinky)
 {
     return(this.soundID[(int)pinky]);
 }
        /// <summary>
        /// You pressed keyboard keys? I will check which key was pressed with Shift/Ctrl/Alt.
        /// </summary>
        private void KeyMappingGrid_KeyDown()
        {
            if (currentIndex < 0)
            {
                currentIndex = 1;
                statusSearch = Search.Search;
                return;
            }
            if (SearchBox.IsSelectionActive == true)
            {
                return;
            }
            if (SearchBox.IsFocused == true)
            {
                return;
            }
            if (SearchBox.IsKeyboardFocused == true)
            {
                return;
            }

            bool Shift = false;
            bool Ctrl  = false;
            bool Alt   = false;

            int catchedScanCode = 0;

            directInputDevice.GetCurrentKeyboardState();

            for (int i = 1; i < 238; i++)
            {
                if (directInputDevice.KeyboardState[(Microsoft.DirectX.DirectInput.Key)i])
                {
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftShift |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightShift)
                    {
                        Shift = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftControl |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightControl)
                    {
                        Ctrl = true;
                        continue;
                    }
                    if (i == (int)Microsoft.DirectX.DirectInput.Key.LeftAlt |
                        i == (int)Microsoft.DirectX.DirectInput.Key.RightAlt)
                    {
                        Alt = true;
                        continue;
                    }
                    catchedScanCode = i;
                }
            }
            if (catchedScanCode == 0)
            {
                return;
            }
            if (statusSearch == Search.Search)
            {
                KeyAssgn keytmp = new KeyAssgn("SimDoNothing - 1 0 0XFFFFFFFF 0 0 0 - 1 \"nothing\"");
                keytmp.SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
                Label_AssgnStatus.Content = "INPUT " + keytmp.GetKeyAssignmentStatus();
                for (int i = 0; i < keyFile.keyAssign.Length; i++)
                {
                    if (keytmp.GetKeyAssignmentStatus() != keyFile.keyAssign[i].GetKeyAssignmentStatus())
                    {
                        continue;
                    }

                    Label_AssgnStatus.Content += "\t/" + keyFile.keyAssign[i].Mapping;

                    KeyMappingGrid.UpdateLayout();
                    KeyMappingGrid.ScrollIntoView(KeyMappingGrid.Items[i]);
                    KeyMappingGrid.SelectedIndex = i;
                }
                return;
            }
            if (KeyMappingGrid.SelectedIndex == -1)
            {
                return;
            }
            if (keyFile.keyAssign[currentIndex].GetVisibility() != "White")
            {
                return;
            }

            Pinky pinkyStatus = Pinky.UnShift;

            if (Select_PinkyShift.IsChecked == false)
            {
                pinkyStatus = Pinky.Shift;
            }

            KeyMappingGrid.ScrollIntoView(KeyMappingGrid.Items[currentIndex]);
            KeyMappingGrid.SelectedIndex = currentIndex;
            if (pinkyStatus == Pinky.UnShift)
            {
                keyFile.keyAssign[currentIndex].SetKeyboard(catchedScanCode, Shift, Ctrl, Alt);
            }
            if (pinkyStatus == Pinky.Shift)
            {
                keyFile.keyAssign[currentIndex].Setkeycombo(catchedScanCode, Shift, Ctrl, Alt);
            }

            for (int i = 0; i < keyFile.keyAssign.Length; i++)
            {
                if (keyFile.keyAssign[i].GetKeyAssignmentStatus() != keyFile.keyAssign[currentIndex].GetKeyAssignmentStatus())
                {
                    continue;
                }
                if (i == currentIndex)
                {
                    continue;
                }
                if (keyFile.keyAssign[i].GetVisibility() != "White")
                {
                    continue;
                }
                keyFile.keyAssign[i].UnassignKeyboard();
            }

            KeyMappingGrid.Items.Refresh();
            KeyMappingGrid.UnselectAllCells();
            statusSearch = Search.Search;
        }
        //Public Methods:
        public void Update()
        {
            //update keypoints and fingers:
            WristCenter.Update(_managedHand, _managedHand.Hand.Wrist.Center.Position, _managedHand.Skeleton.HandCenter.positionFiltered);
            HandCenter.Update(_managedHand, _managedHand.Hand.Center);
            _thumbMCP.Update(_managedHand, _managedHand.Hand.Thumb.MCP.Position, _managedHand.Skeleton.Index.Knuckle.positionFiltered, _managedHand.Skeleton.HandCenter.positionFiltered);
            _thumbPIP.Update(_managedHand, _managedHand.Hand.Thumb.IP.Position, _managedHand.Skeleton.Thumb.Knuckle.positionFiltered, _managedHand.Skeleton.HandCenter.positionFiltered);
            _thumbTip.Update(_managedHand, _managedHand.Hand.Thumb.Tip.Position, _managedHand.Skeleton.Thumb.Joint.positionFiltered, _managedHand.Skeleton.Middle.Tip.positionFiltered, _managedHand.Skeleton.Thumb.Knuckle.positionFiltered, _managedHand.Skeleton.HandCenter.positionFiltered);
            Thumb.Update();

            _indexMCP.Update(_managedHand, _managedHand.Hand.Index.MCP.Position, _managedHand.Skeleton.HandCenter.positionFiltered);
            _indexPIP.Update(_managedHand, _managedHand.Hand.Index.PIP.Position, _managedHand.Skeleton.Index.Knuckle.positionFiltered, _managedHand.Skeleton.HandCenter.positionFiltered);
            _indexTip.Update(_managedHand, _managedHand.Hand.Index.Tip.Position, _managedHand.Skeleton.Index.Joint.positionFiltered, _managedHand.Skeleton.Index.Knuckle.positionFiltered, _managedHand.Skeleton.HandCenter.positionFiltered, _managedHand.Skeleton.Thumb.Joint.positionFiltered, _managedHand.Skeleton.Middle.Tip.positionFiltered);
            Index.Update();

            _middleMCP.Update(_managedHand, _managedHand.Hand.Middle.MCP.Position, _managedHand.Skeleton.HandCenter.positionFiltered);
            _middlePIP.Update(_managedHand, _managedHand.Hand.Middle.PIP.Position, _managedHand.Skeleton.Middle.Knuckle.positionFiltered, _managedHand.Skeleton.HandCenter.positionFiltered);
            _middleTip.Update(_managedHand, _managedHand.Hand.Middle.Tip.Position, _managedHand.Skeleton.Middle.Joint.positionFiltered, _managedHand.Skeleton.Middle.Knuckle.positionFiltered, _managedHand.Skeleton.Ring.Tip.positionFiltered, _managedHand.Skeleton.HandCenter.positionFiltered);
            Middle.Update();

            _ringMCP.Update(_managedHand, _managedHand.Hand.Ring.MCP.Position, _managedHand.Skeleton.HandCenter.positionFiltered);
            _ringTip.Update(_managedHand, _managedHand.Hand.Ring.Tip.Position, _managedHand.Skeleton.Ring.Knuckle.positionFiltered, _managedHand.Skeleton.Pinky.Tip.positionFiltered, _managedHand.Skeleton.Middle.Tip.positionFiltered, _managedHand.Skeleton.HandCenter.positionFiltered);
            Ring.Update();

            _pinkyMCP.Update(_managedHand, _managedHand.Hand.Pinky.MCP.Position, _managedHand.Skeleton.HandCenter.positionFiltered);
            _pinkyTip.Update(_managedHand, _managedHand.Hand.Pinky.Tip.Position, _managedHand.Skeleton.Pinky.Knuckle.positionFiltered, _managedHand.Skeleton.Ring.Tip.positionFiltered, _managedHand.Skeleton.HandCenter.positionFiltered);
            Pinky.Update();

            //we need a hand to continue:
            if (!_managedHand.Visible)
            {
                return;
            }

            //correct distances:
            float thumbMcpToWristDistance = Vector3.Distance(_thumbMCP.positionFiltered, WristCenter.positionFiltered) * .5f;
            //fix the distance between the wrist and thumbMcp as it incorrectly expands as the hand gets further from the camera:
            float distancePercentage = Mathf.Clamp01(Vector3.Distance(_mainCamera.transform.position, WristCenter.positionFiltered) / .5f);

            distancePercentage       = 1 - Percentage(distancePercentage, .90f, 1) * .4f;
            thumbMcpToWristDistance *= distancePercentage;
            Vector3 wristToPalmDirection = Vector3.Normalize(Vector3.Normalize(HandCenter.positionFiltered - WristCenter.positionFiltered));
            Vector3 center = WristCenter.positionFiltered + (wristToPalmDirection * thumbMcpToWristDistance);
            Vector3 camToWristDirection = Vector3.Normalize(WristCenter.positionFiltered - _mainCamera.transform.position);

            //rays needed for planarity discovery for in/out palm facing direction:
            Vector3 camToWrist    = new Ray(WristCenter.positionFiltered, camToWristDirection).GetPoint(1);
            Vector3 camToThumbMcp = new Ray(_thumbMCP.positionFiltered, Vector3.Normalize(_thumbMCP.positionFiltered - _mainCamera.transform.position)).GetPoint(1);
            Vector3 camToPalm     = new Ray(center, Vector3.Normalize(center - _mainCamera.transform.position)).GetPoint(1);

            //discover palm facing direction to camera:
            Plane palmFacingPlane = new Plane(camToWrist, camToPalm, camToThumbMcp);

            if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
            {
                palmFacingPlane.Flip();
            }
            float palmForwardFacing = Mathf.Sign(Vector3.Dot(palmFacingPlane.normal, _mainCamera.transform.forward));

            //use thumb/palm/wrist alignment to determine amount of roll in the hand:
            Vector3 toThumbMcp     = Vector3.Normalize(_thumbMCP.positionFiltered - center);
            Vector3 toPalm         = Vector3.Normalize(center - WristCenter.positionFiltered);
            float   handRollAmount = (1 - Vector3.Dot(toThumbMcp, toPalm)) * palmForwardFacing;

            //where between the wrist and thumbMcp should we slide inwards to get the palm in the center:
            Vector3 toPalmOrigin = Vector3.Lerp(WristCenter.positionFiltered, _thumbMCP.positionFiltered, .35f);

            //get a direction from the camera to toPalmOrigin as psuedo up for use in quaternion construction:
            Vector3 toCam = Vector3.Normalize(_mainCamera.transform.position - toPalmOrigin);

            //construct a quaternion that helps get angles needed between the wrist and thumbMCP to point towards the palm center:
            Vector3    wristToThumbMcp       = Vector3.Normalize(_thumbMCP.positionFiltered - WristCenter.positionFiltered);
            Quaternion towardsCamUpReference = Quaternion.identity;

            if (wristToThumbMcp != Vector3.zero && toCam != Vector3.zero)
            {
                towardsCamUpReference = Quaternion.LookRotation(wristToThumbMcp, toCam);
            }

            //rotate the inwards vector depending on hand roll to know where to push the palm back:
            float inwardsVectorRotation = 90;

            if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
            {
                inwardsVectorRotation = -90;
            }
            towardsCamUpReference = Quaternion.AngleAxis(handRollAmount * inwardsVectorRotation, towardsCamUpReference * Vector3.forward) * towardsCamUpReference;
            Vector3 inwardsVector = towardsCamUpReference * Vector3.up;

            //slide palm location along inwards vector to get it into proper physical location in the center of the hand:
            center = toPalmOrigin - inwardsVector * thumbMcpToWristDistance;
            Vector3 deadCenter = center;

            //as the hand flattens back out balance corrected location with originally provided location for better forward origin:
            center = Vector3.Lerp(center, HandCenter.positionFiltered, Mathf.Abs(handRollAmount));

            //get a forward using the corrected palm location:
            Vector3 forward = Vector3.Normalize(center - WristCenter.positionFiltered);

            //switch back to physical center of hand - this reduces surface-to-surface movement of the center between back and palm:
            center = deadCenter;

            //get an initial hand up:
            Plane handPlane = new Plane(WristCenter.positionFiltered, _thumbMCP.positionFiltered, center);

            if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
            {
                handPlane.Flip();
            }
            Vector3 up = handPlane.normal;

            //find out how much the back of the hand is facing the camera so we have a safe set of features for a stronger forward:
            Vector3 centerToCam = Vector3.Normalize(_mainCamera.transform.position - WristCenter.positionFiltered);
            float   facingDot   = Vector3.Dot(centerToCam, up);

            if (facingDot > .5f)
            {
                float handBackFacingCamAmount = Percentage(facingDot, .5f, 1);

                //steer forward for more accuracy based on the visibility of the back of the hand:
                if (_middleMCP.Visible)
                {
                    Vector3 toMiddleMcp = Vector3.Normalize(_middleMCP.positionFiltered - center);
                    forward = Vector3.Lerp(forward, toMiddleMcp, handBackFacingCamAmount);
                }
                else if (_indexMCP.Visible)
                {
                    Vector3 inIndexMcp = Vector3.Normalize(_indexMCP.positionFiltered - center);
                    forward = Vector3.Lerp(forward, inIndexMcp, handBackFacingCamAmount);
                }
            }

            //make sure palm distance from wrist is consistant while also leveraging steered forward:
            center = WristCenter.positionFiltered + (forward * thumbMcpToWristDistance);

            //an initial rotation of the hand:
            Quaternion orientation = Quaternion.identity;

            if (forward != Vector3.zero && up != Vector3.zero)
            {
                orientation = Quaternion.LookRotation(forward, up);
            }

            //as the hand rolls counter-clockwise the thumbMcp loses accuracy so we need to interpolate to the back of the hand's features:
            if (_indexMCP.Visible && _middleMCP.Visible)
            {
                Vector3 knucklesVector = Vector3.Normalize(_middleMCP.positionFiltered - _indexMCP.positionFiltered);
                float   knucklesDot    = Vector3.Dot(knucklesVector, Vector3.up);
                if (knucklesDot > .5f)
                {
                    float counterClockwiseRoll = Percentage(Vector3.Dot(knucklesVector, Vector3.up), .35f, .7f);
                    center  = Vector3.Lerp(center, HandCenter.positionFiltered, counterClockwiseRoll);
                    forward = Vector3.Lerp(forward, Vector3.Normalize(_middleMCP.positionFiltered - HandCenter.positionFiltered), counterClockwiseRoll);
                    Plane backHandPlane = new Plane(HandCenter.positionFiltered, _indexMCP.positionFiltered, _middleMCP.positionFiltered);
                    if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
                    {
                        backHandPlane.Flip();
                    }
                    up          = Vector3.Lerp(up, backHandPlane.normal, counterClockwiseRoll);
                    orientation = Quaternion.LookRotation(forward, up);
                }
            }

            //as the wrist tilts away from the camera (with the thumb down) at extreme angles the hand center will move toward the thumb:
            float   handTiltAwayAmount          = 1 - Percentage(Vector3.Distance(HandCenter.positionFiltered, WristCenter.positionFiltered), .025f, .04f);
            Vector3 handTiltAwayCorrectionPoint = WristCenter.positionFiltered + camToWristDirection * thumbMcpToWristDistance;

            center  = Vector3.Lerp(center, handTiltAwayCorrectionPoint, handTiltAwayAmount);
            forward = Vector3.Lerp(forward, Vector3.Normalize(handTiltAwayCorrectionPoint - WristCenter.positionFiltered), handTiltAwayAmount);
            Plane wristPlane = new Plane(WristCenter.positionFiltered, _thumbMCP.positionFiltered, center);

            if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
            {
                wristPlane.Flip();
            }
            up = Vector3.Lerp(up, wristPlane.normal, handTiltAwayAmount);
            if (forward != Vector3.zero && up != Vector3.zero)
            {
                orientation = Quaternion.LookRotation(forward, up);
            }

            //steering for if thumb/index are not available from self-occlusion to help rotate the hand better outwards better:
            float forwardUpAmount = Vector3.Dot(forward, Vector3.up);

            if (forwardUpAmount > .7f && _indexMCP.Visible && _ringMCP.Visible)
            {
                float angle = 0;
                if (_managedHand.Hand.Type == MLHandTracking.HandType.Right)
                {
                    Vector3 knucklesVector = Vector3.Normalize(_ringMCP.positionFiltered - _indexMCP.positionFiltered);
                    angle  = Vector3.Angle(knucklesVector, orientation * Vector3.right);
                    angle *= -1;
                }
                else
                {
                    Vector3 knucklesVector = Vector3.Normalize(_indexMCP.positionFiltered - _ringMCP.positionFiltered);
                    angle = Vector3.Angle(knucklesVector, orientation * Vector3.right);
                }
                Quaternion selfOcclusionSteering = Quaternion.AngleAxis(angle, forward);
                orientation = selfOcclusionSteering * orientation;
            }
            else
            {
                //when palm is facing down we need to rotate some to compensate for an offset:
                float rollCorrection       = Mathf.Clamp01(Vector3.Dot(orientation * Vector3.up, Vector3.up));
                float rollCorrectionAmount = -30;
                if (_managedHand.Hand.Type == MLHandTracking.HandType.Left)
                {
                    rollCorrectionAmount = 30;
                }
                orientation = Quaternion.AngleAxis(rollCorrectionAmount * rollCorrection, forward) * orientation;
            }


            //set pose:
            Position = center;
            Rotation = orientation;

            UpdateKeypointRotations();
        }
Esempio n. 28
0
 public void Assign(string callback, Pinky pinky, int soundID)
 {
     this.callback[(int)pinky] = callback;
     this.soundID[(int)pinky]  = soundID;
 }
Esempio n. 29
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);
    }
Esempio n. 30
0
 public void UnAssign(Pinky pinky)
 {
     this.callback[(int)pinky] = "SimDoNothing";
     this.soundID[(int)pinky]  = 0;
 }