private void OnTriggerEnter2D(Collider2D collision) { int indexMetal = Mathf.RoundToInt(UnityEngine.Random.Range(1f, 3f)); int gainMoney = Mathf.RoundToInt(UnityEngine.Random.Range(5f, 15f)); float gainEnergy = UnityEngine.Random.Range(1f, 3f); if (collision.tag == "Player") { switch (objet.gainType) { case ObjectClass.GainType.MONEY: PlayerMoney pm = collision.gameObject.GetComponent <PlayerMoney>(); if (indexMetal == 1) { anim.SetBool("scrap1", true); anim.SetBool("scrap2", false); anim.SetBool("scrap3", false); } else { if (indexMetal == 2) { anim.SetBool("scrap1", false); anim.SetBool("scrap2", true); anim.SetBool("scrap3", false); } else { if (indexMetal == 3) { anim.SetBool("scrap1", false); anim.SetBool("scrap2", false); anim.SetBool("scrap3", true); } } } pm.AddMoney(gainMoney); break; case ObjectClass.GainType.ENERGY: PlayerRage pr = collision.gameObject.GetComponent <PlayerRage>(); pr.AddEnergy(gainEnergy); break; case ObjectClass.GainType.ARMOR: PlayerUI pui = collision.gameObject.GetComponent <PlayerUI>(); pui.previousShield = 0; break; } Destroy(gameObject, 0.5f); } }
private void Start() { rage = GetComponent <PlayerRage>(); mainMenu = FindObjectOfType <MainMenu>(); interMenu = FindObjectOfType <InterLevelMenu>(); pauseMenu = FindObjectOfType <PauseMenu>(); animator = GetComponent <Animator>(); renderer = GetComponent <SpriteRenderer>(); actualOrientation = Orientation.HORIZONTAL; sound = GetComponent <SoundPlayerManager>(); Camera.main.GetComponent <CameraManager>().AddPlayer(this.transform); }
// Start is called before the first frame update void Start() { playerStats = GetComponent <PlayerLife>(); playerRage = GetComponent <PlayerRage>(); }