Exemplo n.º 1
0
        void CreatePiece(Building Building, float Xoffset, float Yoffset, float Zoffset, Model PieceModel, Texture2D[] PieceTextures,
            Vector3 ExplosionPosition, float Force, float Radius, float L, float W, float H)
        {
            ExplosionPosition = new Vector3(ExplosionPosition.X, ExplosionPosition.Y - 15, ExplosionPosition.Z);

            BuildingPiece Piece = new BuildingPiece(parentGame, PieceModel, PieceTextures, NormalDrawing, this, L, W, H);
            Piece.position = new Vector3(
                Building.position.X + Xoffset,
                Building.position.Y + Yoffset,
                Building.position.Z + Zoffset);

            Piece.scale = Building.scale;

            Vector3 ROTATION = Building.rotation;
            Matrix Orientation = Matrix.CreateFromYawPitchRoll(ROTATION.X, ROTATION.Y, ROTATION.Z);

            Piece.SetBody(Orientation);

            Vector3 DIRECTION = Piece.position - ExplosionPosition;
            DIRECTION.Normalize();
            Vector3 ANGLE = DIRECTION;

            float min = 1.1f;
            float max = 1.6f;
            float AMOUNT = (float)(min + (float)random.NextDouble() * (max - min));
            //float amount = (float)(min + (float)random.NextDouble() * (max - min));

            float DIS = Vector3.Distance(Piece.position, ExplosionPosition);
            float POWER = Force * (1 - DIS / Radius);

            Piece.Body.ApplyWorldImpulse(DIRECTION * POWER);
            Piece.Body.AngularVelocity = (ANGLE * AMOUNT);

            Piece.Skin.callbackFn += new CollisionCallbackFn(PieceColllisionFunction);

            //Piece.Body.Immovable = true;

            PieceList.Add(Piece);
        }
Exemplo n.º 2
0
        void CreateBunkerPieces(Building BUILD, Missile MISS, float Force, float Radius)
        {
            // x y z
            CreatePiece(BUILD, 3, 13, -3, BunkerPiece1, BunkerPiece1Textures,
                MISS.position, Force, Radius,
                4, 4, 4);

            CreatePiece(BUILD, -3, 3, -3, BunkerPiece2, BunkerPiece2Textures,
                MISS.position, Force, Radius,
                4, 4, 4);

            CreatePiece(BUILD, -3, 9, 3, BunkerPiece3, BunkerPiece3Textures,
                MISS.position, Force, Radius,
                4, 4, 7);

            CreatePiece(BUILD, -2, 7, 1, BunkerPiece4, BunkerPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);

            CreatePiece(BUILD, 2, 14, 1, BunkerPiece4, BunkerPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);

            CreatePiece(BUILD, 2, 5, 2, BunkerPiece4, BunkerPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);

            CreatePiece(BUILD, -5, 15, -2, BunkerPiece4, BunkerPiece4Textures,
                MISS.position, Force, Radius,
               2, 2, 2);

            CreatePiece(BUILD, -3, 9, 2, BunkerPiece4, BunkerPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);
        }
Exemplo n.º 3
0
        void CreateDepotPieces(Building BUILD, Missile MISS, float Force, float Radius)
        {
            // x y z
            CreatePiece(BUILD, -5, 3, 7, DepotPiece1, DepotPiece1Textures,
                MISS.position, Force, Radius,
                4, 4, 1);

            CreatePiece(BUILD, 2, 2, -3, DepotPiece2, DepotPiece2Textures,
                MISS.position, Force, Radius,
                3, 3, 1);

            CreatePiece(BUILD, -3, 5, -7, DepotPiece3, DepotPiece3Textures,
                MISS.position, Force, Radius,
                1, 1, 1);

            CreatePiece(BUILD, -2, 5, -5, DepotPiece4, DepotPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);

            CreatePiece(BUILD, 3, 5, -7, DepotPiece3, DepotPiece3Textures,
                MISS.position, Force, Radius,
                1, 1, 1);

            CreatePiece(BUILD, 2, 5, -5, DepotPiece4, DepotPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);

            CreatePiece(BUILD, -10, 5, 2, DepotPiece3, DepotPiece3Textures,
                MISS.position, Force, Radius,
                1, 1, 1);

            CreatePiece(BUILD, 10, 5, 3, DepotPiece4, DepotPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);
        }
Exemplo n.º 4
0
        private void SpawnBuildings()
        {
            List<EventFlag> FlagList = parentGame.Level_Loader.myLevel.FlagsList;
            foreach (EventFlag flag in FlagList)
                foreach (GameEvent evnt in flag.Events)
                {
                    double ROTATION = (3 + random.NextDouble() * (84 - 3));

                    EnemySpawn spwn = (evnt.SpawnPoint as EnemySpawn);
                    if (spwn.EnemyStats["Type"] == "BUNKER")
                    {
                        float HEIGHT;
                        Vector3 NORMAL;

                        terrainEngine.GetHeight(spwn.Position, out HEIGHT, out NORMAL);

                        Building building = new Building(
                            parentGame,
                            BunkerModel,
                            BunkerTextures,
                            new Vector3(spwn.Position.X, HEIGHT + 4, spwn.Position.Z),
                            (float)Convert.ToDouble((spwn.EnemyStats["Scale"])),
                            new Vector3(
                                spwn.Rotation.X + MathHelper.ToRadians((float)ROTATION),
                                spwn.Rotation.Y,
                                spwn.Rotation.Z),
                            "BUNKER",
                            this);

                        //+ MathHelper.ToRadians(-90)

                        building.Body.Immovable = true;

                        Buildings.Add(building);
                        ++BuildingRemain;
                    }

                    else if (spwn.EnemyStats["Type"] == "DEPOT")
                    {
                        float HEIGHT;
                        Vector3 NORMAL;
                        terrainEngine.GetHeight(spwn.Position, out HEIGHT, out NORMAL);
                        Building building = new Building(
                            parentGame,
                            DepotModel,
                            DepotTextures,
                            new Vector3(spwn.Position.X, HEIGHT + 1, spwn.Position.Z),
                            (float)Convert.ToDouble((spwn.EnemyStats["Scale"])),
                            new Vector3(
                                spwn.Rotation.X + MathHelper.ToRadians((float)ROTATION),
                                spwn.Rotation.Y,
                                spwn.Rotation.Z),
                            "DEPOT",
                            this);

                        building.Body.Immovable = true;

                        Buildings.Add(building);
                        ++BuildingRemain;
                    }

                    else if (spwn.EnemyStats["Type"] == "RING")
                    {
                        Ring ring = new Ring(
                            parentGame,
                            RingModel,
                            RingTextures,
                            new Vector3(spwn.Position.X, spwn.Position.Y, spwn.Position.Z),
                            (float)Convert.ToDouble((spwn.EnemyStats["Scale"])),
                            new Vector3(spwn.Rotation.X, spwn.Rotation.Y, spwn.Rotation.Z),
                            "RING",
                            this);

                        ring.Body.Immovable = true;

                        Buildings.Add(ring);
                        ++BuildingRemain;
                    }

                }
        }