Esempio n. 1
0
        protected override bool OnEvaluate(IAgent agent, BlackboardMemory workingMemory)
        {
            Tank    t              = (Tank)agent;
            bool    hasStar        = false;
            float   nearestDist    = float.MaxValue;
            Vector3 nearestStarPos = Vector3.zero;

            foreach (var pair in Match.instance.GetStars())
            {
                Star s = pair.Value;
                if (s.IsSuperStar)
                {
                    hasStar        = true;
                    nearestStarPos = s.Position;
                    break;
                }
                else
                {
                    float dist = Functions.CalculatePathLength(t.CaculatePath(s.Position), t.Position, s.Position);
                    if (dist < nearestDist)
                    {
                        hasStar        = true;
                        nearestDist    = dist;
                        nearestStarPos = s.Position;
                    }
                }
            }
            if (hasStar)
            {
                workingMemory.SetValue((int)EBBKey.MovingTargetPos, nearestStarPos);
            }
            return(hasStar);
        }
Esempio n. 2
0
        public override bool IsTrue(IAgent agent)
        {
            Tank  t     = (Tank)agent;
            float dist  = Functions.CalculatePathLength(t.CaculatePath(new Vector3(0, 0, 0)), t.Position, new Vector3(0, 0, 0));
            float speed = 10f;
            float time  = dist / speed + 2 + dist / 30;
            float delta = Match.instance.RemainingTime - Match.instance.GlobalSetting.MatchTime / 2;

            return((delta > 0) && (delta <= time));
        }
Esempio n. 3
0
        public override bool IsTrue(IAgent agent)
        {
            Tank t = (Tank)agent;

            foreach (var pair in Match.instance.GetStars())
            {
                Star  s    = pair.Value;
                float dist = Functions.CalculatePathLength(t.CaculatePath(s.Position), t.Position, s.Position);
                if (dist <= (PhysicsUtils.MaxFieldSize * 0.03 * PhysicsUtils.MaxFieldSize * 0.03))
                {
                    return(true);
                }
            }
            return(false);
        }