예제 #1
0
    protected static internal AccionCompuesta createAttackingAction(PersonajeBase sujeto, PersonajeBase receptor)
    {
        ActionGo      goToEnemy   = new ActionGo(sujeto, SimManagerFinal.positionToGrid(receptor.posicion), receptor);
        AccionAttack  attackEnemy = new AccionAttack(sujeto, receptor);
        List <Accion> orders      = new List <Accion> {
            goToEnemy, attackEnemy
        };
        AccionCompuesta ac = new AccionCompuesta(sujeto, orders, true);

        return(ac);
    }
예제 #2
0
    protected internal override List <Accion> getStrategyActions()
    {
        List <Accion> defensiveActions = new List <Accion>();

        foreach (PersonajeBase ally in allies)
        {
            if (!ally.isAlive())
            {
                continue;
            }
            //1 -  COMPROBAR SI HAY UNIDADES QUE NECESITEN CURACION
            if (!ally.isFullHealth())
            {
                if (!ally.isInCombat())               //Si no esta en combate
                {
                    if (!isInBaseRange(ally, baseCoords) && !alreadyComingToBase(ally))
                    {
                        Vector2  closestPoint = getUnitPointOnBase(ally, baseCoords);
                        ActionGo goToBase     = new ActionGo(ally, closestPoint, null);
                        defensiveActions.Add(goToBase);
                    }
                }
                else
                {
                    if (ally.betterToRun() && !alreadyComingToBase(ally))           //vida por debajo del 30%
                    {
                        if (!isInBaseRange(ally, baseCoords))
                        {
                            Vector2  closestPoint = getUnitPointOnBase(ally, baseCoords);
                            ActionGo goToBase     = new ActionGo(ally, closestPoint, null);
                            defensiveActions.Add(goToBase);
                        }
                    }
                }
            }
            else
            {
                //2 - COMPROBAR SI HAY ENEMIGOS EN EL AREA DE LA BASE INTERRUMPIENDO SPAWN
                List <PersonajeBase> enemies_attacking = enemiesOnBase();
                if (enemies_attacking.Count > 0 && !isGoingToAttack(ally))
                {
                    PersonajeBase closestEnemy = getClosestEnemy(ally, enemies_attacking);
                    ActionGo      goToEnemy    = new ActionGo(ally, SimManagerFinal.positionToGrid(closestEnemy.posicion), closestEnemy);
                    AccionAttack  attackEnemy  = new AccionAttack(ally, closestEnemy);
                    List <Accion> orders       = new List <Accion> {
                        goToEnemy, attackEnemy
                    };
                    AccionCompuesta defendBase = new AccionCompuesta(ally, orders, true);
                    defensiveActions.Add(defendBase);
                    defended = true;
                }
                else
                {
                    //3 -  COMPROBAR UNIDADES FUERA DEL PERIMETRO DE LA BASE
                    if (!isInBaseRange(ally, baseCoords) && !alreadyComingToBase(ally))
                    {
                        Vector2  closestPoint = getUnitPointOnBase(ally, baseCoords);
                        ActionGo goToBase     = new ActionGo(ally, closestPoint, null);
                        defensiveActions.Add(goToBase);
                    }
                    //4 - AGRUPAR UNIDADES DENTRO DEL PERIMETRO DE LA BASE
                }
            }
        }
        return(defensiveActions);
    }