Exemplo n.º 1
0
    private void OnEnable()
    {
        rewardUI = GetComponent <Text>();
        RewardHolder player = GameObject.FindGameObjectWithTag("Player").GetComponent <RewardHolder>();

        player.RewardGained += UpdateUI;
    }
Exemplo n.º 2
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (areaToExplore.Count > 0)
     {
         RewardHolder holder = collision.GetComponent <RewardHolder>();
         if (holder != null)
         {
             float explorationAngle = Vector2.Angle(transform.up, holder.transform.position - transform.position);
             float polarity         = holder.transform.position.x - transform.position.x;
             bool  found            = false;
             int   i = 0;
             while (!found & i < areaToExplore.Count)
             {
                 if (areaToExplore[i].beginAngle <= explorationAngle & areaToExplore[i].endAngle > explorationAngle & areaToExplore[i].polarity * polarity >= 0)
                 {
                     holder.GetReward(areaToExplore[i].value);
                     areaToExplore.Remove(areaToExplore[i]);
                 }
                 i++;
             }
         }
     }
 }