Exemplo n.º 1
0
        private void GenerateUnits()
        {
            _powerRangerCount = _rangedCount + _meleeCount + _kamakaziCount;
              _tuxCount = _rangedCount + _meleeCount + _kamakaziCount;

              _octree = new OctreeLinked<Unit, string>(0, 0, 0, 1000000, 10, Unit.CompareTo, Unit.CompareTo);
              lines = new AvlTreeLinked<Link3<Vector, Vector, Color>>(
            (Link3<Vector, Vector, Color> link, Link3<Vector, Vector, Color> link2) => { if (link.First == link2.First && link.Second == link2.Second) return 0; else return 1; }
            );
              explosions = new ListArray<Explosion>(1);

              _zackMelee = new Unit[_meleeCount];
              _zackRanged = new Unit[_rangedCount];
              _zackKamakazi = new Unit[_kamakaziCount];
              _killemMelee = new Unit[_meleeCount];
              _killemRanged = new Unit[_rangedCount];
              _killemKamakazi = new Unit[_kamakaziCount];

              Random random = new Random();
              string[] colors = new string[] { "YellowRanger", "RedRanger", "BlueRanger", "BlackRanger", "PinkRanger" };
              #region Map 0
              if (_map == 0)
              {
            int maxXZack = -1500;
            int minXZack = -2000;

            int maxZZack = 0;
            int minZZack = -1500;

            int maxXKillem = 2000;
            int minXKillem = 1500;

            int maxZKillem = 0;
            int minZKillem = -1500;

            for (int i = 0; i < _meleeCount; i++)
            {
              _zackMelee[i] = new ZackMelee("ZackMelee" + i, StaticModelManager.GetModel("BlackRanger"));
              _zackMelee[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
              if (_3d)
            _zackMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _zackMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _zackMelee[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
              _zackMelee[i].StaticModel.Scale = new Vector(5, 5, 5);
              _zackMelee[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
              _octree.Add(_zackMelee[i]);

              _killemMelee[i] = new KillemMelee("KillemMelee" + i, StaticModelManager.GetModel("Tux"));
              _killemMelee[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
              if (_3d)
            _killemMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _killemMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _killemMelee[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
              _killemMelee[i].StaticModel.Scale = new Vector(20, 20, 20);
              _killemMelee[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
              _octree.Add(_killemMelee[i]);
            }

            for (int i = 0; i < _rangedCount; i++)
            {
              _zackRanged[i] = new ZackRanged("ZackRanged" + i, StaticModelManager.GetModel("BlueRanger"));
              _zackRanged[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
              if (_3d)
            _zackRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _zackRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _zackRanged[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
              _zackRanged[i].StaticModel.Scale = new Vector(5, 5, 5);
              _zackRanged[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
              _octree.Add(_zackRanged[i]);

              _killemRanged[i] = new KillemRanged("KillemRanged" + i, StaticModelManager.GetModel("TuxGreen"));
              _killemRanged[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
              if (_3d)
            _killemRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _killemRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _killemRanged[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
              _killemRanged[i].StaticModel.Scale = new Vector(20, 20, 20);
              _killemRanged[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
              _killemRanged[i].Id = "Ranger" + i;
              _octree.Add(_killemRanged[i]);
            }

            for (int i = 0; i < _kamakaziCount; i++)
            {
              _zackKamakazi[i] = new ZackKamakazi("ZackKamakazi" + i, StaticModelManager.GetModel("RedRanger"));
              _zackKamakazi[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
              if (_3d)
            _zackKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _zackKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _zackKamakazi[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
              _zackKamakazi[i].StaticModel.Scale = new Vector(5, 5, 5);
              _zackKamakazi[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
              _octree.Add(_zackKamakazi[i]);

              _killemKamakazi[i] = new KillemKamakazi("KillemKamakazi" + i, StaticModelManager.GetModel("TuxRed"));
              _killemKamakazi[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
              if (_3d)
            _killemKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _killemKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _killemKamakazi[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
              _killemKamakazi[i].StaticModel.Scale = new Vector(20, 20, 20);
              _killemKamakazi[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
              _octree.Add(_killemKamakazi[i]);
            }
              }
              #endregion
              #region Map 1
              else if (_map == 1)
              {
            int maxXZack = -800;
            int minXZack = -1300;
            int maxZZack = -800;
            int minZZack = -1300;
            int maxXZack2 = 1300;
            int minXZack2 = 800;
            int maxZZack2 = 1300;
            int minZZack2 = 800;

            int maxXKillem = -800;
            int minXKillem = -1300;
            int maxZKillem = 1300;
            int minZKillem = 800;
            int maxXKillem2 = 1300;
            int minXKillem2 = 800;
            int maxZKillem2 = -800;
            int minZKillem2 = -1300;

            for (int i = 0; i < _meleeCount; i++)
            {
              if (i < _meleeCount / 2)
              {
            _zackMelee[i] = new ZackMelee("ZackMelee" + i, StaticModelManager.GetModel("BlackRanger"));
            _zackMelee[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
            if (_3d)
              _zackMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _zackMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _zackMelee[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
            _zackMelee[i].StaticModel.Scale = new Vector(5, 5, 5);
            _zackMelee[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
            _octree.Add(_zackMelee[i]);

            _killemMelee[i] = new KillemMelee("KillemMelee" + i, StaticModelManager.GetModel("Tux"));
            _killemMelee[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
            if (_3d)
              _killemMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _killemMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _killemMelee[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
            _killemMelee[i].StaticModel.Scale = new Vector(20, 20, 20);
            _killemMelee[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
            _octree.Add(_killemMelee[i]);
              }
              else
              {
            _zackMelee[i] = new ZackMelee("ZackMelee" + i, StaticModelManager.GetModel("BlackRanger"));
            _zackMelee[i].StaticModel.Position.X = random.Next(minXZack2, maxXZack2);
            if (_3d)
              _zackMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _zackMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _zackMelee[i].StaticModel.Position.Z = random.Next(minZZack2, maxZZack2);
            _zackMelee[i].StaticModel.Scale = new Vector(5, 5, 5);
            _zackMelee[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
            _octree.Add(_zackMelee[i]);

            _killemMelee[i] = new KillemMelee("KillemMelee" + i, StaticModelManager.GetModel("Tux"));
            _killemMelee[i].StaticModel.Position.X = random.Next(minXKillem2, maxXKillem2);
            if (_3d)
              _killemMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _killemMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _killemMelee[i].StaticModel.Position.Z = random.Next(minZKillem2, maxZKillem2);
            _killemMelee[i].StaticModel.Scale = new Vector(20, 20, 20);
            _killemMelee[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
            _octree.Add(_killemMelee[i]);
              }
            }

            for (int i = 0; i < _rangedCount; i++)
            {
              if (i < _rangedCount / 2)
              {
            _zackRanged[i] = new ZackRanged("ZackRanged" + i, StaticModelManager.GetModel("BlueRanger"));
            _zackRanged[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
            if (_3d)
              _zackRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _zackRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _zackRanged[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
            _zackRanged[i].StaticModel.Scale = new Vector(5, 5, 5);
            _zackRanged[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
            _octree.Add(_zackRanged[i]);

            _killemRanged[i] = new KillemRanged("KillemRanged" + i, StaticModelManager.GetModel("TuxGreen"));
            _killemRanged[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
            if (_3d)
              _killemRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _killemRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _killemRanged[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
            _killemRanged[i].StaticModel.Scale = new Vector(20, 20, 20);
            _killemRanged[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
            _killemRanged[i].Id = "Ranger" + i;
            _octree.Add(_killemRanged[i]);
              }
              else
              {
            _zackRanged[i] = new ZackRanged("ZackRanged" + i, StaticModelManager.GetModel("BlueRanger"));
            _zackRanged[i].StaticModel.Position.X = random.Next(minXZack2, maxXZack2);
            if (_3d)
              _zackRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _zackRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _zackRanged[i].StaticModel.Position.Z = random.Next(minZZack2, maxZZack2);
            _zackRanged[i].StaticModel.Scale = new Vector(5, 5, 5);
            _zackRanged[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
            _octree.Add(_zackRanged[i]);

            _killemRanged[i] = new KillemRanged("KillemRanged" + i, StaticModelManager.GetModel("TuxGreen"));
            _killemRanged[i].StaticModel.Position.X = random.Next(minXKillem2, maxXKillem2);
            if (_3d)
              _killemRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _killemRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _killemRanged[i].StaticModel.Position.Z = random.Next(minZKillem2, maxZKillem2);
            _killemRanged[i].StaticModel.Scale = new Vector(20, 20, 20);
            _killemRanged[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
            _killemRanged[i].Id = "Ranger" + i;
            _octree.Add(_killemRanged[i]);
              }
            }

            for (int i = 0; i < _kamakaziCount; i++)
            {
              if (i < _kamakaziCount / 2)
              {
            _zackKamakazi[i] = new ZackKamakazi("ZackKamakazi" + i, StaticModelManager.GetModel("RedRanger"));
            _zackKamakazi[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
            if (_3d)
              _zackKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _zackKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _zackKamakazi[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
            _zackKamakazi[i].StaticModel.Scale = new Vector(5, 5, 5);
            _zackKamakazi[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
            _octree.Add(_zackKamakazi[i]);

            _killemKamakazi[i] = new KillemKamakazi("KillemKamakazi" + i, StaticModelManager.GetModel("TuxRed"));
            _killemKamakazi[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
            if (_3d)
              _killemKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _killemKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _killemKamakazi[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
            _killemKamakazi[i].StaticModel.Scale = new Vector(20, 20, 20);
            _killemKamakazi[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
            _octree.Add(_killemKamakazi[i]);
              }
              else
              {
            _zackKamakazi[i] = new ZackKamakazi("ZackKamakazi" + i, StaticModelManager.GetModel("RedRanger"));
            _zackKamakazi[i].StaticModel.Position.X = random.Next(minXZack2, maxXZack2);
            if (_3d)
              _zackKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _zackKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _zackKamakazi[i].StaticModel.Position.Z = random.Next(minZZack2, maxZZack2);
            _zackKamakazi[i].StaticModel.Scale = new Vector(5, 5, 5);
            _zackKamakazi[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
            _octree.Add(_zackKamakazi[i]);

            _killemKamakazi[i] = new KillemKamakazi("KillemKamakazi" + i, StaticModelManager.GetModel("TuxRed"));
            _killemKamakazi[i].StaticModel.Position.X = random.Next(minXKillem2, maxXKillem2);
            if (_3d)
              _killemKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
            else
              _killemKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
            _killemKamakazi[i].StaticModel.Position.Z = random.Next(minZKillem2, maxZKillem2);
            _killemKamakazi[i].StaticModel.Scale = new Vector(20, 20, 20);
            _killemKamakazi[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
            _octree.Add(_killemKamakazi[i]);
              }
            }
              }
              #endregion
              #region Map 2
              if (_map == 2)
              {
            int maxXZack = 250;
            int minXZack = -250;
            int maxZZack = 250;
            int minZZack = -250;

            int maxXKillem = 250;
            int minXKillem = -250;
            int maxZKillem = 250;
            int minZKillem = -250;

            for (int i = 0; i < _meleeCount; i++)
            {
              _zackMelee[i] = new ZackMelee("ZackMelee" + i, StaticModelManager.GetModel("BlackRanger"));
              _zackMelee[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
              if (_3d)
            _zackMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _zackMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _zackMelee[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
              _zackMelee[i].StaticModel.Scale = new Vector(5, 5, 5);
              _zackMelee[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
              _octree.Add(_zackMelee[i]);

              _killemMelee[i] = new KillemMelee("KillemMelee" + i, StaticModelManager.GetModel("Tux"));
              _killemMelee[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
              if (_3d)
            _killemMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _killemMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _killemMelee[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
              _killemMelee[i].StaticModel.Scale = new Vector(20, 20, 20);
              _killemMelee[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
              _octree.Add(_killemMelee[i]);
            }

            for (int i = 0; i < _rangedCount; i++)
            {
              _zackRanged[i] = new ZackRanged("ZackRanged" + i, StaticModelManager.GetModel("BlueRanger"));
              _zackRanged[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
              if (_3d)
            _zackRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _zackRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _zackRanged[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
              _zackRanged[i].StaticModel.Scale = new Vector(5, 5, 5);
              _zackRanged[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
              _octree.Add(_zackRanged[i]);

              _killemRanged[i] = new KillemRanged("KillemRanged" + i, StaticModelManager.GetModel("TuxGreen"));
              _killemRanged[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
              if (_3d)
            _killemRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _killemRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _killemRanged[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
              _killemRanged[i].StaticModel.Scale = new Vector(20, 20, 20);
              _killemRanged[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
              _killemRanged[i].Id = "Ranger" + i;
              _octree.Add(_killemRanged[i]);
            }

            // CIRCLE: radius ^ 2 = x ^ 2 + z ^ 2
            float radiusSquared = 1000000f;

            for (int i = 0; i < _kamakaziCount; i++)
            {
              float x = random.Next(-1000, 1000);

              _zackKamakazi[i] = new ZackKamakazi("ZackKamakazi" + i, StaticModelManager.GetModel("RedRanger"));
              _zackKamakazi[i].StaticModel.Position.X = x;
              if (_3d)
            _zackKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _zackKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _zackKamakazi[i].StaticModel.Position.Z = Calc.SquareRoot(radiusSquared - x * x);
              _zackKamakazi[i].StaticModel.Scale = new Vector(5, 5, 5);
              _zackKamakazi[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
              _octree.Add(_zackKamakazi[i]);

              _killemKamakazi[i] = new KillemKamakazi("KillemKamakazi" + i, StaticModelManager.GetModel("TuxRed"));
              _killemKamakazi[i].StaticModel.Position.X = x;
              if (_3d)
            _killemKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _killemKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _killemKamakazi[i].StaticModel.Position.Z = -Calc.SquareRoot(radiusSquared - x * x);
              _killemKamakazi[i].StaticModel.Scale = new Vector(20, 20, 20);
              _killemKamakazi[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
              _octree.Add(_killemKamakazi[i]);
            }
              }
              #endregion
              #region Map 3
              if (_map == 3)
              {
            int maxXZack = 2000;
            int minXZack = -2000;

            int maxZZack = 2000;
            int minZZack = -2000;

            int maxXKillem = 2000;
            int minXKillem = -2000;

            int maxZKillem = 2000;
            int minZKillem = -2000;

            for (int i = 0; i < _meleeCount; i++)
            {
              _zackMelee[i] = new ZackMelee("ZackMelee" + i, StaticModelManager.GetModel("BlackRanger"));
              _zackMelee[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
              if (_3d)
            _zackMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _zackMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _zackMelee[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
              _zackMelee[i].StaticModel.Scale = new Vector(5, 5, 5);
              _zackMelee[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
              _octree.Add(_zackMelee[i]);

              _killemMelee[i] = new KillemMelee("KillemMelee" + i, StaticModelManager.GetModel("Tux"));
              _killemMelee[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
              if (_3d)
            _killemMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _killemMelee[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _killemMelee[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
              _killemMelee[i].StaticModel.Scale = new Vector(20, 20, 20);
              _killemMelee[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
              _octree.Add(_killemMelee[i]);
            }

            for (int i = 0; i < _rangedCount; i++)
            {
              _zackRanged[i] = new ZackRanged("ZackRanged" + i, StaticModelManager.GetModel("BlueRanger"));
              _zackRanged[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
              if (_3d)
            _zackRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _zackRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _zackRanged[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
              _zackRanged[i].StaticModel.Scale = new Vector(5, 5, 5);
              _zackRanged[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
              _octree.Add(_zackRanged[i]);

              _killemRanged[i] = new KillemRanged("KillemRanged" + i, StaticModelManager.GetModel("TuxGreen"));
              _killemRanged[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
              if (_3d)
            _killemRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _killemRanged[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _killemRanged[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
              _killemRanged[i].StaticModel.Scale = new Vector(20, 20, 20);
              _killemRanged[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
              _killemRanged[i].Id = "Ranger" + i;
              _octree.Add(_killemRanged[i]);
            }

            for (int i = 0; i < _kamakaziCount; i++)
            {
              _zackKamakazi[i] = new ZackKamakazi("ZackKamakazi" + i, StaticModelManager.GetModel("RedRanger"));
              _zackKamakazi[i].StaticModel.Position.X = random.Next(minXZack, maxXZack);
              if (_3d)
            _zackKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _zackKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _zackKamakazi[i].StaticModel.Position.Z = random.Next(minZZack, maxZZack);
              _zackKamakazi[i].StaticModel.Scale = new Vector(5, 5, 5);
              _zackKamakazi[i].StaticModel.Orientation = new Quaternion(0, 1, 0, 0);
              _octree.Add(_zackKamakazi[i]);

              _killemKamakazi[i] = new KillemKamakazi("KillemKamakazi" + i, StaticModelManager.GetModel("TuxRed"));
              _killemKamakazi[i].StaticModel.Position.X = random.Next(minXKillem, maxXKillem);
              if (_3d)
            _killemKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10 + random.Next(0, 1000);
              else
            _killemKamakazi[i].StaticModel.Position.Y = _terrain.Position.Y + 10;
              _killemKamakazi[i].StaticModel.Position.Z = random.Next(minZKillem, maxZKillem);
              _killemKamakazi[i].StaticModel.Scale = new Vector(20, 20, 20);
              _killemKamakazi[i].StaticModel.Orientation = new Quaternion(0, 1, 0, -Calc.PiOverTwo);
              _octree.Add(_killemKamakazi[i]);
            }
              }
              #endregion
        }
Exemplo n.º 2
0
        public string Update(float elapsedTime)
        {
            CameraControls();
              _skybox.Position.X = _camera.Position.X;
              _skybox.Position.Y = _camera.Position.Y;
              _skybox.Position.Z = _camera.Position.Z;

              if (InputManager.Keyboard.Zpressed)
            _meleeCount = (_meleeCount + 1) % 100;
              if (InputManager.Keyboard.Xpressed)
            if (_meleeCount > 0) _meleeCount--;
              if (InputManager.Keyboard.Cpressed)
            _rangedCount = (_rangedCount + 1) % 100;
              if (InputManager.Keyboard.Vpressed)
            if (_rangedCount > 0) _rangedCount--;
              if (InputManager.Keyboard.Bpressed)
            _kamakaziCount = (_kamakaziCount + 1) % 100;
              if (InputManager.Keyboard.Npressed)
            if (_kamakaziCount > 0) _kamakaziCount--;

              if (InputManager.Keyboard.Gpressed)
            _map = (_map + 1) % 4;

              if (InputManager.Keyboard.Rpressed)
            _showlines = !_showlines;

              if (InputManager.Keyboard.Ypressed)
            _3d = !_3d;

              if (InputManager.Keyboard.Tpressed)
            GenerateUnits();

              if (InputManager.Keyboard.Spacepressed)
            _paused = !_paused;

              if (!_paused)
              {
            _octree.Traverse((Unit model) => { model.AI(elapsedTime, _octree); }, -100000, -100000, -100000, 100000, 100000, 100000);

            OctreeLinked<Unit, string> octree = new OctreeLinked<Unit, string>(0, 0, 0, 1000000, 10, Unit.CompareTo, Unit.CompareTo);
            foreach (Unit unit in _zackMelee)
              octree.Add(unit);
            foreach (Unit unit in _zackRanged)
              octree.Add(unit);
            foreach (Unit unit in _zackKamakazi)
              octree.Add(unit);
            foreach (Unit unit in _killemMelee)
              octree.Add(unit);
            foreach (Unit unit in _killemRanged)
              octree.Add(unit);
            foreach (Unit unit in _killemKamakazi)
              octree.Add(unit);
            _octree = octree;
              }
              return "Don't Change States";
        }