Пример #1
0
    void UnitSelectionOptions()
    {
        bool unitNull = SelectedUnit == null;

        if (unitNull && ScriptLink.UIcontroller.gameStatsBar.activeSelf == true) //We are selecting
        {
            UnitSelection();
        }
        else if (unitNull == false && SelectedUnit.GetComponent <Unit>().canMove == false && SelectedUnit.GetComponent <Unit>().canAttack == true) //We are attacking
        {
            if (mouseLocation == new Vector2(SelectedUnit.transform.position.x, SelectedUnit.transform.position.y))
            {
                UnselectUnit();
            }
            if (SelectedUnit != null && SelectedUnit.GetComponent <UnitStats>().UnitIdentity == UnitStats.UnitType.Artillery && SelectedUnit.GetComponent <Unit>().artilleryCanMove == false)
            {
                SelectedUnit.GetComponent <Unit>().artilleryCanMove = true;
                UnselectUnit();
            }
            CanWeAttack();
        }
        else if (unitNull == false && SelectedUnit.gameObject.GetComponent <UnitStats>().isRed == ScriptLink.flowController.IsRedTurn) //We are moving
        {
            LocationSelection();
        }
    }
Пример #2
0
 void MovementTileCheck()
 {
     if (ScriptLink.tileSpreadingManager.actionTiles[(int)unitSelectionLocation.x, (int)unitSelectionLocation.y] != null)
     {
         if (ScriptLink.tileSpreadingManager.actionTiles[(int)unitSelectionLocation.x, (int)unitSelectionLocation.y].GetComponent <ActionTileProperties>().actionType == ActionTileProperties.ActionType.Movement_Valid)
         {
             SelectedUnit.GetComponent <Unit>().LocationSelected();
         }
     }
 }
Пример #3
0
 /// <summary>
 /// Deselects an unit, removing the <see cref="SelectedUnit"/> component and turning it back to its default state
 /// </summary>
 private void deselectUnit()
 {
     if (SelectedUnit != null)
     {
         var selectedUnitComponent = SelectedUnit.GetComponent <SelectedUnit>();
         selectedUnitComponent.Deselect();
         Destroy(selectedUnitComponent);
         MatchManager.DeactivateUIForUnit(SelectedUnit);
         SelectedUnit = null;
     }
 }
Пример #4
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;
     }
 }
Пример #5
0
    void CanWeAttack()
    {
        RaycastHit UnitHit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out UnitHit, 1000.0f, unitLayerMask))
        {
            enemyUnit = UnitHit.collider.gameObject;
            if (EnemyUnit.GetComponent <UnitStats>().isRed != ScriptLink.flowController.IsRedTurn)
            {
                if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y] != null)
                {
                    if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].GetComponent <ActionTileProperties>().actionType == ActionTileProperties.ActionType.Attack_Valid)
                    {
                        if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].transform.position.x == EnemyUnit.transform.position.x)
                        {
                            if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].transform.position.y == EnemyUnit.transform.position.y)
                            {
                                SelectedUnit.GetComponent <UnitAttacking>().Attack();
                            }
                        }
                    }
                }
            }
            else
            {
                if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y] != null)
                {
                    if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].GetComponent <ActionTileProperties>().actionType == ActionTileProperties.ActionType.Assist_Valid)
                    {
                        if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].transform.position.x == EnemyUnit.transform.position.x)
                        {
                            if (ScriptLink.tileSpreadingManager.actionTiles[(int)mouseLocation.x, (int)mouseLocation.y].transform.position.y == EnemyUnit.transform.position.y)
                            {
                                SelectedUnit.GetComponent <UnitAssisting>().Assist();
                            }
                        }
                    }
                }
            }
        }
    }