Beispiel #1
0
    private void Start()
    {
        followMouse = false;
        isCoal      = false;
        GiftObject gift = GetComponent <GiftObject>();

        if (gift != null)
        {
            isCoal = gift.Obj == GiftObject.GObject.Coal;
        }
    }
Beispiel #2
0
    public void OnTriggerEnter(Collider other)
    {
        GiftObject gift = other.GetComponent <GiftObject>();

        if (gift != null)
        {
            //GameObject.FindGameObjectWithTag("NextButton").GetComponent<Button>().interactable = true;
            GameObject go      = Instantiate(packedGift, new Vector3(transform.parent.position.x, transform.parent.position.y + 2f), Quaternion.identity);
            GiftObject giftObj = go.AddComponent <GiftObject>();
            giftObj.Obj    = gift.Obj;
            giftObj.Wishes = GameObject.FindGameObjectWithTag("WishList").GetComponent <Wishlist>().wishesId;
            SpawnGift spawnGift = GameObject.FindGameObjectWithTag("GameManager").GetComponent <SpawnGift>();
            giftObj.Score         = spawnGift.GetScore();
            go.transform.rotation = Quaternion.Euler(new Vector3(90f, 0f, 0f));
            Destroy(other.gameObject);
            Destroy(transform.parent.gameObject);
        }
    }
Beispiel #3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Dest"))
     {
         Text       text          = GameObject.FindGameObjectWithTag("Score").GetComponent <Text>();
         GiftObject gift          = GetComponent <GiftObject>();
         float      mutliplicator = 1;
         if (gift.Obj == GiftObject.GObject.Coal)
         {
             mutliplicator *= -1f;
         }
         float score;
         if (gift.Obj == GiftObject.GObject.Coal || gift.Wishes.Contains((int)gift.Obj))
         {
             score = gift.Score * 10f * mutliplicator;
         }
         else
         {
             score = -20f;
         }
         if (score > 30f)
         {
             score = 30f;
         }
         if (score < -30f)
         {
             score = -30f;
         }
         if (score < 0f)
         {
             score *= 3f;
         }
         text.text = "Score: " + (int.Parse(text.text.Split(' ').Last()) + Mathf.Round(score)).ToString();
         SpawnGift spawnGift = GameObject.FindGameObjectWithTag("GameManager").GetComponent <SpawnGift>();
         spawnGift.Spawn();
         Destroy(gameObject);
     }
 }