public SteeringBehaviours(Fighter entity)
        {
            this.fighter = entity;
            calculationMethod = CalculationMethods.WeightedTruncatedRunningSumWithPrioritisation;
            sphere = new Sphere(0.2f);
            XNAGame.Instance().Children.Add(sphere);
            wanderTarget = new Vector3(randomClamped(), randomClamped(), randomClamped());
            wanderTarget.Normalize();

            weights.Add(behaviour_type.allignment, 1.0f);
            weights.Add(behaviour_type.cohesion, 2.0f);
            weights.Add(behaviour_type.obstacle_avoidance, 20.0f);
            weights.Add(behaviour_type.wall_avoidance, 20.0f);
            weights.Add(behaviour_type.wander, 1.0f);
            weights.Add(behaviour_type.seek, 1.0f);
            weights.Add(behaviour_type.flee, 1.0f);
            weights.Add(behaviour_type.arrive, 1.0f);
            weights.Add(behaviour_type.pursuit, 1.0f);
            weights.Add(behaviour_type.offset_pursuit, 1.0f);
            weights.Add(behaviour_type.interpose, 1.0f);
            weights.Add(behaviour_type.hide, 1.0f);
            weights.Add(behaviour_type.evade, 0.01f);
            weights.Add(behaviour_type.follow_path, 1.0f);
            weights.Add(behaviour_type.separation, 1.0f);
        }
        public SteeringBehaviours(Fighter entity)
        {
            this.fighter = entity;
            calculationMethod = CalculationMethods.WeightedTruncatedRunningSumWithPrioritisation;
            sphere = new Sphere(0.2f);
            wanderSphere = new Sphere(1);
            wanderSphere.ShouldDraw = false;
            sphere.ShouldDraw = false;
            XNAGame.Instance().Children.Add(sphere);
            XNAGame.Instance().Children.Add(wanderSphere);

            wanderTarget = new Vector3(RandomClamped(), RandomClamped(), RandomClamped());
            wanderTarget.Normalize();
            wanderTarget *= Params.GetFloat("wander_radius");
        }
 public static void setUpArrive()
 {
     List<Entity> children = XNAGame.Instance().Children;
     Fighter leader = new Fighter();
     leader.pos = new Vector3(10, 20, 20);
     leader.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.arrive);
     leader.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
     leader.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
     leader.targetPos = new Vector3(0, 100, -450);
     children.Add(leader);
     XNAGame.Instance().Leader = leader;
     Ground ground = new Ground();
     children.Add(ground);
     XNAGame.Instance().Ground = ground;
     foreach (Entity child in children)
     {
         child.pos.Y += 100;
     }
 }
        public static void setUpCylonchase()
        {
            List<Entity> children = XNAGame.Instance().Children;
            Fighter cylonScout = new Fighter("models/Cylon/CylonRaider");
            cylonScout.pos = new Vector3(10, 20, 20);
            cylonScout.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.seek);
            cylonScout.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            cylonScout.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            cylonScout.targetPos = new Vector3(0, 100, -450);
            children.Add(cylonScout);
            XNAGame.Instance().Leader = cylonScout;

            // Add some Obstacles

            Obstacle o = new Obstacle(4);
            o.pos = new Vector3(0, 10, -10);
            children.Add(o);

            o = new Obstacle(17);
            o.pos = new Vector3(-10, 16, -80);
            children.Add(o);

            o = new Obstacle(10);
            o.pos = new Vector3(10, 15, -120);
            children.Add(o);

            o = new Obstacle(12);
            o.pos = new Vector3(5, -10, -150);
            children.Add(o);

            o = new Obstacle(20);
            o.pos = new Vector3(-2, 5, -200);
            children.Add(o);

            o = new Obstacle(10);
            o.pos = new Vector3(-25, -20, -250);
            children.Add(o);

            o = new Obstacle(10);
            o.pos = new Vector3(20, -20, -250);
            children.Add(o);

            o = new Obstacle(35);
            o.pos = new Vector3(-10, -30, -300);
            children.Add(o);

            // Now make a fleet
            int fleetSize = 5;
            float xOff = 6;
            float zOff = 6;
            for (int i = 2; i < fleetSize; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    float z = (i - 1) * +zOff;
                    Fighter fleet = new Fighter();
                    fleet.Leader = cylonScout;
                    fleet.offset = new Vector3((xOff * (-i / 2.0f)) + (j * xOff), 0, z);
                    fleet.pos = cylonScout.pos + fleet.offset;
                    fleet.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.offset_pursuit);
                    fleet.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
                    fleet.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
                    children.Add(fleet);
                }
            }

            Fighter camFighter = new Fighter();
            camFighter.Leader = cylonScout;
            camFighter.pos = new Vector3(0, 15, fleetSize * zOff);
            camFighter.offset = new Vector3(0, 5, fleetSize * zOff);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.offset_pursuit);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            XNAGame.Instance().CamFighter = camFighter;
            children.Add(camFighter);

            Ground ground = new Ground();
            children.Add(ground);
            XNAGame.Instance().Ground = ground;
            foreach (Entity child in children)
            {
                child.pos.Y += 100;
            }
        }
        public static void setUpWander()
        {
            List<Entity> children = XNAGame.Instance().Children;
            Fighter leader = new Fighter();
            leader.pos = new Vector3(10, 120, 20);
            leader.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wander);
            leader.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            leader.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            children.Add(leader);

            Fighter camFighter = new Fighter();
            camFighter.Leader = leader;
            camFighter.pos = new Vector3(10, 120, 0);
            camFighter.offset = new Vector3(0, 5, 10);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.offset_pursuit);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            XNAGame.Instance().CamFighter = camFighter;
            children.Add(camFighter);

            Ground ground = new Ground();
            children.Add(ground);
            XNAGame.Instance().Ground = ground;
        }
        public static void setUpStateMachineDemo()
        {
            List<Entity> children = XNAGame.Instance().Children;
            Ground ground = new Ground();
            children.Add(ground);
            XNAGame.Instance().Ground = ground;
            AIFighter aiFighter = new AIFighter();
            aiFighter.pos = new Vector3(-20, 50, 50);
            aiFighter.maxSpeed = 16.0f;
            aiFighter.SwicthState(new IdleState(aiFighter));
            aiFighter.Path.DrawPath = true;
            children.Add(aiFighter);

            Fighter fighter = new Fighter();
            fighter.ModelName = "ship2";
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.arrive);
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            fighter.pos = new Vector3(10, 50, 0);
            fighter.targetPos = aiFighter.pos + new Vector3(-50, 0, -80);
            children.Add(fighter);

            Fighter camFighter = new Fighter();
            camFighter.Leader = fighter;
            camFighter.offset = new Vector3(0, 5, 10);
            camFighter.pos = fighter.pos + camFighter.offset;
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.offset_pursuit);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            camFighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            XNAGame.Instance().CamFighter = camFighter;
            children.Add(camFighter);

            XNAGame.Instance().Leader = fighter;
            Camera camera = XNAGame.Instance().Camera;
            camera.pos = new Vector3(0.0f, 60.0f, 100.0f);
        }
        public static void setUpPursuit()
        {
            List<Entity> children = XNAGame.Instance().Children;

            Ground ground = new Ground();
            children.Add(ground);
            XNAGame.Instance().Ground = ground;

            Fighter fighter = new Fighter();
            fighter.ModelName = "models/ColonialFleet/Military/ViperMkII";
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.arrive);
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.obstacle_avoidance);
            fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wall_avoidance);
            fighter.pos = new Vector3(2, 20, -50);
            fighter.targetPos = fighter.pos * 2;
            XNAGame.Instance().Leader = fighter;
            children.Add(fighter);

            Fighter fighter1 = new Fighter();
            fighter1.ModelName = "models/Cylon/CylonRaider";
            fighter1.Target = fighter;
            fighter1.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.pursuit);
            fighter1.pos = new Vector3(-20, 20, -20);
            children.Add(fighter1);
        }
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            camera = new Camera();
            int midX = GraphicsDeviceManager.DefaultBackBufferHeight / 2;
            int midY = GraphicsDeviceManager.DefaultBackBufferWidth / 2;
            Mouse.SetPosition(midX, midY);

            dalek = new Dalek();
            dalek.pos = new Vector3(0, 0, 0);
            dalek.DrawAxis = true;
            children.Add(dalek);

            EnemyDalek enemy = new EnemyDalek();
            enemy.pos = new Vector3(10, 0, -10);
            enemy.DrawAxis = true;
            children.Add(enemy);

            children.Add(camera);
            ground = new Ground();
            children.Add(ground);

            Fighter fighter = new Fighter();
            fighter.pos.X = 0; fighter.pos.Y = 20; fighter.pos.Z = 0;
            children.Add(fighter);

            base.Initialize();
        }
        public static void setUpFlockingDemo()
        {
            Params.Load("flocking.properties");
            List<Entity> children = XNAGame.Instance().Children;

            // Create an EliteFighter instance to be the pursuer

            float range = Params.GetFloat("world_range");

            Fighter fighter = new Fighter();
            fighter.ModelName = "ship2";
            //fighter.pos = new Vector3(10.0f, 10.0f, 10.0f);
            //fighter.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.pursuit);

            // Create Params.GetFloat("num_boids") boids and turn on the appropriate steering behaviours..
            float boids = Params.GetFloat("num_boids");

            for (int i = 0; i < boids;  i++)
            {
                Fighter boid = new Fighter();
                boid.ModelName = "fighter";
                boid.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.alignment);
                boid.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.cohesion);
                boid.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.wander);
                boid.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.sphere_constrain);
                boid.SteeringBehaviours.turnOn(SteeringBehaviours.behaviour_type.separation);

                // use Vector3 pos = randomPosition(range); to generate random positions
                Vector3 pos = randomPosition(range);
                boid.pos = pos;
                //fighter.targetPos = boid.pos + new Vector3(-50, 0, -80);
                children.Add(boid);
            }
            //children.Add(fighter);

            int numObstacles = 5;
            float dist = (range * 2) / numObstacles;
            for (float x = - range ; x < range ; x+= dist)
            {
                for (float z = - range ; z < range ; z += dist)
                {
                    Obstacle o = new Obstacle(20);
                    o.pos = new Vector3(x, 0, z);
                    o.Color = new Vector3((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
                    o.ShouldDraw = true;
                    children.Add(o);
                }
            }

            // Create a camera fighter
            // Give it a "Leader" to follow and turn on offset pursuit
            //XNAGame.Instance().CamFighter = XXX?
            Camera camera = XNAGame.Instance().Camera;
            camera.pos = new Vector3(0.0f, 60.0f, 200.0f);
        }