Пример #1
0
 public void RemoveSupplyingRoutePoint(RoutePoint routePoint)
 {
     if (this.SupplyingRoutePoints != null)
     {
         this.SupplyingRoutePoints.Remove(routePoint);
     }
 }
Пример #2
0
        public bool IsEnough(Point position, int food)
        {
            RoutePoint point = null;

            this.RouteArea.TryGetValue(position, out point);
            return((point != null) && this.IsEnough(point.ConsumptionRate, food));
        }
Пример #3
0
        public void Extend(Point p)
        {
            RoutePoint point = new RoutePoint();

            point.Position = p;
            TerrainDetail terrainDetailByPosition = base.Scenario.GetTerrainDetailByPosition(p);

            if (this.RoutePoints.Count <= 0)
            {
                point.Index             = 0;
                point.PreviousDirection = SimpleDirection.None;
                point.Direction         = SimpleDirection.None;
                point.ConsumptionRate   = terrainDetailByPosition.RoutewayConsumptionRate * this.BelongedFaction.RateOfRoutewayConsumption;
                point.BuildFundCost     = (int)(terrainDetailByPosition.RoutewayBuildFundCost * this.StartArchitecture.RateOfRoutewayBuildFundCost);
                point.ActiveFundCost    = terrainDetailByPosition.RoutewayActiveFundCost;
                point.BuildWorkCost     = terrainDetailByPosition.RoutewayBuildWorkCost;
            }
            else
            {
                point.Index = this.LastPoint.Index + 1;
                int num  = p.X - this.LastPoint.Position.X;
                int num2 = p.Y - this.LastPoint.Position.Y;
                switch (num)
                {
                case -1:
                    this.LastPoint.Direction = SimpleDirection.Left;
                    break;

                case 0:
                    switch (num2)
                    {
                    case -1:
                        this.LastPoint.Direction = SimpleDirection.Up;
                        break;

                    case 1:
                        this.LastPoint.Direction = SimpleDirection.Down;
                        break;
                    }
                    break;

                case 1:
                    this.LastPoint.Direction = SimpleDirection.Right;
                    break;
                }
                point.PreviousDirection = this.LastPoint.Direction;
                point.Direction         = SimpleDirection.None;
                point.ConsumptionRate   = this.LastPoint.ConsumptionRate + (terrainDetailByPosition.RoutewayConsumptionRate * this.BelongedFaction.RateOfRoutewayConsumption);
                point.BuildFundCost     = this.LastPoint.BuildFundCost + ((int)(terrainDetailByPosition.RoutewayBuildFundCost * this.StartArchitecture.RateOfRoutewayBuildFundCost));
                point.ActiveFundCost    = this.LastPoint.ActiveFundCost + terrainDetailByPosition.RoutewayActiveFundCost;
                point.BuildWorkCost     = terrainDetailByPosition.RoutewayBuildWorkCost;
            }
            point.BelongedRouteway = this;
            this.RoutePoints.AddLast(point);
            if (this.LastActivePointIndex >= point.Index)
            {
                this.BelongedFaction.AddPositionInformation(p, GlobalVariables.RoutewayInformationLevel);
            }
            base.Scenario.MapTileData[p.X, p.Y].AddTileRouteway(this);
        }
Пример #4
0
 private void AddRoutePointArea(RoutePoint routePoint)
 {
     GameArea area = GameArea.GetViewArea(routePoint.Position, this.Radius, true, base.Scenario, this.BelongedFaction);
     foreach (Point point in area.Area)
     {
         if (!base.Scenario.PositionOutOfRange(point) && !this.RouteArea.ContainsKey(point))
         {
             this.RouteArea.Add(point, routePoint);
             base.Scenario.MapTileData[point.X, point.Y].AddSupplyingRoutePoint(routePoint);
         }
     }
 }
Пример #5
0
 public void AddSupplyingRoutePoint(RoutePoint routePoint)
 {
     if (this.SupplyingRoutePoints == null)
     {
         this.SupplyingRoutePoints = new List <RoutePoint>();
     }
     if (this.SupplyingRoutePoints.IndexOf(routePoint) >= 0)
     {
         this.SupplyingRoutePoints.Remove(routePoint);
     }
     this.SupplyingRoutePoints.Add(routePoint);
 }
Пример #6
0
 public void LoadRoutePointsFromString(string points)
 {
     char[]   separator = new char[] { ' ', '\n', '\r', '\t' };
     string[] strArray  = points.Split(separator, StringSplitOptions.RemoveEmptyEntries);
     this.RoutePoints.Clear();
     for (int i = 0; i < strArray.Length; i += 2)
     {
         RoutePoint point = new RoutePoint();
         point.Position = new Point(int.Parse(strArray[i]), int.Parse(strArray[i + 1]));
         this.RoutePoints.AddLast(point);
     }
 }
Пример #7
0
        private void AddRoutePointArea(RoutePoint routePoint)
        {
            GameArea area = GameArea.GetViewArea(routePoint.Position, this.Radius, true, base.Scenario, this.BelongedFaction);

            foreach (Point point in area.Area)
            {
                if (!base.Scenario.PositionOutOfRange(point) && !this.RouteArea.ContainsKey(point))
                {
                    this.RouteArea.Add(point, routePoint);
                    base.Scenario.MapTileData[point.X, point.Y].AddSupplyingRoutePoint(routePoint);
                }
            }
        }
Пример #8
0
        private void RemoveRoutePointArea(RoutePoint routePoint)
        {
            GameArea area = GameArea.GetArea(routePoint.Position, this.Radius, true);

            foreach (Point point in area.Area)
            {
                RoutePoint point2 = null;
                this.RouteArea.TryGetValue(point, out point2);
                if (point2 == routePoint)
                {
                    this.RouteArea.Remove(point);
                    base.Scenario.MapTileData[point.X, point.Y].RemoveSupplyingRoutePoint(routePoint);
                }
            }
        }
Пример #9
0
 public void ReGenerateRoutePointArea()
 {
     foreach (Point point in this.RouteArea.Keys)
     {
         RoutePoint point2 = null;
         this.RouteArea.TryGetValue(point, out point2);
         if (point2 != null)
         {
             base.Scenario.MapTileData[point.X, point.Y].RemoveSupplyingRoutePoint(point2);
         }
     }
     this.RouteArea.Clear();
     foreach (RoutePoint point2 in this.RoutePoints)
     {
         if (point2.Index <= this.LastActivePointIndex)
         {
             this.AddRoutePointArea(point2);
         }
     }
 }
Пример #10
0
 private void RemoveRoutePointArea(RoutePoint routePoint)
 {
     GameArea area = GameArea.GetArea(routePoint.Position, this.Radius, true);
     foreach (Point point in area.Area)
     {
         RoutePoint point2 = null;
         this.RouteArea.TryGetValue(point, out point2);
         if (point2 == routePoint)
         {
             this.RouteArea.Remove(point);
             base.Scenario.MapTileData[point.X, point.Y].RemoveSupplyingRoutePoint(routePoint);
         }
     }
 }
Пример #11
0
 public void LoadRoutePointsFromString(string points)
 {
     char[] separator = new char[] { ' ', '\n', '\r', '\t' };
     string[] strArray = points.Split(separator, StringSplitOptions.RemoveEmptyEntries);
     this.RoutePoints.Clear();
     for (int i = 0; i < strArray.Length; i += 2)
     {
         RoutePoint point = new RoutePoint();
         point.Position = new Point(int.Parse(strArray[i]), int.Parse(strArray[i + 1]));
         this.RoutePoints.AddLast(point);
     }
 }
Пример #12
0
        public void Extend(Point p)
        {
            RoutePoint point = new RoutePoint();
            point.Position = p;
            TerrainDetail terrainDetailByPosition = base.Scenario.GetTerrainDetailByPosition(p);
            if (this.RoutePoints.Count <= 0)
            {
                point.Index = 0;
                point.PreviousDirection = SimpleDirection.None;
                point.Direction = SimpleDirection.None;
                point.ConsumptionRate = terrainDetailByPosition.RoutewayConsumptionRate * this.BelongedFaction.RateOfRoutewayConsumption;
                point.BuildFundCost = (int) (terrainDetailByPosition.RoutewayBuildFundCost * this.StartArchitecture.RateOfRoutewayBuildFundCost);
                point.ActiveFundCost = terrainDetailByPosition.RoutewayActiveFundCost;
                point.BuildWorkCost = terrainDetailByPosition.RoutewayBuildWorkCost;
            }
            else
            {
                point.Index = this.LastPoint.Index + 1;
                int num = p.X - this.LastPoint.Position.X;
                int num2 = p.Y - this.LastPoint.Position.Y;
                switch (num)
                {
                    case -1:
                        this.LastPoint.Direction = SimpleDirection.Left;
                        break;

                    case 0:
                        switch (num2)
                        {
                            case -1:
                                this.LastPoint.Direction = SimpleDirection.Up;
                                break;

                            case 1:
                                this.LastPoint.Direction = SimpleDirection.Down;
                                break;
                        }
                        break;

                    case 1:
                        this.LastPoint.Direction = SimpleDirection.Right;
                        break;
                }
                point.PreviousDirection = this.LastPoint.Direction;
                point.Direction = SimpleDirection.None;
                point.ConsumptionRate = this.LastPoint.ConsumptionRate + (terrainDetailByPosition.RoutewayConsumptionRate * this.BelongedFaction.RateOfRoutewayConsumption);
                point.BuildFundCost = this.LastPoint.BuildFundCost + ((int) (terrainDetailByPosition.RoutewayBuildFundCost * this.StartArchitecture.RateOfRoutewayBuildFundCost));
                point.ActiveFundCost = this.LastPoint.ActiveFundCost + terrainDetailByPosition.RoutewayActiveFundCost;
                point.BuildWorkCost = terrainDetailByPosition.RoutewayBuildWorkCost;
            }
            point.BelongedRouteway = this;
            this.RoutePoints.AddLast(point);
            if (this.LastActivePointIndex >= point.Index)
            {
                this.BelongedFaction.AddPositionInformation(p, GlobalVariables.RoutewayInformationLevel);
            }
            base.Scenario.MapTileData[p.X, p.Y].AddTileRouteway(this);
        }
Пример #13
0
 public void RemoveSupplyingRoutePoint(RoutePoint routePoint)
 {
     if (this.SupplyingRoutePoints != null)
     {
         this.SupplyingRoutePoints.Remove(routePoint);
     }
 }
Пример #14
0
 public void AddSupplyingRoutePoint(RoutePoint routePoint)
 {
     if (this.SupplyingRoutePoints == null)
     {
         this.SupplyingRoutePoints = new List<RoutePoint>();
     }
     if (this.SupplyingRoutePoints.IndexOf(routePoint) >= 0)
     {
         this.SupplyingRoutePoints.Remove(routePoint);
     }
     this.SupplyingRoutePoints.Add(routePoint);
 }