// Update is called once per frame void Update() { if (cannon == null) { cannon = GameObject.FindObjectOfType <PlayerCannon>(); if (cannon == null) { return; } } if (cannon.Ammo <= 0) { NoAmmo.SetActive(true); } else { NoAmmo.SetActive(false); } while (cannon.Ammo > this.transform.childCount) { // Spawn some icons Instantiate(AmmoIconPrefab, this.transform); } while (cannon.Ammo < this.transform.childCount) { Transform t = this.transform.GetChild(0); t.SetParent(null); Destroy(t.gameObject); } }
public void Player_Projectile() { float ability = Input.GetAxis("Projectile"); if (ability > 0 && (abilityEnergy > projectRequirements)) { PlayerCannon pc = playerCannon.GetComponent <PlayerCannon>(); pc.projectileDamage = projectileDamage; pc.projectileRange = projectileRange; pc.projectileSpeed = projectileSpeed; pc.DetectAndFire(); abilityEnergy -= projectRequirements; } }
private void Awake() { if (photonView.IsMine) { photonView.RPC(nameof(RPC_SetSubSettings), RpcTarget.AllBufferedViaServer, GameManager.SP.playerData.subBaseSelected, GameManager.SP.playerData.subEngineSelected, GameManager.SP.playerData.subCannonSelected); } sp = GetComponent <SonarPool>(); pm = GetComponent <PlayerMovement>(); pb = GetComponentInChildren <ParticleBehaviour>(); pc = GetComponent <PlayerCannon>(); ph = GetComponent <PlayerHealth>(); }
// Start is called before the first frame update void Start() { GameObject tempObj = GameObject.Find("PlayerShip"); tempHeat = tempObj.GetComponent <PlayerCannon>(); }