예제 #1
0
    void CheckLeftClick()
    {
        if (!Input.GetMouseButtonDown(0))
        {
            return;
        }

        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, Mathf.Infinity))
        {
            GameObject hitObject = hit.collider.gameObject;

            TurbineController tubineController = hit.transform.GetComponentInParent <TurbineController>();
            if (tubineController != null)
            {
                UIScript.GetInstance().OpenTurbineMenu(tubineController);
            }

            WindVaneController windVaneController = hit.transform.GetComponentInParent <WindVaneController>();

            //if (windVaneController != null)
            //    OpenWindVaneMenu(windVaneController);
        }
    }
예제 #2
0
    void BuildNow(GridTile plantGrid, Vector3 plantPos)
    {
        if (isTurbine) // If we want to build a turbine...
        {
            curInstantiated.GetComponent <TurbineController>().enabled = true;
            world.AddTurbine(curInstantiated, plantPos, curInstantiated.transform.rotation, curInstantiated.GetComponent <SizeController>().desiredScale, GridTileOccupant.OccupantType.Turbine, TurbineManager.GetInstance().transform); // Let the world controller know we want to build this thing
            Renderer[] rens       = curInstantiated.GetComponentsInChildren <Renderer>();
            Renderer[] rensPrefab = curSelected.GetComponentsInChildren <Renderer>();
            int        count      = 0;
            foreach (Renderer ren in curInstantiated.GetComponentsInChildren <Renderer>())
            {
                foreach (Material mat in ren.materials)
                {
                    mat.shader = Shader.Find("Standard");
                    mat.color  = originalMaterial[count];
                    count++;
                }
            }
        }
        else
        {
            world.AddOther(curSelected, plantPos, curInstantiated.transform.rotation, curInstantiated.GetComponent <SizeController>().desiredScale, GridTileOccupant.OccupantType.Other, TerrainController.thisTerrainController.transform);
            Destroy(curInstantiated);
            WindVaneController windVaneController = curInstantiated.GetComponent <WindVaneController>();

            if (windVaneController != null)
            {
                windVaneController.enabled = true;
            }
        }
        GameResources.Buy(curInstantiated.GetComponent <PriceController>().price);
        curInstantiated = null;

        GameObject newObject = new GameObject();

        newObject.transform.parent = Camera.main.transform;
        AudioSource doefAudioSource = newObject.AddComponent <AudioSource>();

        doefAudioSource.clip = doef;
        doefAudioSource.Play();
        inBuildMode = false;
    }
예제 #3
0
 public void OpenWindVaneMenu(WindVaneController windVaneController)
 {
     //menus[6].SetActive(true);
     //menus[6].GetComponentInChildren<Canvas>().sortingOrder = activeUIElements + 1;
     activeUIElements++;
 }