void ActionSend(string action)
    {
        if (acting)
        {
            CancelAction();
        }

        unit = turnOrder.currentOrder[0].GetComponent <UnitInfo>();

        UnitInfo.Action thisAct = actDesc.actions[action];

        if (unit.currMP < thisAct.cost)
        {
            return;
        }

        currAct = thisAct;

        int range = thisAct.range;

        int mp = thisAct.cost;

        if (thisAct.shape == "blast" && unit.status.ContainsKey("widen"))
        {
            mp *= 2;
        }


        string desc = thisAct.desc + "\n\rMP Cost: " + mp;

        descBox.text = desc;

        List <string> cond = new List <string>();

        cond.Add("noTerrain");
        cond.Add("noElevation");
        cond.Add("enemy");
        cond.Add("player");

        List <UnitInfo> targets = moveCalc.SingleTargetFinder(unit, range, unit.currentTile, thisAct.target);

        foreach (UnitInfo target in targets)
        {
            target.transform.Find("Pointer").gameObject.SetActive(true);
        }
        possTargets = targets;
        unitTarget  = true;

        if (!(thisAct.shape == "single" || thisAct.shape == "double"))
        {
            moveCalc.MoveFinder(range, unit.currentTile, cond);

            unitTarget = false;
        }

        if (thisAct.target == "self")
        {
            possTargets.Add(unit);
        }

        acting = true;
    }
Exemple #2
0
    public IEnumerator TakeAction(UnitInfo unit)
    {
        bool actionTaken = false;

        //if (unit.faction == "enemy")
        //{

        string actionName = "";

        List <string> actionNames = unit.actionNames;

        for (int i = 0; i < unit.actionNames.Count; i++)
        {
            actionName = actionNames[0];
            UnitInfo.Action thisAction = actDesc.actions[actionName];
            if (thisAction.target == "self")
            {
                MoveClosestEnemy(unit);

                yield return(new WaitForSeconds(2.0f));

                List <UnitInfo> self = new List <UnitInfo>();
                self.Add(unit);
                List <GameObject> selfTile = new List <GameObject>();
                selfTile.Add(unit.currentTile);

                yield return(actHand.ActionInterpreter(unit, actionNames[0], self, selfTile));

                turnHistory.AddMessage(unit.name + " used " + actionName);
                actionTaken = true;
                break;
            }
            if (thisAction.target == "enemy")
            {
                if (CanReach(unit, thisAction.range, thisAction.rad, "enemy"))
                {
                    List <UnitInfo> targ = new List <UnitInfo>();
                    targ.Add(targetUnit);

                    List <GameObject> tile = new List <GameObject>();
                    tile.Add(targetUnit.currentTile);

                    cubeClick.MoveToTile(moveTile, unit.gameObject);
                    yield return(new WaitForSeconds(2.0f));

                    turnHistory.AddMessage(unit.name + " used " + actionName + " on " + targetUnit.name);
                    yield return(actHand.ActionInterpreter(unit, actionName, targ, tile));


                    actionTaken = true;
                    break;
                }
            }
            if (thisAction.target == "ally")
            {
                if (CanReach(unit, thisAction.range, thisAction.rad, "ally"))
                {
                    List <UnitInfo> targ = new List <UnitInfo>();
                    targ.Add(targetUnit);

                    List <GameObject> tile = new List <GameObject>();
                    tile.Add(targetUnit.currentTile);

                    cubeClick.MoveToTile(moveTile, unit.gameObject);
                    yield return(new WaitForSeconds(2.0f));

                    yield return(actHand.ActionInterpreter(unit, actionName, targ, tile));

                    actionTaken = true;
                    break;
                }
            }
            else
            {
                if (CanReach(unit, thisAction.range, thisAction.rad, thisAction.target))
                {
                    List <GameObject> tile = listTiles;

                    foreach (UnitInfo targ in allTargets)
                    {
                        turnHistory.AddMessage(unit.name + " uses " + thisAction.name + " on " + targ.name);
                        tile.Add(targ.currentTile);
                    }

                    cubeClick.MoveToTile(moveTile, unit.gameObject);

                    yield return(new WaitForSeconds(2.0f));

                    yield return(actHand.ActionInterpreter(unit, actionName, allTargets, tile));

                    actionTaken = true;
                    break;
                }
            }

            actionNames.Remove(actionName);
            actionNames.Add(actionName);
        }

        if (actionTaken == true)
        {
            actionNames.Remove(actionName);
            actionNames.Add(actionName);
            unit.actionNames = actionNames;
        }
        else
        {
            turnHistory.AddMessage(unit.name + " moves");
            MoveClosestEnemy(unit);
            yield return(new WaitForSeconds(2.0f));
        }
        // }
    }