Beispiel #1
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Ray        toMouse = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit rhInfo;
         bool       didHit = Physics.Raycast(toMouse, out rhInfo, 500.0f);
         if (didHit)
         {
             HouseValue thisHouse = rhInfo.collider.GetComponent <HouseValue>();
             isOwned = thisHouse.owned;
             if (didHit && thisHouse.isMansion)
             {
                 thisHouse.buyMansion();
                 if (thisHouse.winCheck)
                 {
                     thisScript.enabled = false;
                 }
             }
             else if (didHit && isOwned)
             {
                 //Debug.Log (rhInfo.collider.name + " -- is sold");
                 thisHouse.isSold();
                 Destroyable destScript = rhInfo.collider.GetComponent <Destroyable>();
                 if (destScript)
                 {
                     destScript.RemoveMe();
                 }
                 soldThis.Play();
             }
             else if (didHit && !isOwned)
             {
                 HouseValue bought = rhInfo.collider.GetComponent <HouseValue>();
                 if (bought)
                 {
                     bought.isBought();
                 }
             }
         }
         else
         {
             Debug.Log("Clicked on nothing");
         }
     }
 }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        toMouse = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit rhInfo;
            bool       didHit = Physics.Raycast(toMouse, out rhInfo);

            if (didHit)
            {
                Destroyable destroyableScript = rhInfo.collider.GetComponent <Destroyable>();
                if (destroyableScript)
                {
                    destroyableScript.RemoveMe();
                }
            }
        }
    }