コード例 #1
0
 void Update()
 {
     if (!EventSystem.current.IsPointerOverGameObject())
     {
         // auka check /ar til m'us getur ekki fari[ ut fyrir map
         if (GetCellUnderCursor() != null)
         {
             if (GetCellUnderCursor().Unit != null)
             {
                 canvasHoover.enabled = true;
                 hoover.UpdateUnitInfoPanel(GetCellUnderCursor().Unit);
             }
             else
             {
                 canvasHoover.enabled = false;
             }
         }
         if (Input.GetMouseButton(0))
         {
             HandleInput();
             return;
         }
         if (Input.GetKeyDown(KeyCode.U))
         {
             CreateRandomUnit();
             return;
         }
         if (Input.GetKeyDown(KeyCode.I))
         {
             DestroyUnit();
             return;
         }
     }
     previousCell = null;
 }
コード例 #2
0
    /// <summary>
    /// Does the selection.
    /// </summary>
    void DoSelection()
    {
        grid.ClearPath();
        grid.ClearTilesInRange();
        grid.ClearAttackableTiles();


        print(currentTeamTurn);
        if (UpdateCurrentCell())
        {
            if (currentCell.Unit != null && currentCell.Unit.Team == currentTeamTurn)
            {
                selectedUnit = currentCell.Unit;
                text.UpdateUnitInfoPanel(selectedUnit);
                if (selectedUnit.CurrentCooldown < turn + 1)
                {
                    SoundManager.instance.PlayRandomVoiceline(selectedVoicelines);
                    if (selectedUnit != null)
                    {
                        grid.FindReachableTiles(currentCell, selectedUnit.Speed);
                        grid.FindAttackableTiles(currentCell, selectedUnit.Range, selectedUnit.Team);
                    }
                }
                else
                {
                    selectedUnit = null;
                    currentCell  = null;
                }
            }
        }
        else
        {
            //deselectum unitinn
            currentCell = null;
        }
    }