コード例 #1
0
        public override GameState Operate(GameState currentState)
        {
            GameState newState = currentState.Copy();
            IEnumerable <PathGraphVertex> path = PathGraph.FindShortestPath(currentState.Position, Game.Player.Position, false);
            float length   = PathGraph.GetLengthOfPath(path);
            float duration = length / Human.RunSpeed;

            newState.AddTime(TimeSpan.FromSeconds(duration));
            newState.Position = Game.Player.Position;
            newState.Damage  -= Game.Player.Health;
            newState.Health  -= Game.Player.Health * 0.9f;
            bool one = false;

            for (int i = 0; i < newState.QuarterStates.Length; i++)
            {
                if (newState.QuarterStates[i].Ownership == QuarterOwnership.His)
                {
                    if (one)
                    {
                        newState.QuarterStates[i].Ownership         = QuarterOwnership.Empty;
                        newState.QuarterStates[i].OwnershipDuration = TimeSpan.Zero;
                    }
                    one = true;
                }
            }
            return(newState);
        }
コード例 #2
0
        public override GameState Operate(GameState currentState)
        {
            IEnumerable <PathGraphVertex> path = PathGraph.FindShortestPath(currentState.Position, actionObject.Position, false);
            float     length   = PathGraph.GetLengthOfPath(path);
            GameState newState = currentState.Copy();
            float     duration = length / Human.RunSpeed;

            newState.AddTime(TimeSpan.FromSeconds(duration));
            newState.Position = actionObject.Position;
            return(newState);
        }
コード例 #3
0
ファイル: TakeBoxOperation.cs プロジェクト: havri/ActionGame
        public override GameState Operate(GameState currentState)
        {
            IEnumerable <PathGraphVertex> path = PathGraph.FindShortestPath(currentState.Position, box.Position, false);
            float     length   = PathGraph.GetLengthOfPath(path);
            GameState newState = currentState.Copy();
            float     duration = length / Human.RunSpeed;

            newState.AddTime(TimeSpan.FromSeconds(duration));
            if (box is ToolBox)
            {
                GunType gunType = Game.BoxDefaultGuns[Game.Random.Next(Game.BoxDefaultGuns.Count)];
                newState.Damage += gunType.Damage * gunType.DefaultBulletCount;
            }
            else
            {
                newState.Health = 100;
            }
            newState.Position = box.Position;
            return(newState);
        }