Ejemplo n.º 1
0
 public void OnPointerUp(PointerEventData eventData)
 {
     if (holdingBuilding)
     {
         Vector3 pos = currentCamera.ScreenToWorldPoint(Input.mousePosition);
         pos.z = 0;
         pos.x = Mathf.RoundToInt(pos.x);
         pos.y = Mathf.RoundToInt(pos.y);
         if (boxCollider.IsTouchingLayers(buildingLayerMask))
         {
             audioSource.PlayOneShot(cantBuildSound);
             resourceController.AddResources(woodCost, goldCost, foodCost);
             populationController.freeVillager(villagerCost);
             Destroy(heldBuilding);
         }
         else
         {
             audioSource.PlayOneShot(buildOnGroundSound);
         }
         heldBuilding.transform.GetChild(0).GetComponent <SpriteRenderer>().sortingOrder = 5;
         heldBuilding.GetComponent <Building>().buildingPlaced = true;
         heldBuilding    = null;
         holdingBuilding = false;
     }
     cameraMove.CanMove        = true;
     gameController.isBuilding = false;
 }