Exemple #1
0
        public void SerchLeaf()
        {
            if (IsFear)
            {
                Brain.PushState(() => { RunAway(); });
            }
            if (TargetLeaf != null)
            {
                Brain.PushState(() => { GoHomeWithLeaf(); });
            }

            ChFear();
            Control foundLeaf = FoundLeaf();

            if (foundLeaf == null)
            {
                Serch();
            }
            else
            {
                GoOneStepToTarget(Speed);
                Point foundLeafCentre = SupportFunc.getCentre(foundLeaf.Location, foundLeaf.Width, foundLeaf.Height);
                if (!InTarget())
                {
                    Target = foundLeafCentre;
                }

                if (SupportFunc.DotInSqrt(ThisAnt.Location, ThisAnt.Width, ThisAnt.Height, foundLeafCentre, 5))
                {
                    TargetLeaf = foundLeaf;
                }
            }
        }
Exemple #2
0
 private bool InHome()
 {
     if (SupportFunc.DotInSqrt(Home.Location, Home.Width, Home.Height, ThisAnt.Location, -5))
     {
         return(true);
     }
     return(false);
 }