Beispiel #1
0
        void Explode(Collision collision)
        {
            //add explosion force to surrounding objects
            Vector3 explosionPos = transform.position;
            int     count        = Physics.OverlapSphereNonAlloc(explosionPos, ExplosionRadius, overlapResults);

            for (int i = 0; i < count; i++)
            {
                Rigidbody otherRb = overlapResults[i].GetComponent <Rigidbody>();
                if (otherRb != null)
                {
                    Debug.Log("Apply force to " + overlapResults[i].gameObject.name);
                    otherRb.AddExplosionForce(ExplosionForce * RigidbodyExplosionForceScale, explosionPos, ExplosionRadius, 0, ForceMode.Force);
                }

                LevelTerrain terrain = overlapResults[i].GetComponent <LevelTerrain>();
                if (terrain != null)
                {
                    Debug.Log("Apply force to " + overlapResults[i].gameObject.name);
                    terrain.AddExplosionForce(ExplosionForce, explosionPos, this.rb.velocity.normalized, ExplosionRadius);
                }
            }

            //destroy
            Destroy(gameObject);
        }
Beispiel #2
0
        protected override bool setup()
        {
            #region setup world
            // scene light
            Vector3 lightDir = new Vector3(1f, -1f, 1f);
            light = new DirectionalLight(lightDir.Normalized(), new Vector3(1, 1, 1));
            AddLight(light);

            // shadow material (unused)
            //ShadowMaterial = new ShadowMaterial();
            //if (!ShadowMaterial.Ready) return false;

            // create skysphere
            skySphere = new SkySphere(2000f, 2);
            if (!skySphere.Ready)
            {
                return(false);
            }
            AddNode(skySphere);

            // load level file
            Data = new LevelFile(Config.DATA_FOLDER + "maps/level0-" + levelNumber + ".dat");
            if (!Data.Ready)
            {
                return(false);
            }

            Name = Data.Name;

            // load level atlas texture file
            int atlasNumber = levelNumber;
            if (levelNumber == 7)
            {
                atlasNumber = 1;                   // original game has this hardcoded too
            }
            Atlas = new AtlasMaterial("images/level0-" + atlasNumber + ".png", false);
            if (!Atlas.Ready)
            {
                return(false);
            }

            // create terrain
            Terrain = new LevelTerrain("Terrain Level " + levelNumber, Data, Atlas);
            if (!Terrain.Ready)
            {
                return(false);
            }
            AddNode(Terrain);

            // player (camera controller really)
            Camera = new CameraController(new Vector3(6f, Terrain.Size.Y + 6f, 6f), new Vector3(10f, Terrain.Size.Y + 5f, 10f));

            // create building node and add columns
            Buildings = new SceneNode();
            AddNode(Buildings);

            columnsByPosition = new Dictionary <int, Column>();

            foreach (var columnPosPair in Data.Columns)
            {
                addColumn(columnPosPair.Value, columnPosPair.Key);
            }

            // create entities and link columns with their morph source
            createEntities();
            #endregion

            #region temporary

            /*
             * mouseLine = new Line(Vector3.Zero, Vector3.UnitZ, new Vector4(1, 1, 1, 1));
             * AddNode(mouseLine);
             *
             */

            /*
             * Craft craft = new Craft("JET0-0", box.Position);
             * AddNode(craft);
             */

            // level bounds rectangle

            /*
             * Line line;
             * line = new Line(new Vector3(0f, Terrain.Size.Y, 0f), new Vector3(256f, Terrain.Size.Y, 0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f));
             * if (!line.Ready) return false;
             * line.Extend(new Vector3(256f, Terrain.Size.Y, 160f)).Extend(new Vector3(0f, Terrain.Size.Y, 160f)).Extend(line.A);
             * AddNode(line);
             */
            #endregion

            #region helpers
            // X / Y / Z
            AddNode(new Line(new Vector3(0f, 0f, 0f), new Vector3(20f, 0f, 0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f)));
            AddNode(new Line(new Vector3(0f, 0f, 0f), new Vector3(0f, 20f, 0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f)));
            AddNode(new Line(new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 20f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f)));

            // setup collision helper for superfast Hi-Octane world box collisions
            Collisions = new LevelCollision(this, Data);
            #endregion
            return(true);
        }
 public DrawableLevelTerrain(LevelTerrain terrain)
 {
     m_terrain = terrain;
 }
Beispiel #4
0
 public TerrainInfo(LevelTerrain lt)
 {
     m_terrain = lt;
 }
 // Start is called before the first frame update
 void Start()
 {
     terrain = FindObjectOfType <LevelTerrain>();
 }