Beispiel #1
0
 void OnMouseEnter()
 {
     //Checks to make sure the mouse isn't also over a UI element.
     if (_eventSystem.IsPointerOverGameObject())
     {
         return;
     }
     //If a tool is selected
     if (Tools.currentTool != null && Tools.currentTool.getName() != "Inspect" && Tools.currentTool.getName() != "Elevator")
     {
         if (Tools.currentTool.getName().Equals("Empty") && buildingType != 3 && buildingType != 9)
         {
             GetComponent <SpriteRenderer>().color = Color.red;
         }
         TowerMap tower = GameObject.Find("Tower").GetComponent <TowerMap>();
         //If the building type isnt empty or not yet set
         if ((buildingType == -1 || buildingType == 3 || buildingType == 9) && !isOccupied)
         {
             GetComponent <SpriteRenderer>().sprite       = GameObject.Find("Tower").GetComponent <TowerMap>().getBuildingData().Find(x => x.getTypeName().Equals(Tools.currentTool.getName())).getEmptySprite();
             GetComponent <SpriteRenderer>().color        = tower.getCurrentMapColor(this);
             GetComponent <SpriteRenderer>().sortingOrder = 10;
         }
     }
     if (Input.GetMouseButton(0))
     {
         isInspecting = false;
     }
 }
Beispiel #2
0
    //Removes the cursor sprite
    void OnMouseExit()
    {
        TowerMap tower = GameObject.Find("Tower").GetComponent <TowerMap>();

        GetComponent <SpriteRenderer>().sprite = buildingSprite;
        if (!(buildingType == -1 || buildingType == 3 || buildingType == 9))
        {
            GetComponent <SpriteRenderer>().color        = tower.getCurrentMapColor(this);
            GetComponent <SpriteRenderer>().sortingOrder = 1;
        }
        else if (buildingType == 3 || buildingType == 9)
        {
            GetComponent <SpriteRenderer>().color        = tower.getCurrentMapColor(this);
            GetComponent <SpriteRenderer>().sortingOrder = 0;
        }
        else
        {
            GetComponent <SpriteRenderer>().sprite = null;
        }
        isInspecting = true;
    }