Example #1
0
        protected virtual int GetTurnCost(Point at, Point move)
        {
            int      cost     = int.MaxValue;
            AreaEnum tipeArea = map[at.X, at.Y].AreaType;

            switch (tipeArea)
            {
            case AreaEnum.LowDensity:
                cost = 1;
                break;

            case AreaEnum.MediumDensity:
                cost = 2;
                break;

            case AreaEnum.HighDensity:
                cost = 3;
                break;
            }
            BloodStream bs = map.IsInStream(at.X, at.Y);

            if (bs != null)
            {
                if (bs.Direction == BloodStreamDirection.EstWest)
                {
                    if (move.X == -1)
                    {
                        cost -= 2;
                    }
                    else if (move.X == 1)
                    {
                        cost += 2;
                    }
                }
                else if (bs.Direction == BloodStreamDirection.NorthSouth)
                {
                    if (move.Y == 1)
                    {
                        cost -= 2;
                    }
                    else if (move.Y == -1)
                    {
                        cost += 2;
                    }
                }
                else if (bs.Direction == BloodStreamDirection.SouthNorth)
                {
                    if (move.Y == -1)
                    {
                        cost -= 2;
                    }
                    else if (move.Y == 1)
                    {
                        cost += 2;
                    }
                }
                else if (bs.Direction == BloodStreamDirection.WestEst)
                {
                    if (move.X == 1)
                    {
                        cost -= 2;
                    }
                    else if (move.X == -1)
                    {
                        cost += 2;
                    }
                }
            }
            if (cost <= 0)
            {
                cost = 1;
            }
            return(cost);
        }