private void LoadWeaponData() { var weaponDataParse = JSON.ParseFile("weapon_definitions"); var weaponDataArray = weaponDataParse["WEAPON_DEFINITIONS"].AsArray; var weaponDataCount = weaponDataArray.Count; m_weaponData = new WeaponStruct[weaponDataCount]; for (int i = 0; i < weaponDataCount; i++) { var thisWeapon = weaponDataArray[i]; string name = thisWeapon["NAME"]; string soundPathActivateWeapon = thisWeapon["SOUND_PATH_ACTIVATE_WEAPON"]; // note: the particle paths must have all material types defined in same order as // material definitions List <string> particlePathHit = new List <string>(); List <string> decalPathHit = new List <string>(); for (int m = 0; m < m_materialData.Length; m++) { string matName = m_materialData[m].m_name.ToUpper(); // Add Particle path string particleName = "PARTICLE_PATH_HIT_" + matName; string particlePath = thisWeapon[particleName]; particlePathHit.Add(particlePath); // Add Decal Path string decalName = "DECAL_PATH_HIT_" + matName; string decalPath = thisWeapon[decalName]; decalPathHit.Add(decalPath); } m_weaponData[i] = new WeaponStruct(name, soundPathActivateWeapon, particlePathHit, decalPathHit); } }
//private void GameStarted() //{ // this.EquipWeaponDirect(WeaponDatabase.instance.GenerateWeapon()); //} public void EquipWeaponByName(string name) { currentWeapon = WeaponDatabase.instance.GetWeaponByName(name); WeaponStruct.Type wepType = currentWeapon.wepType; switch (wepType) { case WeaponStruct.Type.Pistol: shootFunction = new ShootFunction(StandardGun); break; case WeaponStruct.Type.Rifle: shootFunction = new ShootFunction(Rifle); break; case WeaponStruct.Type.ShotGun: shootFunction = new ShootFunction(ShotGun); break; case WeaponStruct.Type.MachineGun: shootFunction = new ShootFunction(MachineGun); break; } }
public void EquipWeaponDirect(WeaponStruct wep) { currentWeapon = wep; WeaponStruct.Type wepType = currentWeapon.wepType; if (wepType != WeaponStruct.Type.Pistol) { if (wepType != WeaponStruct.Type.ShotGun) { if (wepType == WeaponStruct.Type.Rifle) { shootFunction = new ShootFunction(Rifle); } } else { shootFunction = new ShootFunction(ShotGun); } } else { shootFunction = new ShootFunction(MachineGun); } }