当前位置: 首页>>代码示例>>C#>>正文


C# GameMaster.setupPlay方法代码示例

本文整理汇总了C#中GameMaster.setupPlay方法的典型用法代码示例。如果您正苦于以下问题:C# GameMaster.setupPlay方法的具体用法?C# GameMaster.setupPlay怎么用?C# GameMaster.setupPlay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameMaster的用法示例。


在下文中一共展示了GameMaster.setupPlay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MouseClicked

        public void MouseClicked(int x, int y, GameMaster sender)
        {
            Rectangle mouseClickRect = new Rectangle(x, y, 10, 10);

            Rectangle backButtonRect = new Rectangle((int)(Width * 0.009765625), (int)Height - (int)(Height * 0.104167), (int)(Width * 0.048828125), (int)(Height * 0.065104167));
            Rectangle playButtonRect = new Rectangle((int)Width - (int)(Width * 0.048828125) - (int)(Width * 0.009765625), (int)Height - (int)(Height * 0.104167), (int)(Width * 0.048828125), (int)(Height * 0.065104167));

            Rectangle prevPlayerRect = new Rectangle((int)(Width * 0.009765625), (int)(Height * 0.013020833), (int)(Width * 0.048828125), (int)(Height * 0.065104167));
            Rectangle nextPlayerRect = new Rectangle((int)Width - (int)(Width * 0.048828125) - (int)(Width * 0.009765625), (int)(Height * 0.013020833), (int)(Width * 0.048828125), (int)(Height * 0.065104167));

            Rectangle leftControllerRect = new Rectangle(screenCenter.X - (int)(Width * 0.17578125), (int)(Height * 0.325520833), (int)(Width * 0.048828125), (int)(Height * 0.065104167));
            Rectangle rightControllerRect = new Rectangle(screenCenter.X + (int)(Width * 0.126953125), (int)(Height * 0.325520833), (int)(Width * 0.048828125), (int)(Height * 0.065104167));

            Rectangle leftGhostRect = new Rectangle(screenCenter.X - (int)(Width * 0.17578125), (int)(Height * 0.7161458333), (int)(Width * 0.048828125), (int)(Height * 0.065104167));
            Rectangle rightGhostRect = new Rectangle(screenCenter.X + (int)(Width * 0.126953125), (int)(Height * 0.7161458333), (int)(Width * 0.048828125), (int)(Height * 0.065104167));

            if (mouseClickRect.Intersects(backButtonRect))
            {
                players = null;
                sender.GraphicsDevice.Clear(Color.Black);
                sender.screenNumber = 1;
            }

            else if (mouseClickRect.Intersects(playButtonRect))
            {
                sender.GraphicsDevice.Clear(Color.Black);
                sender.setupPlay();
                sender.screenNumber = 3;
                sender.gameState = GameMaster.GameState.Playing;

            }

            else if (mouseClickRect.Intersects(leftControllerRect))
            {
                if (players[inFocusScreen].controllerType == ControllerTypes.Xbox)
                {
                    players[inFocusScreen].controllerType = ControllerTypes.Keyboard;
                }

                else if (players[inFocusScreen].controllerType == ControllerTypes.Keyboard)
                {
                    players[inFocusScreen].controllerType = ControllerTypes.GhostAI;
                }

                else if (players[inFocusScreen].controllerType == ControllerTypes.GhostAI || players[inFocusScreen].controllerType == ControllerTypes.PacAI)
                {
                    players[inFocusScreen].controllerType = ControllerTypes.Xbox;
                }
            }

            else if (mouseClickRect.Intersects(rightControllerRect))
            {
                if (players[inFocusScreen].controllerType == ControllerTypes.Xbox)
                {
                    players[inFocusScreen].controllerType = ControllerTypes.GhostAI;
                }

                else if (players[inFocusScreen].controllerType == ControllerTypes.Keyboard)
                {
                    players[inFocusScreen].controllerType = ControllerTypes.Xbox;
                }

                else if (players[inFocusScreen].controllerType == ControllerTypes.GhostAI || players[inFocusScreen].controllerType == ControllerTypes.PacAI)
                {
                    players[inFocusScreen].controllerType = ControllerTypes.Keyboard;
                }
            }

            else if (mouseClickRect.Intersects(prevPlayerRect))
            {
                if (inFocusScreen == 0)
                {
                    inFocusScreen = players.Count()-1;
                }
                else
                {
                    inFocusScreen--;
                }
            }

            else if (mouseClickRect.Intersects(nextPlayerRect))
            {
                if (inFocusScreen == players.Count()-1)
                {
                    inFocusScreen = 0;
                }
                else
                {
                    inFocusScreen++;
                }
            }

            else if (mouseClickRect.Intersects(leftGhostRect))
            {
                players[inFocusScreen].IsGhost = !players[inFocusScreen].IsGhost;
            }

            else if (mouseClickRect.Intersects(rightGhostRect))
            {
                players[inFocusScreen].IsGhost = !players[inFocusScreen].IsGhost;
//.........这里部分代码省略.........
开发者ID:EphemeralGeek,项目名称:Pacman,代码行数:101,代码来源:PlayerSetup.cs


注:本文中的GameMaster.setupPlay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。