Example #1
0
        public void UpdateSeeAreaTest()
        {
            {
                bool[,] see = new bool[GameConstant.FieldSize, GameConstant.FieldSize];

                for (int x = 0; x < 100; x++)
                {
                    for (int y = 0; y < 100; y++)
                    {
                        see[x, y] = false;
                    }
                }

                var myUnits = new List <IUnit>();
                myUnits.Add(new Unit(UnitType.Worker, -1, new Point(0, 0)));
                Ofuton.UpdateSeeArea(see, myUnits);
                for (int y = 0; y < 100; y++)
                {
                    for (int x = 0; x < 100; x++)
                    {
                        if (x + y <= 4)
                        {
                            Assert.IsTrue(see[x, y]);
                        }
                        else
                        {
                            Assert.IsFalse(see[x, y]);
                        }
                    }
                }
            }

            {
                bool[,] see = new bool[GameConstant.FieldSize, GameConstant.FieldSize];
                var myUnits = new List <IUnit>();
                myUnits.Add(new Unit(UnitType.Worker, -1, new Point(50, 50)));
                Ofuton.UpdateSeeArea(see, myUnits);
                for (int y = 0; y < 100; y++)
                {
                    for (int x = 0; x < 100; x++)
                    {
                        if (Math.Abs(x - 50) + Math.Abs(y - 50) <= 4)
                        {
                            Assert.IsTrue(see[x, y]);
                        }
                        else
                        {
                            Assert.IsFalse(see[x, y]);
                        }
                    }
                }
            }
        }