示例#1
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Player") && !collision.isTrigger)
     {
         if (myType == ObjectType.red)
         {
             pc.AddToInventory("Red", amount);
             GameObject fx = Instantiate(collectFX, new Vector3(transform.position.x, transform.position.y, -1), Quaternion.identity);
             Destroy(gameObject);
         }
         else if (myType == ObjectType.blue)
         {
             pc.AddToInventory("Blue", amount);
             GameObject fx = Instantiate(collectFX, new Vector3(transform.position.x, transform.position.y, -1), Quaternion.identity);
             Destroy(gameObject);
         }
         else if (myType == ObjectType.yellow)
         {
             pc.AddToInventory("Yellow", amount);
             GameObject fx = Instantiate(collectFX, new Vector3(transform.position.x, transform.position.y, -1), Quaternion.identity);
             Destroy(gameObject);
         }
     }
 }
示例#2
0
    IEnumerator Craft()
    {
        available = false;
        short c = 0;

        while (c < requirements.Length)
        {
            pc.resources[c, 0] -= requirements[c];
            c++;
        }
        pc.redCount.text    = pc.resources[0, 0].ToString();
        pc.blueCount.text   = pc.resources[1, 0].ToString();
        pc.yellowCount.text = pc.resources[2, 0].ToString();

        yield return(new WaitForSeconds(1));

        foreach (IconScript icon in FindObjectsOfType <IconScript>())
        {
            icon.Display();
        }
        pc.AddToInventory(item, 1);
        Check();
    }