예제 #1
0
 void Update()
 {
     ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     if (buildingPlane.Raycast(ray, out distance))
     {
         position = ray.GetPoint(distance);
         if (newBuilding)
         {
             newBuilding.transform.position = position;
         }
     }
     if (isBuilding == true)
     {
         if (Input.GetKeyDown(KeyCode.Mouse0) && FindObjectOfType <CheckGroundBelow> ().canBuild == true)
         {
             BuildingControl bc = newBuilding.GetComponent <BuildingControl> ();
             if (bc.type.ToString() == "camp")
             {
                 bc.SetSpawnPoints(bc.maxSpace / 2, 3, bc.gameObject.transform.position);
                 bc.SetSpawnPoints(bc.maxSpace / 2, 4, bc.gameObject.transform.position);
                 bc.SpawnCampUnits();
             }
             if (bc.type.ToString() == "lumbermill")
             {
             }
             newBuilding = null;
             isBuilding  = false;
         }
     }
 }
예제 #2
0
        public void BuildBaracks()
        {
            FindObjectOfType <CursorControl> ().CursorToCenter();
            int money = 100;

            if (money >= 20)
            {
                newBuilding = (GameObject)PhotonNetwork.Instantiate("pref_baracks", position, barracksPrefab.transform.rotation, 0, null);
                //TODO Save player camp to the database.
                BuildingControl bc = newBuilding.GetComponent <BuildingControl> ();
                //PhotonView pw = newBuilding.GetComponent<PhotonView> ();
                bc.SetToBaracks(FindObjectOfType <GameManager> ().userId, 0);
                isBuilding = true;
            }
        }
예제 #3
0
 void CheckRaycast()
 {
     if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit))
     {
         buildingControl = hit.transform.GetComponent <BuildingControl> ();
         if (hit.transform.name.Contains("BackgroundPlane"))
         {
             return;
             //currentPointing = null;
         }
         else
         {
             currentPointing = hit.transform.gameObject;
         }
         if (Input.GetMouseButtonDown(0))
         {
             currentSelectedObject = currentPointing;
             CheckOwner();
         }
     }
 }
예제 #4
0
 public void SetCurrentSelected(GameObject obj)
 {
     currentSelectedObject = obj;
     buildingControl       = null;
 }