Пример #1
0
 void RightClickSelection()
 {
     if (_RayInfo.ObjectRaycast().GetComponent <ISelectable>() != null)
     {
         ISelectable selectObject = _RayInfo.ObjectRaycast().GetComponent <ISelectable>();
         selectObject.GetObject();
         InteractObject(selectObject);
         //Currently selected object will attempt to interact with the object
         if (_CurrentlySelectedObject != null)
         {
             _CurrentlySelectedObject.InteractWithObject(selectObject);
             foreach (ISelectable selectable in _MultiSelectedVillagers)
             {
                 selectable.InteractWithObject(selectObject);
             }
             return;
         }
     }
     else
     {
         _HighlightInteract.transform.position = _RayInfo.LocationToBuild();
         _HighlightInteract.GetComponent <Animator>().SetTrigger("Interact");
     }
     if (_CurrentlySelectedObject != null)
     {
         _CurrentlySelectedObject.InteractWithLocation(_RayInfo.LocationToBuild());
         foreach (ISelectable selectable in _MultiSelectedVillagers)
         {
             selectable.InteractWithLocation(_RayInfo.LocationToBuild());
         }
     }
 }
Пример #2
0
    private void Update()
    {
        //Default Update position
        if (_RotatingObject == false)
        {
            _ContructionSphere.transform.position = _RayInfo.LocationToBuild();
        }
        else
        {
            Vector3 pos = _RayInfo.LocationToBuild();
            _ContructionSphere.transform.LookAt(new Vector3(pos.x, _ContructionSphere.position.y, pos.z));
        }
        if (_BuildCheck.CanBuild == true)
        {
            if (Input.GetMouseButtonUp(0) && _CanPlaceObject == true)
            {
                //Skip rotation for walls

                if (_BuildingDetails._BuildingType == BuildingType.Wall)
                {
                    PlaceNewBuilding();
                    return;
                }
                else
                {
                    _RotatingObject = true;
                }
            }
            if (Input.GetMouseButtonDown(0) && _RotatingObject == true)
            {
                PlaceNewBuilding();
            }
        }
        if (Input.GetMouseButtonDown(1))
        {
            CancelBuildOrder();
        }
    }