Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        strategyLayer = new StrategyLayer(faction);

        foreach (StrategyT strategy in strategySchedulers.Keys)
        {
            strategySchedulers[strategy].Initialize(faction);
        }

        militaryResourceAllocator = new MilitaryResourcesAllocator(faction, atkbase, defbase, atkhalf, defhalf);
        militaryResourceAllocator.SetOffensiveFactor(offensiveFactor);
    }
Ejemplo n.º 2
0
    void UpdateRealDist()
    {
        Dictionary <UnitT, int> modifications = new Dictionary <UnitT, int>()
        {
            { UnitT.MELEE, 0 },
            { UnitT.RANGED, 0 },
            { UnitT.SCOUT, 0 },
            { UnitT.ARTIL, 0 }
        };

        realDist = new Dictionary <UnitT, int>(idealDist);

        HashSet <AgentUnit> enemies = Map.GetEnemies(strategyManager.faction);


        StrategyLayer stratL       = strategyManager.GetStrategyLayer();
        StrategyT     mostPriority = StrategyT.DEF_BASE; // Hay que inicializarlo a la fuerza
        float         mostValue    = 0;

        foreach (KeyValuePair <StrategyT, float> tuple in stratL.priority)
        {
            if (tuple.Value > mostValue)
            {
                mostPriority = tuple.Key;
            }
        }

        if (mostPriority != StrategyT.ATK_BASE && mostPriority != StrategyT.DEF_BASE)
        {
            modifications[UnitT.ARTIL]  -= 2;
            modifications[UnitT.RANGED] += 2;
            //   Debug.Log("Como no estamos atacando ni defendiendo base principalmente, -2A, +2R");
        }

        int numberScouts  = 0;
        int numberRangeds = 0;

        foreach (AgentUnit enemy in enemies)
        {
            if (enemy is Scout)
            {
                numberScouts++;
            }
            else if (enemy is Ranged)
            {
                numberRangeds++;
            }
        }

        if (numberScouts >= 5)
        {
            modifications[UnitT.ARTIL]  += 2;
            modifications[UnitT.RANGED] -= 2;
            //   Debug.Log("Como hay muchos scouts enemigos, -2R, +2A");
        }

        numberRangeds -= 5;
        numberRangeds  = Mathf.Clamp(numberRangeds, -4, 8);
        modifications[UnitT.SCOUT] += numberRangeds;
        modifications[UnitT.MELEE] -= numberRangeds;
//        Debug.Log("Debido al numero de Rangeds rivales, " + numberRangeds + "S, " + (-numberRangeds) + "M");

        foreach (UnitT unit in modifications.Keys)
        {
            realDist[unit] += modifications[unit];
        }
    }