• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IGameState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IGameState的典型用法代码示例。如果您正苦于以下问题:C# IGameState类的具体用法?C# IGameState怎么用?C# IGameState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IGameState类属于命名空间,在下文中一共展示了IGameState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: consumeEvent

        public bool consumeEvent(IEvent e)
        {
            if (currentState.getTransitionableState().Keys.Contains(e.getEventName()))
            {
                LOG.Info("Consuming game event name=" + e.getEventName());
                this.currentState = (IGameState)this.currentState.getTransitionableState()[e.getEventName()];
                this.currentState.run(e);
                return true;
            }
            else if (currentState.isSubmachineEvent(e))
            {
                // Transport event to submachine like PlayerMachine or BoardMachine
                LOG.Info("Transport submachine event with name=" + e.getEventName());
                try
                {
                    currentState.submachineConsumeEvent(e);
                }
                catch (EventNotAcceptableException ex)
                {
                    return false;
                }
                return true;
            }
            else
            {
                // Reject unvalid event
                LOG.Info("Unvalid event in current state (" + this.currentState.getStateName() + ") event name=" + e.getEventName());
                return false;
            }

        }
开发者ID:hoangchunghien,项目名称:ChineseChessLearning,代码行数:31,代码来源:GameStateMachine.cs


示例2: SpecificHandle

        public override void SpecificHandle(IGameState previous, IGameState next)
        {
            //if (!_optionMenuControls.IsCheckBoxAvailable())
            //    return;

            var checkboxCopy = _optionMenuControls.CreateCheckboxCopy();
        }
开发者ID:Mattish,项目名称:Brodee,代码行数:7,代码来源:CheckBoxAttemptHandler.cs


示例3: execute

        protected override void execute()
        {
            _log = Context.Get<IScriptLog>();
            _gameState = Context.Get<IGameState>();

            Pause(Token);
        }
开发者ID:joemcbride,项目名称:outlander,代码行数:7,代码来源:PauseTokenHandler.cs


示例4: SpecificHandle

        public override void SpecificHandle(IGameState previous, IGameState next)
        {
            //if (!_optionMenuControls.IsSliderAvailable())
            //    return;

            var sliderCopy = _optionMenuControls.CreateSliderCopy();
        }
开发者ID:Mattish,项目名称:Brodee,代码行数:7,代码来源:CreateSliderHandler.cs


示例5: DoublePipe

 public DoublePipe(IGameState gameState, Game1 game)
 {
     myGame = game;
     pipeSprite = TileSpriteFactory.CreateDoublePipeSprite();
     isWarpPipe = true;
     this.gameState = gameState;
 }
开发者ID:Bartholomew-m134,项目名称:BuckeyeGameEngine,代码行数:7,代码来源:DoublePipe.cs


示例6: ChangeState

 /// <summary>
 /// Removes the current running state and insert the state provide.
 /// </summary>
 /// <param name="gameState">State of the game.</param>
 public void ChangeState(IGameState gameState)
 {
     PopStack();
     
     gameState.LoadContent();
     _gameStates.Push(gameState);
 }
开发者ID:swallentin,项目名称:XNA.Pong,代码行数:11,代码来源:GameManager.cs


示例7: RoomState

        public RoomState(IGameState previousState, IGameStateService gameStateService, IGuiService guiService,
                        IInputService inputService, GraphicsDeviceManager graphics,
                        ContentManager content)
        {
            this.gameStateService = gameStateService;
            this.guiService = guiService;
            this.inputService = inputService;
            this.graphics = graphics;
            this.content = content;

            this.previousState = previousState;
            this.mouseMove = new MouseMoveDelegate(mouseMoved);

            this.teamA = new List<Peer>();
            this.teamB = new List<Peer>();

            playerIDLabels = new List<LabelControl>();
            panelVisibility = new List<bool>();
            roomScreen = new Screen(1184, 682);

            Game1.main_console.StartEvent += Start;

            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);

            LoadContent(roomScreen, content);
        }
开发者ID:edwardsamuel,项目名称:Gunbond,代码行数:26,代码来源:RoomState.cs


示例8: AGSInteractions

        public AGSInteractions (IInteractions defaultInteractions, IObject obj, IGameState state)
		{
            _events = new ConcurrentDictionary<string, IEvent<ObjectEventArgs>>();
            _inventoryEvents = new ConcurrentDictionary<string, IEvent<InventoryInteractEventArgs>>();
            var defaultInteractionEvent = new AGSInteractionEvent<ObjectEventArgs>(
                new List<IEvent<ObjectEventArgs>>(), DEFAULT, obj, state);
            var defaultInventoryEvent = new AGSInteractionEvent<InventoryInteractEventArgs>(
                new List<IEvent<InventoryInteractEventArgs>>(), DEFAULT, obj, state);
            _events.TryAdd(DEFAULT, defaultInteractionEvent);
            _inventoryEvents.TryAdd(DEFAULT, defaultInventoryEvent);

            _factory = verb =>
            {
                List<IEvent<ObjectEventArgs>> interactions = new List<IEvent<ObjectEventArgs>> { defaultInteractionEvent };
                if (defaultInteractions != null)
                {
                    interactions.Add(defaultInteractions.OnInteract(verb));
                    if (verb != DEFAULT) interactions.Add(defaultInteractions.OnInteract(DEFAULT));
                }
                return new AGSInteractionEvent<ObjectEventArgs>(interactions, verb, obj, state);
            };
            _inventoryFactory = verb =>
            {
                List<IEvent<InventoryInteractEventArgs>> interactions = new List<IEvent<InventoryInteractEventArgs>> { defaultInventoryEvent };
                if (defaultInteractions != null)
                {
                    interactions.Add(defaultInteractions.OnInventoryInteract(verb));
                    if (verb != DEFAULT) interactions.Add(defaultInteractions.OnInventoryInteract(DEFAULT));
                }
                return new AGSInteractionEvent<InventoryInteractEventArgs>(interactions, verb, obj, state);
            };
		}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:32,代码来源:AGSInteractions.cs


示例9: HandleTrade

        public ITrade HandleTrade(IGameState state, ITrade offer, int proposingPlayerId)
        {
            // accept if convert extras to needed and opponent < 7 points
            List<Resource> extras = new List<Resource>();
            foreach (Resource r in Enum.GetValues(typeof(Resource)))
            {
                int extra = state.GetOwnResources().Count(res => res == r) - 1;
                for (int i = 0; i < extra; i++) extras.Add(r);
            }

            // good offer?
            var valid = offer.Give.Where(o => o.All(r => o.Count(cur => cur == r) <= extras.Count(e => e == r)));

            if (valid.Count() == 0) return offer.Decline();

            // take the one with least cards to give, and then by most duplicates
            List<Resource> bestGive = valid.OrderBy(o => o.Count)
                .ThenByDescending(o => state.GetOwnResources().Sum(r => state.GetOwnResources().Count(res => res == r)))
                .First();

            // find best "take" (cards we get) kind of the opposite of above
            List<Resource> bestTake = offer.Take.OrderBy(o => o.Count)
                .ThenBy(o => state.GetOwnResources().Sum(r => state.GetOwnResources().Count(res => res == r)))
                .First();

            return offer.Respond(bestGive, bestTake);
        }
开发者ID:rasmusgreve,项目名称:catan,代码行数:27,代码来源:StarterAgent.cs


示例10: AGSDialogFactory

		public AGSDialogFactory(IContainer resolver, IGameState gameState, IUIFactory ui, IObjectFactory obj)
		{
			_resolver = resolver;
			_gameState = gameState;
			_ui = ui;
			_object = obj;
		}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:7,代码来源:AGSDialogFactory.cs


示例11: Update

        public override TankUpdate Update(IGameState gameState)
        {
            TankUpdate tankUpdate = new TankUpdate();
            tankUpdate.TankColor = ConvertColorToHexString(Color.Blue);

            if (gameState.Foes.Any() && gameState.Goals.Any())
            {
                var target = gameState.Foes
                    .Where(foe => 1000 / GetDistanceFromTank(foe) >= 2)
                    .OrderBy(foe => GetDistanceToGoal(foe, gameState.Goals) + GetTimeToGoal(foe, gameState.Goals) + GetDistanceFromTank(foe))
                    .FirstOrDefault();

                if (target != null)
                {
                    tankUpdate.ShotTarget = target.Center;
                    ChangeBulletPower(target);
                    tankUpdate.Bullet = Bullet;
                }

                var x = (gameState.Foes.Max(foe => foe.X) + 9 * gameState.Goals.Last().X) / 10;
                var y = (gameState.Foes.Max(foe => foe.Y) + 9 * gameState.Goals.Last().Y) / 10;
                tankUpdate.MovementTarget = LocationProvider.GetLocation(x, y);
            }

            return tankUpdate;
        }
开发者ID:PretentiousGames,项目名称:towerDefense,代码行数:26,代码来源:FreezeTank.cs


示例12: GameStateManager

        public GameStateManager( Game game )
        {
            _game = game;

            _gameStates = new Dictionary<string,IGameState>();
            _currentGameState = null;
        }
开发者ID:BGCX261,项目名称:zombeeswarm-svn-to-git,代码行数:7,代码来源:GameStateManager.cs


示例13: Rollback

 public override void Rollback(IGameState state)
 {
     var s = state as ChessState;
     s.Castling = _Castling;
     RollbackMovePiece(From, To, state);
     RollbackMovePiece(RookFrom, RookTo, state);
 }
开发者ID:Maniulo,项目名称:GameWarden,代码行数:7,代码来源:Castling.cs


示例14: CalculateState

        public State CalculateState(Location a, IGameState state)
        {
            State s = new State();
            Location l;
            Tile t;
            for (int x = -radius; x <= radius; x++)
            {
                for (int y = -radius; y <= radius; y++)
                {
                    if (x == 0 && y == 0)
                        continue;

                    l = (a + new Location(y, x)) % new Location(state.Height, state.Width);
                    t = state[l];
                    if (t == Tile.Ant)
                    {
                        if(state.MyAnts.Contains(new Ant(l.Row, l.Col, state.MyAnts[0].Team)))
                            s.MyAnt = true;
                        else
                            s.EnemyAnt = true;
                    }
                    else if (t == Tile.Food)
                        s.Food = true;
                    else if (t == Tile.Hill)
                    {
                        if (state.MyHills.Contains(new AntHill(l.Row, l.Col, state.MyHills[0].Team)))
                            s.MyHill = true;
                        else
                            s.EnemyHill = true;
                    }
                }
            }
            s.AirSuperiority = state.MyAnts.Count > state.EnemyAnts.Count;
            return s;
        }
开发者ID:Lapixx,项目名称:CS-UU-KI2,代码行数:35,代码来源:MyBot.cs


示例15: InformState

 public InformState(string message, IGameState nextstate, Color color, bool isCard = false)
 {
     this.message = message;
     this.nextState = nextstate;
     this.color = color;
     this.isCard = isCard;
 }
开发者ID:roric32,项目名称:inferno,代码行数:7,代码来源:InformState.cs


示例16: Become

 public override void Become(IGameState prevState)
 {
     PuzzleBoardViewModel.StartPauseButtonCaption = "Game Over :-)";
     PuzzleBoardViewModel.PauseTimer();
     PuzzleBoardViewModel.FireGameCompleteMessage();
     base.Become(prevState);
 }
开发者ID:abdulbaruwa,项目名称:CrossSharp,代码行数:7,代码来源:GameFinishedState.cs


示例17: DrawGridCells

        private static void DrawGridCells(IGameState state)
        {
            GL.LineWidth(5.0f);
            var deltaX = 2.0f / (float)state.GridWidth;
            var deltaY = 2.0f / (float)state.GridHeight;
            var cell = new Box2D(0, 0, deltaX, deltaY);
            for (int u = 0; u < state.GridWidth; ++u)
            {
                for (int v = 0; v < state.GridHeight; ++v)
                {
                    cell.X = deltaX * u - 1.0f;
                    cell.Y = 1.0f - deltaY * (v + 1);
                    switch (state[u, v])
                    {
                        case FieldType.DIAMONT:
                            DrawDiamont(cell);
                            break;
                        case FieldType.CROSS:
                            DrawCross(cell);
                            break;
                        default: break;
                    }

                }
            }
        }
开发者ID:danielscherzer,项目名称:Framework,代码行数:26,代码来源:Visual.cs


示例18: Update

        public override TankUpdate Update(IGameState gameState)
        {
            TankUpdate tankUpdate = new TankUpdate();

            if (gameState.Foes.Any() && gameState.Goals.Any())
            {
                tankUpdate.ShotTarget = LocationProvider.GetLocation(_xTarget, _yTarget);
                ChangeBulletPower(tankUpdate.ShotTarget, gameState);

                var range = GetDistanceFromTank(LocationProvider.GetLocation(_xTarget, _yTarget)) + 1;
                if (Bullet.GetReloadTime((int)range) < 1000 || range < 100)
                {
                    tankUpdate.Bullet = Bullet;
                }
                else
                {
                    tankUpdate.Bullet = new Bullet();
                }

                UpdateMovementTarget(tankUpdate, gameState);
            }

            tankUpdate.TankColor = ConvertColorToHexString(Color.CornflowerBlue);

            return tankUpdate;
        }
开发者ID:PretentiousGames,项目名称:towerDefense,代码行数:26,代码来源:BoomTank.cs


示例19: AGSInventoryWindowComponent

		public AGSInventoryWindowComponent(IGameState state, IGameEvents gameEvents)
		{
			_state = state;
			_inventoryItems = new List<IObject> (20);
			_gameEvents = gameEvents;
			_gameEvents.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
		}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:7,代码来源:AGSInventoryWindowComponent.cs


示例20: PauseMenu

 public PauseMenu(IGameState prevGameState, Game1 game)
 {
     this.game = game;
     this.prevGameState = prevGameState;
     currentSelection = Selections.Resume;
     font = MenuSpriteFactory.CreateHUDFont();
 }
开发者ID:Bartholomew-m134,项目名称:BuckeyeGameEngine,代码行数:7,代码来源:PauseMenu.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IGatewayProviderService类代码示例发布时间:2022-05-24
下一篇:
C# IGameObject类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap