/// <summary> /// creates a weapon for level. /// reads an weapon information file(.spec) and configures the weapon class. /// The read weapon class is stored in the list. /// </summary> /// <param name="info">weapon information for level</param> /// <param name="sceneParent">3D scene parent node</param> /// <returns>weapon class for the game</returns> protected GameWeapon CreateWeapon(WeaponInLevel info, NodeBase sceneParent) { GameWeaponSpec spec = new GameWeaponSpec(); spec = (GameWeaponSpec)GameDataSpecManager.Load(info.SpecFilePath, spec.GetType()); GameWeapon weapon = new GameWeapon(spec); // creates a collision data. Vector3 centerPos = Vector3.Transform(new Vector3(0f, spec.ModelRadius, 0f), Matrix.Invert(weapon.RootAxis)); CollideSphere collide = new CollideSphere(centerPos, spec.ModelRadius); weapon.SetCollide(collide); weapon.SetDroppedModelActiveFog(true); weapon.SetDroppedModelActiveLighting(false); // drop to world. weapon.Drop(info.Position, sceneParent, null); // adds a weapon to the list. weaponList.Add(weapon); return(weapon); }
/// <summary> /// creates a weapon by spec file. /// </summary> /// <param name="specFileName">weapon information file (.spec)</param> public void CreateWeapon(string specFileName) { GameWeaponSpec spec = new GameWeaponSpec(); spec = (GameWeaponSpec)GameDataSpecManager.Load(specFileName, spec.GetType()); GameWeapon createWeapon = new GameWeapon(spec); createWeapon.AttachOwner(this); weaponList.Add(createWeapon); SelectWeapon(0); }
/// <summary> /// creates a weapon by spec file. /// </summary> /// <param name="specFileName">weapon information file (.spec)</param> public void CreateWeapon(string specFileName) { GameWeaponSpec spec = new GameWeaponSpec(); spec = (GameWeaponSpec)GameDataSpecManager.Load(specFileName, spec.GetType()); GameWeapon createWeapon = new GameWeapon(spec); createWeapon.AttachOwner(this); weaponList.Add(createWeapon); SelectWeapon(0); }