private void OnTriggerExit2D(Collider2D other) { if (other.tag == GameConfiguration.PLAYER_TAG) { _pigController = null; } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == GameConfiguration.PLAYER_TAG) { _pigController = other.GetComponent <PigController>(); } }
// Start is called before the first frame update void Awake() { m_PigController = GetComponent <PigController>(); GameGlobals.OnGameOver += GameOver; GameGlobals.OnGameRestart += GameRestart; m_PigController.OnCoinCountChanged += CoinCountChanged; m_Coins = new List <CoinVisualAnimation>(); m_CoinCounterInitialPosition = m_CoinCounterText.rectTransform.localPosition; m_CoinCounterInitialColor = m_CoinCounterText.color; }
void SpawnPig(Transform target) { if (target == null) { Debug.Log("Unable to spawn pig to target. Transform is null"); return; } GameObject pig = Instantiate(m_pigPrefabs[0], m_pigParent); PigController pigController = pig.GetComponent <PigController>(); pigController.SetTargetPosition(target); pigController.transform.position = m_currentFabricator.GetSpawnLocation().position; }
void ApplyDamage(GameObject other) { if (other.tag == "PigTag") { Pigscript = (PigController)other.GetComponent(typeof(PigController)); Pigscript.HpController(power); } if (other.tag == "TreeTag") { Treescript = (TreeController)other.GetComponent(typeof(TreeController)); Treescript.HpController(power); } if (other.tag == "StoneTag") { Stonescript = (StoneController)other.GetComponent(typeof(StoneController)); Stonescript.HpController(power); } }
public void ChangeScore(PigController pig) { AudioPlayer.PlayClip(GetComponent <AudioSource>().clip, .8f); pig.ChangeCoinCount(1); Destroy(gameObject); }
public void ChangeScore(PigController pig) { pig.ChangeCoinCount(amount); Destroy(gameObject); }