コード例 #1
0
        public override void Modify(IPanzer panzer)
        {
            var sections = _currentMap.Sections;
            var enemies  = _currentMap.LocationOfForces;

            var(positionX, positionY) = ModifyPosition(panzer.CurrentPosition, panzer.CurrentDirection);

            //Вышли за пределы карты
            if (positionX < 0 || _currentMap.Width <= positionX)
            {
                return;
            }
            if (positionY < 0 || _currentMap.Heigth <= positionY)
            {
                return;
            }

            //В секцию невозможно встать
            if (!sections[positionY, positionX].CanPositionTo)
            {
                return;
            }

            //Танка в области
            if (enemies[positionY, positionX] != null)
            {
                return;
            }

            enemies.MoveElement(
                new Position(panzer.CurrentPosition.X, panzer.CurrentPosition.Y),
                new Position(positionX, positionY));

            panzer.CurrentPosition = new Position(positionX, positionY);
        }
コード例 #2
0
 public PanzerBuilder(IPanzerCommander panzer)
 {
     if (panzer == null)
     {
         throw new ArgumentException("Panzer commander can't be null.", nameof(panzer));
     }
     _panzer = new Panzer(panzer);
 }
コード例 #3
0
        public override void Modify(IPanzer panzer)
        {
            var panzerLayer  = _currentMap.LocationOfForces;
            var sectionLayer = _currentMap.Sections;

            for (int i = 1; i <= BULLET_SPEED; i++)
            {
                var(positionX, positionY) = CalcPosition(panzer.CurrentPosition, panzer.CurrentDirection, i);

                //Вышли за пределы карты
                if (positionX < 0 || _currentMap.Width <= positionX)
                {
                    break;
                }
                if (positionY < 0 || _currentMap.Heigth <= positionY)
                {
                    break;
                }

                var enemy = panzerLayer[positionY, positionX] as Panzer;
                if (enemy != null && enemy.Health != 0)
                {
                    enemy.Health -= (short)panzer.Damage;
                    if (enemy.Health < 0)
                    {
                        enemy.Health = 0;
                    }
                    break;
                }

                var section = sectionLayer[positionY, positionX] as SectionBase;
                if (!section.CanBuletThrought)
                {
                    if (section.CanDestroy)
                    {
                        section.IsDestroy = true;
                    }
                    break;
                }
            }
        }
コード例 #4
0
 public override void Modify(IPanzer panzer)
 {
 }
コード例 #5
0
 public Intent(IPanzer panzer, IEnumerable <(double MillesecondsOnStep, CommanderCommand Command)> commandInfo)
コード例 #6
0
 public override void Modify(IPanzer panzer)
 {
     panzer.CurrentDirection = panzer.CurrentDirection.Next();
 }
コード例 #7
0
 public abstract void Modify(IPanzer panzer);