Ejemplo n.º 1
0
    void UnitSelection()
    {
        RaycastHit unitHit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out unitHit, 1000.0f, unitLayerMask))
        {
            if (selectedUnit == null)
            {
                selectedUnit = unitHit.collider.gameObject;
                if (SelectedUnit.gameObject.GetComponent <UnitStats>().isRed == ScriptLink.flowController.IsRedTurn)
                {
                    ScriptLink.unitMenuControl.HideUnitMenus();

                    ScriptLink.preDefinedActionTileSpawning.MovementTilesWithAttackRange();
                    busyWithAllyUnit = true;

                    SelectionBox.GetComponent <SpriteRenderer>().sprite = selectionBoxBlue;
                }
                else
                {
                    selectedUnit = null;
                }
            }
            else
            {
                GameObject oldSelection = SelectedUnit;
                selectedUnit = unitHit.collider.gameObject;
                if (oldSelection.gameObject.GetComponent <UnitStats>().isRed != ScriptLink.flowController.IsRedTurn) //This is keeping sure that we can't select enemy pieces
                {
                    selectedUnit = oldSelection;
                }
            }
        }
    }
Ejemplo n.º 2
0
 public void UnselectUnit()
 {
     busyWithAllyUnit = false;
     if (selectedUnit.GetComponent <Unit>().canMove == false && SelectedUnit.GetComponent <Unit>().canAttack == true) //We are attacking
     {
         selectedUnit.GetComponent <Unit>().canAttack = false;
         ScriptLink.unitMenuControl.unitInventory.SetActive(false);
     }
     if (selectedUnit.GetComponent <Unit>().canMove == false && SelectedUnit.GetComponent <Unit>().canAttack == false) //Unit done moving
     {
         ScriptLink.mouseController.SelectedUnit.GetComponent <Unit>().DarkenUnit();
     }
     if (selectedUnit != null) //We are moving
     {
         selectedUnit = null;
         ScriptLink.unitMenuControl.HideUnitMenus();
         ScriptLink.tileSpreadingManager.ClearActionTiles();
         SelectionBox.GetComponent <SpriteRenderer>().sprite = SelectionBoxYellow;
     }
 }