private void setGunUI(int jValue) { int j = jValue; foreach (GameObject gun in containers) { GunContainer gunContainer = gun.GetComponent <GunContainer>(); if (gunContainer.index == j) { containersOrdered[j] = gunContainer; j++; } } if (j < containers.Length) { setGunUI(j); } else { gunsBullets = new int[allGuns.Length]; int i = 0; foreach (Gun gun in allGuns) { gunsBullets[i] = gun.projectilesPerMag; containersOrdered[i].setImage(gun.image); i++; } } updateGunUISelect(); }
public void DropCurrentWeapon() { GunContainer dropGunContainer = ((GameObject)Instantiate(gunContainerPrefab, GetSpawnLocation(), new Quaternion())).GetComponent <GunContainer>(); dropGunContainer.SetContainedGun(currentWeapon); currentWeapon = null; }
public void SpawnWeapon() { GameObject gunContainer = (GameObject)Instantiate(containerPrefab, transform.position, new Quaternion()); GunContainer gunContainerScript = gunContainer.GetComponent <GunContainer>(); gunContainerScript.SetContainedGun(((GameObject)Instantiate(weapon)).GetComponent <IWeapon>()); //NetworkServer.Spawn(gunContainer); }
private void Start() { container = magazine.GetComponent <GunContainer>(); container.SetFillPercentage(0); timeSinceLastEmpty = _emptyingTimeout; audioSource = GetComponent <AudioSource>(); }
private void UpdateContainer() { container = magazine.GetComponent <GunContainer>(); container.SetFillPercentage(containerFill); if (colorInContainer != null) { container.SetColor(colorInContainer.Value); } }
public void SwapGun() { DropCurrentWeapon(); GunContainer pickupGunContainer = swapableGunContainer; SetWeapon(pickupGunContainer.GetContainedGun()); pickupGunContainer.DestroyContainer(); //RpcUpdatePlayerGun(GetComponent<NetworkIdentity>().netId, newGun.GetComponent<NetworkIdentity>().netId, newGunScript.ammoData); //RpcUpdateContainerGun(newGunContainer.GetComponent<NetworkIdentity>().netId, oldGun.GetComponent<NetworkIdentity>().netId, oldGunScript.ammoData); }
//[Command] //public void CmdDropCurrentWeapon() //{ // GameObject newGunContainer = (GameObject)Instantiate(this.gunContainerPrefab, GetBulletSpawnLocation(), new Quaternion()); // GunContainer newGunContainerScript = newGunContainer.GetComponent<GunContainer>(); // GameObject oldGun = currentGunObject; // IGun oldGunScript = oldGun.GetComponent<IGun>(); // //newGunContainerScript.SetContainedGun(oldGun); // NetworkServer.Spawn(newGunContainer); // currentGunObject = null; // currentGun = null; // //RpcUpdateContainerGun(newGunContainer.GetComponent<NetworkIdentity>().netId, oldGun.GetComponent<NetworkIdentity>().netId, oldGunScript.ammoData); //} //================================================================================================= //Client Functions //================================================================================================= //[ClientRpc] //public void RpcUpdatePlayerGun(NetworkInstanceId gunID) //{ // if (isServer) // return; // SetPlayersGun(ClientScene.FindLocalObject(gunID)); //} //[ClientRpc] //public void RpcUpdateContainerGun(NetworkInstanceId containerID, NetworkInstanceId gunID, GunBase.AmmoData ammoData) //{ // if (isServer) // return; // GameObject gunContainerPrefab = ClientScene.FindLocalObject(containerID); // GunContainer gunContainerScript = gunContainerPrefab.GetComponent<GunContainer>(); // gunContainerScript.SetContainedGun(ClientScene.FindLocalObject(gunID)); // GunBase containerGunScript = gunContainerScript.containedGun.GetComponent<GunBase>(); // containerGunScript.ammoData = ammoData; //} //Sets the gun container that the player is currently able to pick up public void SetSwappableGunContainer(GunContainer gunContainer) { this.swapableGunContainer = gunContainer; if (gunContainer == null || gunContainer.GetContainedGun() == null) { //Debug.LogWarning("Container: " + gunContainer); //Debug.LogWarning("Gun: " + gunContainer.GetContainedGun().GetWeaponName()); playerHud.ClearWeaponPickupName(); } else { playerHud.SetWeaponPickupName(gunContainer.GetContainedGun().GetWeaponName()); } }
protected override void Init() { target = PlayerMovement.Instance.transform; if (gunNr == -1) { gun = GunContainer.GetRandomGun(); } else { gun = GunContainer.GetGun(gunNr); } bias = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)) * biasStrength; readyToFire = false; Invoke(nameof(FireCooldown), gun.GetFireRate() * GetFirerateMultiplier()); health += Game.Instance.GetEnemyHealth(); GenerateDungeon.Instance.objects.Add(gameObject); }
void Awake() { s = this; }
private void Start() { gun = GunContainer.GetGun(gunNr); }