Ejemplo n.º 1
0
 // Destroys Boid and changes formation
 public void Reorganize(GameObject DeadBoid)
 {
     size--;
     Boids.Remove(DeadBoid);
     if (size != 0)
     {
         SetFollowers();
     }
     Destroy(DeadBoid);
 }
Ejemplo n.º 2
0
 // Destroys Boid and change targets
 public void Reorganize(GameObject DeadBoid)
 {
     size--;
     Boids.Remove(DeadBoid);
     if (size != 0)
     {
         if (DeadBoid == leader)
         {
             leaderIndex = leader.GetComponent <PathFollow>().current;
             SetLeader(DeadBoid.GetComponent <NPCController>());
         }
         SetNoTargets(DeadBoid.GetComponent <NPCController>());
     }
     Destroy(DeadBoid);
 }
 // Destroys Boid and changes formation
 public void Reorganize(GameObject DeadBoid)
 {
     size--;
     Boids.Remove(DeadBoid);
     if (size != 0)
     {
         if (DeadBoid == leader)
         {
             leaderPos   = leader.transform.position;
             leaderIndex = leader.GetComponent <PathFollow>().current;
             SetLeader();
         }
         SetFollowers();
     }
     Destroy(DeadBoid);
 }
Ejemplo n.º 4
0
        protected override void OnKeyDown(KeyboardKeyEventArgs e)
        {
            base.OnKeyDown(e);

            // Move the camera when in free mode
            if (e.Key == Key.I)
            {
                Camera.ProcessKeyboard(CameraMovement.FORWARD, deltaTime);
            }
            if (e.Key == Key.K)
            {
                Camera.ProcessKeyboard(CameraMovement.BACKWARD, deltaTime);
            }
            if (e.Key == Key.J)
            {
                Camera.ProcessKeyboard(CameraMovement.LEFT, deltaTime);
            }
            if (e.Key == Key.L)
            {
                Camera.ProcessKeyboard(CameraMovement.RIGHT, deltaTime);
            }

            // change camera type
            if (e.Key == Key.Number1)
            {
                Camera.SetCameraType(CameraType.Behind);
            }
            if (e.Key == Key.Number2)
            {
                Camera.SetCameraType(CameraType.Parallel);
            }
            if (e.Key == Key.Number3)
            {
                Camera.SetCameraType(CameraType.Tower);
            }
            if (e.Key == Key.Number4)
            {
                Camera.SetCameraType(CameraType.Free);
            }

            // add boids/increase boid speed
            if (e.Key == Key.Plus)
            {
                if (e.Shift)
                {
                    Boid.MAX_SPEED = Math.Min(800, Boid.MAX_SPEED + 10);                     // keeping max speed sane
                    if (!autoPilot)
                    {
                        LeaderBoid.Velocity = LeaderBoid.Velocity.Normalized() * Boid.MAX_SPEED;
                    }
                }
                else
                {
                    Boid b = new Boid(ResourceManager.GetModel("fish_000010"), GetRandomPosition(), Vector3.One * Utils.Random.Next(10, 16), GetRandomDir());
                    Boids.Add(b);
                    EngineObjects.Add(b);
                }
            }

            //remove boids/decrease boid speed
            if (e.Key == Key.Minus)
            {
                if (e.Shift)
                {
                    Boid.MAX_SPEED = Math.Max(50, Boid.MAX_SPEED - 10);                     // speeds lower than 50 start to get weird
                    if (!autoPilot)
                    {
                        LeaderBoid.Velocity = LeaderBoid.Velocity.Normalized() * Boid.MAX_SPEED;
                    }
                }
                else if (Boids.Count > 3)
                {
                    int          i = Utils.Random.Next(Boids.Count);
                    EngineObject b = Boids[i];
                    Boids.Remove(b);
                    EngineObjects.Remove(b);
                }
            }

            // toggle light mode
            // can mess up with shadows
            if (e.Key == Key.T)
            {
                directionalLight = !directionalLight;
            }

            // enable/disable fog
            if (e.Key == Key.F)
            {
                fogEnabled = !fogEnabled;
            }

            // move light source, mostly for testing
            if (e.Key == Key.Left)
            {
                Sun.Position -= Vector3.UnitZ * 50;
            }
            if (e.Key == Key.Right)
            {
                Sun.Position += Vector3.UnitZ * 50;
            }
            if (e.Key == Key.Down)
            {
                Sun.Position -= Vector3.UnitY * 50;
            }
            if (e.Key == Key.Up)
            {
                Sun.Position += Vector3.UnitY * 50;
            }

            // enable/disable boid movement rules
            if (e.Key == Key.F1)
            {
                Boid.Sep = !Boid.Sep;
            }
            if (e.Key == Key.F2)
            {
                Boid.Coh = !Boid.Coh;
            }
            if (e.Key == Key.F3)
            {
                Boid.Ali = !Boid.Ali;
            }
            if (e.Key == Key.F4)
            {
                Boid.Goal = !Boid.Goal;
            }

            // move leader boid when autopilot is disabled
            if (!autoPilot)
            {
                if (e.Key == Key.W)
                {
                    LeaderBoid.Velocity += LeaderBoid.Up * (Boid.MAX_SPEED / 20);
                }
                if (e.Key == Key.S)
                {
                    LeaderBoid.Velocity -= LeaderBoid.Up * (Boid.MAX_SPEED / 20);
                }
                if (e.Key == Key.A)
                {
                    LeaderBoid.Velocity -= LeaderBoid.Right * (Boid.MAX_SPEED / 20);
                }
                if (e.Key == Key.D)
                {
                    LeaderBoid.Velocity += LeaderBoid.Right * (Boid.MAX_SPEED / 20);
                }
            }

            if (e.Key == Key.P)
            {
                // toggle auto/manual leader control
                if (e.Shift)
                {
                    autoPilot = !autoPilot;
                }
                else
                {
                    // pause/unpause
                    if (State == GameState.Active)
                    {
                        State = GameState.Paused;
                    }
                    else
                    {
                        State = GameState.Active;
                    }
                }
            }

            // quit
            if (e.Key == Key.Q || e.Key == Key.Escape)
            {
                Close();
            }
        }