コード例 #1
0
ファイル: UnitTests.cs プロジェクト: Think-Jumper/everland
        public void Check_Unit_State_Transitions()
        {
            var world = WorldService.Create(200, 200);

            var spearMan = new Unit
                               {
                                   CurrentUnitState = new Spearman(),
                                   Location = world.GetHex(50, 50)
                               };

            spearMan.ExecuteTurn(new MoveStateContext()
            {
                Source = spearMan,
                Target = world.GetHex(70,70)
            });

            while(spearMan.Location.X != 70 && spearMan.Location.Y != 70)
            {
                var x = spearMan.Location.X;
                var y = spearMan.Location.Y;
                spearMan.ExecuteTurn(new ContinueStateContext());

                Assert.AreNotEqual(x, spearMan.Location.X);
                Assert.AreNotEqual(y, spearMan.Location.Y);
            }

            Assert.AreEqual(70, spearMan.Location.X);
            Assert.AreEqual(70, spearMan.Location.Y);
        }
コード例 #2
0
ファイル: Nation.cs プロジェクト: Think-Jumper/everland
        public virtual void AddUnit(Unit unit)
        {
            if(Units == null)
                Units = new List<Unit>();

            unit.Nation = this;
            Units.Add(unit);
        }
コード例 #3
0
ファイル: PathFinder.cs プロジェクト: Think-Jumper/everland
        //TODO: inject IPathCalculator
        public static IList<Hex> CalculatePath(Hex start, Hex end, Unit unit)
        {
            // var pathFinder = IoC.Resolve<>()
            var currentHex = start;
            var path = new List<Hex>();
            while(!currentHex.IsAdjacentTo(end))
            {
                // need to inject the pathfinder here, which takes into account what a unit can traverse
                // and relative terrain cost, also avoiding enemy units
                currentHex = currentHex.FindClosestSurroundingHexTo(end);
                path.Add(currentHex);
            }

            return path;
        }
コード例 #4
0
ファイル: Hex.cs プロジェクト: Think-Jumper/everland
 public virtual bool IsTraversable(Unit unit)
 {
     return true;
 }