Beispiel #1
0
 private void OnTriggerExit2D(Collider2D other)
 {
     if (other.tag == GameConfiguration.PLAYER_TAG)
     {
         _pigController = null;
     }
 }
Beispiel #2
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == GameConfiguration.PLAYER_TAG)
     {
         _pigController = other.GetComponent <PigController>();
     }
 }
Beispiel #3
0
 // 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;
 }
Beispiel #4
0
    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;
    }
Beispiel #5
0
    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);
        }
    }
Beispiel #6
0
 public void ChangeScore(PigController pig)
 {
     AudioPlayer.PlayClip(GetComponent <AudioSource>().clip, .8f);
     pig.ChangeCoinCount(1);
     Destroy(gameObject);
 }
Beispiel #7
0
 public void ChangeScore(PigController pig)
 {
     pig.ChangeCoinCount(amount);
     Destroy(gameObject);
 }