public void CmdInstantiateMultiShot(WeaponCall weaponLevel, SpawnLocationCall locationLevel, int spawnNumbers, float angleSpread) { GameObject shotPrefab; Transform shotLocation; if (!shotWeaponsMap.TryGetValue((int)weaponLevel, out shotPrefab) || !spawnLocationMap.TryGetValue((int)locationLevel, out shotLocation)) { Debug.LogWarning("Weapon or Spawn Location not found!"); return; } else { Dictionary<GameObject, float> weaponDictionary = weaponCooldownGrid[shotLocation]; if (weaponDictionary[shotPrefab] <= 0) { //Vector3 newSpawnLocation = new Vector3(shotLocation.eulerAngles.x, shotLocation.eulerAngles.y, shotLocation.eulerAngles.z - angleSpread); shotLocation.eulerAngles -= new Vector3(0, 0, angleSpread / 2); for (int i = 0; i < spawnNumbers; i++) { GameObject shot = (GameObject)Instantiate(shotPrefab, shotLocation.position, shotLocation.rotation); NetworkServer.Spawn(shot); shotLocation.eulerAngles += new Vector3(0, 0, angleSpread / (spawnNumbers - 1)); } shotLocation.eulerAngles -= new Vector3(0, 0, angleSpread / (spawnNumbers - 1)); shotLocation.eulerAngles -= new Vector3(0, 0, angleSpread / 2); WeaponShot ws = shotPrefab.GetComponent<WeaponShot>(); weaponDictionary[shotPrefab] = ws.shotRate; } } return; }
public void CmdInstantiateShot(WeaponCall weaponLevel, SpawnLocationCall locationLevel) { GameObject shotPrefab; Transform shotLocation; if (!this.shotWeaponsMap.TryGetValue((int)weaponLevel, out shotPrefab) || !this.spawnLocationMap.TryGetValue((int)locationLevel, out shotLocation)) { Debug.LogWarning("Weapon or Spawn Location not found!"); return; } else { Dictionary<GameObject, float> weaponDictionary = this.weaponCooldownGrid[shotLocation]; if (weaponDictionary[shotPrefab] <= 0) { GameObject shot = (GameObject)Instantiate(shotPrefab, shotLocation.position, shotLocation.rotation); shot.GetComponent<Rigidbody2D>().velocity = this.GetComponent<Rigidbody2D>().velocity; NetworkServer.Spawn(shot); WeaponShot ws = shotPrefab.GetComponent<WeaponShot>(); weaponDictionary[shotPrefab] = ws.shotRate; } } return; }