Esempio n. 1
0
        public Point GetBaseCollectPoint()
        {
            CHelper = new CalcHelper(Engine.Map);
            List <Point> ar = new List <Point>();

            ar = CHelper.GetEmptyAround(BaseLoc);
            return(ar[Engine.rnd.Next(ar.Count)]);
        }
Esempio n. 2
0
        private Point GetApprochablePoint(bool[,] map, Point t)
        {
            CHelper = new CalcHelper(Engine.Map);
            List <Point> ES = CHelper.GetEmptyAround(t);

            if (ES.Count != 0)
            {
                List <Point> Accesible = new List <Point>();
                for (int i = 0; i < ES.Count; i++)
                {
                    if (CHelper.CalcShortestPath(Position, ES[i]) != null)
                    {
                        Accesible.Add(ES[i]);
                    }
                }
                if (Accesible.Count != 0)
                {
                    return(Accesible[Engine.rnd.Next(Accesible.Count)]);
                }
            }
            else
            {
                map[t.X, t.Y] = true;
                if (t.X - 1 >= 0 && !map[t.X - 1, t.Y])
                {
                    GetApprochablePoint(map, new Point(t.X - 1, t.Y));
                }
                if (t.Y - 1 >= 0 && !map[t.X, t.Y - 1])
                {
                    GetApprochablePoint(map, new Point(t.X, t.Y - 1));
                }
                if (t.X + 1 < Engine.MapSize && !map[t.X + 1, t.Y])
                {
                    GetApprochablePoint(map, new Point(t.X + 1, t.Y));
                }
                if (t.Y + 1 < Engine.MapSize && !map[t.X, t.Y + 1])
                {
                    GetApprochablePoint(map, new Point(t.X, t.Y + 1));
                }
            }
            return(new Point(0, 0));
        }
Esempio n. 3
0
 public override void Work()
 {
     if (Path.Count != 0)
     {
         Path.RemoveAt(Path.Count - 1);
         if (Path.Count - 1 >= 0)
         {
             this.Position = Path[Path.Count - 1];
         }
         if (!IsIdle)
         {
             Target = GetOreArround(this.Position);
         }
     }
     else if (IsIdle)
     {
         CalcHelper ch = new CalcHelper(Engine.Map);
         if (!ch.GetEmptyAround(BaseLoc).Contains(this.Position))
         {
             GetShortestPath(BaseLoc);
         }
     }
     else
     {
         if (Engine.Map[Target.X, Target.Y].ResourceAmmount >= CollectAmmount)
         {
             Engine.Map[Target.X, Target.Y].ResourceAmmount    -= CollectAmmount;
             Engine.Map[Target.X, Target.Y].AmmountOnTheGround += CollectAmmount;
         }
         else
         {
             Engine.Map[Target.X, Target.Y].AmmountOnTheGround += Engine.Map[Target.X, Target.Y].ResourceAmmount;
             Engine.Map[Target.X, Target.Y].ResourceAmmount     = 0;
             Engine.Map[Target.X, Target.Y].ContaintID          = 0;
             IsIdle = true;
         }
     }
 }
Esempio n. 4
0
        public List <Point> GetReachebleNearNotVisible()
        {
            CHelper = new CalcHelper(Engine.Map);
            List <Point> TilesToGo = new List <Point>();

            for (int i = 0; i < Engine.MapSize; i++)
            {
                for (int j = 0; j < Engine.MapSize; j++)
                {
                    if (Engine.Visible[i, j] == false)
                    {
                        List <Point> aux = CHelper.GetEmptyAround(new Point(i, j));
                        for (int q = 0; q < aux.Count; q++)
                        {
                            if (!TilesToGo.Contains(aux[q]) && aux[q] != this.Position && CHelper.CalcShortestPath(this.Position, aux[q]) != null)
                            {
                                TilesToGo.Add(aux[q]);
                            }
                        }
                    }
                }
            }
            return(TilesToGo);
        }