Exemplo n.º 1
0
        public static Enemy Create(int type, Vec3 pos)
        {
            var enemy = Entity.Instantiate <Enemy>(pos, Quat.Identity, 0.5f, EnemyTypes [type].Geometry);

            if (EnemyTypes[type].Material != null)
            {
                enemy.Material = Env.Engine.GetMaterialManager().LoadMaterial(EnemyTypes[type].Material);
            }

            // Rotate Z-Axis in degrees to have enemy facing forward.
            enemy.Rotation = Quat.CreateRotationZ(Utils.Deg2Rad(90f));

            var pfx = Env.ParticleManager.FindEffect("spaceship.Trails.blue_fire_trail");

            enemy.LoadParticleEmitter(1, pfx, 0.5f);

            // Get position of jet on enemy (Note: Non-Existing position means x, y and z are all 0).
            Vec3 jetPosition = enemy.GetHelperPos(0, "particle_01");

            // NOTE ON MATRIX34
            // ----------------
            // First Vec3 parameter indicates scale
            // Second Quat parameter indicate rotation
            // Third Vec3 parameter indicates position

            // Scale, Rotate and Position particle effect to ensure it's shown at the back of the ship.
            enemy.SetTM(1, Matrix34.Create(Vec3.One, Quat.CreateRotationX(Utils.Deg2Rad(270f)), jetPosition));

            // Put into game loop.
            GamePool.AddObjectToPool(enemy);
            return(enemy);
        }
Exemplo n.º 2
0
//        GameObject core;

        public override void OnInitialize()
        {
            base.OnInitialize();

            Health = new Health();
            NativeEntity.LoadGeometry(0, AssetLibrary.Meshes.BasePlate);
            NativeEntity.SetMaterial(AssetLibrary.Materials.BasePlate);

            NativeEntity.LoadGeometry(1, AssetLibrary.Meshes.Diamond);
            NativeEntity.SetSlotMaterial(1, AssetLibrary.Materials.BaseCore);
            NativeEntity.SetSlotLocalTM(1, Matrix34.Create(Vec3.One, Quat.Identity, new Vec3(0, 0, 2f)));
        }
Exemplo n.º 3
0
        private void AddToGamePoolWithDoor(Vec3 position = null)
        {
            GamePool.AddObjectToPool(this);

            if (position == null)             // Get position via Engine EntitySystem.
            {
                position = this.Position;
            }

            // Create a door case as connector between tunnels.
            _tunnelDoor       = Door.Create(new Vec3(position.x, position.y, position.z), 0);
            _tunnelDoor.Speed = LevelGeometry.GlobalGeomSpeed;

            // Create random door types
            int rand = Rand.NextInt(3);

            if (rand != 0)
            {
                _tunnelDoor       = Door.Create(new Vec3(position.x, position.y, position.z), rand);
                _tunnelDoor.Speed = LevelGeometry.GlobalGeomSpeed;
            }

            ColorF lightColor = new ColorF(_randomizer.Next(0, 255), _randomizer.Next(0, 255), _randomizer.Next(0, 255));

            // Till 'MaxValue' as the for-loop is quit when once the first empty position is discovered.
            for (int i = 1; i < int.MaxValue; i++)
            {
                Vec3 helperPos = GetHelperPos(0, "Light_0" + i.ToString());

                if (helperPos.x != 0 || helperPos.y != 0 || helperPos.z != 0)
                {
                    CDLight light = new CDLight()
                    {
                        m_fRadius = 25f,
                        m_fAttenuationBulbSize = 0.1f,
                        m_BaseColor            = lightColor,
                        m_BaseSpecMult         = 1f
                    };

                    LoadLight(i, light);
                    SetTM(i, Matrix34.Create(Vec3.One, Quat.Identity, helperPos));
                }
                else
                {
                    break;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Spawn this instance.
        /// </summary>
        public static Player Create(Vec3 pos)
        {
            var player         = Entity.Instantiate <Player>(pos, Quat.Identity, 10, PlayerSkin.Geometry);
            var particleEffect = Env.ParticleManager.FindEffect("spaceship.Trails.fire_trail");

            player.LoadParticleEmitter(1, particleEffect, 0.03f);

            // Get position where to spawn the particle effect.
            Vec3 jetPosition = player.GetHelperPos(0, "particle_01");

            // Rotate particle effect to ensure it's shown at the back of the ship.
            player.SetTM(1, Matrix34.Create(Vec3.One, Quat.CreateRotationX(Utils.Deg2Rad(270f)), jetPosition));

            // Rotate Z-Axis of player ship in degrees.
            player.Rotation = new Quat(Matrix34.CreateRotationZ(Utils.Deg2Rad(180.0f)));

            Hud.CurrentHud.SetEnergy(player.MaxLife);
            GamePool.AddObjectToPool(player);
            return(player);
        }