Пример #1
0
        /*
         * public void ClearFogOfWar() {
         *      int viewRange = _buildingData.ViewRange;
         *
         *      for (int x = -viewRange + Position.X; x <= viewRange + Position.X; x++) {
         *              for (int y = -viewRange + Position.Y; y <= viewRange + Position.Y; y++) {
         *                      if (x < 0 || y < 0 || x > _map.Width - 1 || y > _map.Height - 1) {
         *                              continue;
         *                      }
         *                      _map.FogOfWar[x, y] = false;
         *              }
         *      }
         * }
         */


        /// <summary>
        /// manage building
        /// there are buildings which can shoot - some ai
        /// </summary>
        public void DoAI()
        {
            if (_bStatus != null)
            {
                if (_bStatus.DoTurn())
                {
                    this.state = BuildingState.normal;
                }
            }
            if (this.State == BuildingState.normal)
            {
                if (this.BuildingData.FirePower == 0)
                {
                    return;
                }
                if (roundToReload > 0)
                {
                    // reload time - cant shoot.
                    roundToReload--;
                    return;
                }
                if (FindNearestTargetInFireRange(out attacked))
                {
                    /*
                     * actions for looking for target, shooting
                     *
                     */
                    TryAttack(attacked);
                    roundToReload = BuildingData.__ReloadTime;
                }
            }
        }