示例#1
0
 void OnCollisionStay2D(Collision2D collider)
 {
     // collision avec le puit et touche espace pour remplir l'arrosoire
     if (collider.gameObject.name == "Puit" && Input.GetKeyDown(KeyCode.Space))
     {
         if (objectC.objectCurrent.itemName == "WateringCan")
         {
             objectC.objectCurrent.itemPower = 41;
             FM_SonScript.sonOutil("event:/Outil/remplirArrosoir");
         }
     }
 }
示例#2
0
    public void useObject(Vector2 direction)
    {
        Vector3 pos = transform.position;

        if (objectCurrent != null)
        {
            if (objectCurrent.itemType != Item.ItemType.Tool)
            {
                if (objectCurrent.itemType == Item.ItemType.Graine)
                {
                    for (int i = 0; i < (int)PlantList.plant_number; i++)
                    {
                        if (((PlantList)i).ToString() == objectCurrent.itemName)
                        {
                            if (Map.ajoutPlante(((PlantList)i), new Vector3(pos.x + direction.x, pos.y + direction.y, 0)))
                            {
                                objectCurrent.itemValue--;
                                pathSoundObject = "event:/Outil/Semer";
                                FM_SonScript.sonOutil(pathSoundObject);
                            }
                        }
                    }
                }
                else if (objectCurrent.itemType == Item.ItemType.Mobilier)
                {
                    MapTile tile = Map.getTileAt(new Vector3(pos.x + direction.x, pos.y + direction.y, 0));
                    if (tile != null)
                    {
                        if (objectCurrent.itemName == "sprinkler")
                        {
                            tile.addObject(new Sprinkler());
                            objectCurrent.itemValue--;
                        }
                    }
                }

                else
                {
                    objectCurrent.itemValue--;
                }
                if (objectCurrent.itemValue <= 0)
                {
                    objet.SetActive(false);
                    objectCurrent = new Item();
                }
            }
            else
            {
                if (objectCurrent.itemName != "WateringCan" || (objectCurrent.itemName == "WateringCan" && objectCurrent.itemPower > 0))
                {
                    Map.useTool(tool.GetComponent <toolController>().currentTool, new Vector3(pos.x + direction.x, pos.y + direction.y, 0));
                    FM_SonScript.sonOutil(pathSoundObject);
                }
                if (objectCurrent.itemName == "WateringCan")
                {
                    if (objectCurrent.itemPower > 0)
                    {
                        objectCurrent.itemPower--;
                    }
                }
            }
        }
    }