Esempio n. 1
0
    public bool MoveToBetterPositon()
    {
        MapControl.SafePositionRequest posRequest = new MapControl.SafePositionRequest(
            transform.position, unitControl.TeamName, 5);
        posRequest.excludeCenter = true;
        MapCellData myCell   = mapControl.GetData(transform.position);
        MapCellData safeCell = mapControl.GetSafestPosition(posRequest);

        if (safeCell.lastScoreCheck > mapControl.GetCellScore(myCell, unitControl.TeamName))
        {
            unitControl.MoveTo(safeCell.position);
            Debug.Log("Moving to a better position");
            State = "Moving";
            return(true);
        }
        return(false);
    }
Esempio n. 2
0
 void HandleAppButton()
 {
     if (GvrControllerInput.AppButtonDown)
     {
         movingUI.IsVisible = true;
     }
     if (GvrControllerInput.AppButton)
     {
         LayerMask  terrainMask = 1 << LayerMask.NameToLayer("Terrain");
         RaycastHit hit;
         if (Physics.Raycast(cameraControl.GetControllerRay(), out hit, 20, terrainMask))
         {
             if (hit.transform.tag.Equals("Map"))
             {
                 movingUI.SetPos(hit.point);
             }
             else
             {
                 movingUI.IsVisible = false;
             }
         }
         else
         {
             movingUI.IsVisible = false;
         }
     }
     if (GvrControllerInput.AppButtonUp)
     {
         Vector3 movePos = movingUI.transform.position;
         if (movingUI.IsVisible &&
             !Physics.Linecast(
                 movePos + (Vector3.up * 5),
                 movePos + (Vector3.up * 0.5f)))
         {
             playerControl.MoveTo(movingUI.transform.position);
         }
         movingUI.IsVisible = false;
     }
 }