Exemplo n.º 1
0
        public void update(GameTime gTime, Police sp)
        {
            for (int i = 0; i < Game1.n.Count(); i++)
            { //check to make sure they dont overlap
                Vector2 pushDirection = Vector2.Zero;
                float   weight        = .5f;

                if (Game1.n[i] != null && sp.area.Intersects(Game1.n[i].area) &&
                    sp.location != Game1.n[i].location)
                {
                    pushDirection = sp.location - Game1.n[i].location;
                    Vector2.Normalize(ref pushDirection, out pushDirection);

                    //push away
                    //weight *= (1 -(float)Animal.ReactionDistance / aiParams.SeparationDistance);
                    weight        *= (1 - (float)ReactionDistance / SeparationDistance);
                    pushDirection *= weight;

                    //reacted = true;
                    sp.movement = pushDirection;
                }
                if (Game1.n[i] != null && sp.area.Intersects(Game1.p.area) &&
                    sp.location != Game1.p.location)
                {
                    pushDirection = sp.location - Game1.p.location;
                    Vector2.Normalize(ref pushDirection, out pushDirection);

                    //push away
                    //weight *= (1 -(float)Animal.ReactionDistance / aiParams.SeparationDistance);
                    weight        *= (1 - (float)ReactionDistance / SeparationDistance);
                    pushDirection *= weight;

                    //reacted = true;
                    sp.movement = pushDirection;
                }
            }
        }
Exemplo n.º 2
0
 public Police_Movement(List <Vector2> commands, Police p)
 {
     Commands = commands;
     this.p   = p;
 }