Esempio n. 1
0
    private void BattlePhaseManager()
    {
        // comprueba que este en la fase de batalla
        if (!battleFase)
        {
            return;
        }

        // comprueba que sea el turno del jugador
        if (myTurnNumber != currentTurn)
        {
            return;
        }

        // comprueba si una unidad fue seleccionada
        if (selectedUnit == null)
        {
            foreach (UnitScript unit in army)
            {
                if (unit.CanMove() && unit.Selected())
                {
                    selectedUnit = unit;
                    break;
                }
            }
        }

        // maneja la unidad seleccionada
        if (selectedUnit != null)
        {
            if (!selectedUnit.IsMoving())
            {
                SelectTileToMove(selectedUnit);
            }

            // mueve la unidad si debe hacerlo
            selectedUnit.Move(worldPos);

            // ejecuta el ataque si existe un objetivo
            if (targetUnit != null)
            {
                // ejecuta el ataque sobre la unidad
                selectedUnit.Attack(targetUnit);

                targetUnit = null;
            }

            // comprueba si la unidad deja de estar seleccionada
            if (!selectedUnit.IsSelected() && !selectedUnit.IsMoving())
            {
                selectedUnit = null;
            }
        }
    }
Esempio n. 2
0
    void Update()
    {
        GameObject target = Search();

        if (null == target)
        {
            return;
        }

        UnitScript unit = target.GetComponent <UnitScript>();

        if (null != unit)
        {
            //Debug.Log(unit);
            myUnit.Attack(unit);
        }
    }