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); }
/// <summary> /// Initializes a new instance of the <see cref="CryEngine.Sydewinder.Door"/> class. /// </summary> /// <param name="position">Position.</param> /// <param name="doorType">Door type.</param> public static Door Create(Vector3 pos, int doorType) { if (doorType < 0 && doorType >= DoorTypes.Length) { throw new ArgumentOutOfRangeException( string.Format("doorType must betwenn 0 and {0}", (DoorTypes.Length - 1).ToString())); } var door = Entity.Spawn <Door> (pos, Quaternion.Identity, 1); var material = DoorTypes[doorType].Material; if (material != null) { door.LoadMaterial(material); } var geometry = DoorTypes[doorType].Geometry; if (geometry != null) { door.LoadGeometry(0, geometry); } door.Physics.Physicalize(0, 1, EPhysicalizationType.ePT_Rigid); GamePool.AddObjectToPool(door); return(door); }
private void AddToGamePoolWithDoor(Vector3?pos = null) { GamePool.AddObjectToPool(this); Vector3 position; if (pos.HasValue) { position = pos.Value; } else { position = this.Position; } // Create a door case as connector between tunnels. _tunnelDoor = Door.Create(new Vector3(position.x, position.y, position.z), 0); _tunnelDoor.Speed = LevelGeometry.GlobalGeomSpeed; // Create random door types int rand = Random.Next(3); if (rand != 0) { _tunnelDoor = Door.Create(new Vector3(position.x, position.y, position.z), rand); _tunnelDoor.Speed = LevelGeometry.GlobalGeomSpeed; } ColorF lightColor = new ColorF(Random.Next(0, 255), Random.Next(0, 255), Random.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++) { Vector3 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); SetGeometrySlotLocalTransform(i, new Matrix3x4(Vector3.One, Quaternion.Identity, helperPos)); } else { break; } } }
/// <summary> /// Initializes a new instance of the <see cref="CryEngine.Sydewinder.Door"/> class. /// </summary> /// <param name="position">Position.</param> /// <param name="doorType">Door type.</param> public static Door Create(Vec3 pos, int doorType) { if (doorType < 0 && doorType >= DoorTypes.Length) { throw new ArgumentOutOfRangeException( string.Format("doorType must betwenn 0 and {0}", (DoorTypes.Length - 1).ToString())); } var door = Entity.Instantiate <Door> (pos, Quat.Identity, 1, DoorTypes [doorType].Geometry, DoorTypes[doorType].Material); GamePool.AddObjectToPool(door); return(door); }
public static Enemy Create(int type, Vector3 pos) { var enemy = Entity.SpawnWithComponent <Enemy>(pos, Quaternion.Identity, 0.5f); enemy.Entity.LoadGeometry(0, EnemyTypes[type].Geometry); enemy.Entity.Physics.Physicalize(0, 1, EPhysicalizationType.ePT_Rigid); if (EnemyTypes [type].Material != null) { enemy.Entity.Material = Engine.Engine3D.GetMaterialManager().LoadMaterial(EnemyTypes [type].Material); } // Rotate Z-Axis in degrees to have enemy facing forward. enemy.Entity.Rotation = Quaternion.CreateRotationZ(MathHelpers.DegreesToRadians(90f)); var pfx = Engine.ParticleManager.FindEffect("spaceship.Trails.blue_fire_trail"); enemy.Entity.LoadParticleEmitter(1, pfx, 0.5f); // Get position of jet on enemy (Note: Non-Existing position means x, y and z are all 0). Vector3 jetPosition = enemy.Entity.GetHelperPos(0, "particle_01"); // NOTE ON Matrix3x4 // ---------------- // First Vector3 parameter indicates scale // Second Quaternion parameter indicate rotation // Third Vector3 parameter indicates position // Scale, Rotate and Position particle effect to ensure it's shown at the back of the ship. enemy.Entity.SetGeometrySlotLocalTransform(1, new Matrix3x4(Vector3.One, Quaternion.CreateRotationX(MathHelpers.DegreesToRadians(270f)), jetPosition)); // Put into game loop. GamePool.AddObjectToPool(enemy); return(enemy); }