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


C# IGameState类代码示例

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


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


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