Пример #1
0
 // deletes a unit from a group
 public void deleteUnitFromGroup(SavedUnitGroup group)
 {
     if (group.numUnits > 0)
     {
         group.numUnits--;
     }
 }
 // adds a unit group(on retreat)
 public void addUnitGroup(UnitGroupScript group)
 {
     SavedUnitGroup newUnitGroup = new SavedUnitGroup();
     newUnitGroup.normalUpgrades = new List<string>();
     newUnitGroup.numUnits = group.unitsInBaseScripts.Count;
     unitGroupsSaved.Add (newUnitGroup);
 }
Пример #3
0
    // adds a unit group(on retreat)
    public void addUnitGroup(UnitGroupScript group)
    {
        SavedUnitGroup newUnitGroup = new SavedUnitGroup();

        newUnitGroup.normalUpgrades = new List <string>();
        newUnitGroup.numUnits       = group.unitsInBaseScripts.Count;
        unitGroupsSaved.Add(newUnitGroup);
    }
 // deletes existing group
 // returns num units
 public int deleteUnitGroup(SavedUnitGroup group)
 {
     for(int i = unitGroupsSaved.Count - 1; i >= 0; i--) {
         if (unitGroupsSaved[i].unitGroupName  == group.unitGroupName)
         {
             unitGroupsSaved.RemoveAt(i);
         }
     }
     return group.numUnits;
 }
Пример #5
0
 // deletes existing group
 // returns num units
 public int deleteUnitGroup(SavedUnitGroup group)
 {
     for (int i = unitGroupsSaved.Count - 1; i >= 0; i--)
     {
         if (unitGroupsSaved[i].unitGroupName == group.unitGroupName)
         {
             unitGroupsSaved.RemoveAt(i);
         }
     }
     return(group.numUnits);
 }
 public void addUpgrade(string upgradeName, SavedUnitGroup group, bool type)
 {
     if(type) {
         if(group.normalUpgrades.Count < 4) {
             group.normalUpgrades.Add(upgradeName);
         }
     } else if(!type) {
         if(group.specialUpgrade == null) {
             group.specialUpgrade = upgradeName;
         }
     }
 }
    // creates new(empty) group
    public SavedUnitGroup createNewGroup()
    {
        SavedUnitGroup newUnitGroup = new SavedUnitGroup();
        newUnitGroup.unitGroupName = "Standard Ants " + unitGroupCounter.ToString();
        unitGroupCounter++;
        newUnitGroup.normalUpgrades = new List<string>();
        //newUnitGroup.normalUpgrades.Add("Heal");
        //newUnitGroup.normalUpgrades.Add("Moral");
        unitGroupsSaved.Add (newUnitGroup);

        return newUnitGroup;
    }
Пример #8
0
    // creates new(empty) group
    public SavedUnitGroup createNewGroup()
    {
        SavedUnitGroup newUnitGroup = new SavedUnitGroup();

        newUnitGroup.unitGroupName = "Standard Ants " + unitGroupCounter.ToString();
        unitGroupCounter++;
        newUnitGroup.normalUpgrades = new List <string>();
        //newUnitGroup.normalUpgrades.Add("Heal");
        //newUnitGroup.normalUpgrades.Add("Moral");
        unitGroupsSaved.Add(newUnitGroup);

        return(newUnitGroup);
    }
Пример #9
0
 public void addUpgrade(string upgradeName, SavedUnitGroup group, bool type)
 {
     if (type)
     {
         if (group.normalUpgrades.Count < 4)
         {
             group.normalUpgrades.Add(upgradeName);
         }
     }
     else if (!type)
     {
         if (group.specialUpgrade == null)
         {
             group.specialUpgrade = upgradeName;
         }
     }
 }
Пример #10
0
    // adds a unit group(on retreat)
    public void addUnitGroup(UnitGroupBase group)
    {
        SavedUnitGroup newUnitGroup = new SavedUnitGroup();

        newUnitGroup.position = new Vector3(transform.position.x + 5, transform.position.y, transform.position.z);
        newUnitGroup.unitGroupName = group.name;
        newUnitGroup.attackspeed = group.attackspeed;
        newUnitGroup.movementspeed = group.movementspeed;

        newUnitGroup.damage = group.damage;
        newUnitGroup.health = group.health;
        newUnitGroup.regeneration = group.regeneration;

        newUnitGroup.attackrange = group.attackrange;
        newUnitGroup.visionRange = group.visionRange;

        newUnitGroup.numUnits = group.numUnitsInGroup;
        unitGroupsSaved.Add (newUnitGroup);
    }
Пример #11
0
 public void create_new_group()
 {
     /*foreach (UnitGroupFriendly item in GameObject.Find(vars.UnitGroupUIManager).GetComponent<UIUnitFighterSelection>().unitGroupList) {
      *      item.OnUnselected();
      * }*/
     foreach (UnitGroupFriendlyScript item in GameObject.Find(vars.UnitGroupUIManager).GetComponent <UIUnitFighterSelection>().unitGroupList)
     {
         item.OnUnselected();
     }
     if ((GameObject.Find(vars.base_name).GetComponent <UnitGroupCache>().unitGroupsSaved.Count + GameObject.Find(vars.UnitGroupUIManager).GetComponent <UIUnitFighterSelection>().unitGroupList.Count) < 18)
     {
         SavedUnitGroup svg = GameObject.Find(vars.base_name).GetComponent <UnitGroupCache>().createNewGroup();
         GameObject.Find(vars.ui_manager_name).GetComponent <ui_manager>().sug = svg;
         //GameObject.Find(vars.ui_manager_name).GetComponent<ui_manager>().connected_unit_to_ui = group_id;
         GameObject.Find(vars.ui_manager_name).GetComponent <ui_manager>().slot_0_set_unit();
         GameObject.Find(vars.ui_manager_name).GetComponent <ui_manager>().is_saved_group = true;
         Debug.Log("group added");
         GameObject.Find(vars.ui_manager_name).GetComponent <ui_manager>().show_upgrade_ui = false;
         GameObject.Find(vars.ui_manager_name).GetComponent <ui_manager>().manage_upgrade_ui();
         refresh_unit_group_selection_ui();
     }
 }
Пример #12
0
    public bool add_upgrade(ref upgrade_description upgrade, SavedUnitGroup group)
    {
        Debug.Log("unit upgrade add");
        if(upgrade != null && upgrade.upgrade_type == vars.upgrade_type.units){
            Debug.Log("upgrade check");
            base_manager thisBase = GameObject.FindGameObjectWithTag(vars.base_tag+""+vars.friendly_tag+""+vars.attackable_tag).GetComponent<base_manager>();
            if(thisBase.res_a_storage >= upgrade.costs_res_a && thisBase.res_b_storage >= upgrade.costs_res_b && thisBase.res_c_storage >= upgrade.costs_res_c){
                Debug.Log("costs check");
                // remove resources from base
                thisBase.res_a_storage -= upgrade.costs_res_a;
                thisBase.res_b_storage -= upgrade.costs_res_b;
                thisBase.res_c_storage -= upgrade.costs_res_c;

                if(group.upgrade_slot_0 == null || group.upgrade_slot_1 == null || group.upgrade_slot_2 == null){
                    switch (upgrade.upgrade_add_to_value) {
                    case vars.upgrade_values.ant_life:
                        group.health += upgrade.increase_value;
                        break;

                    case vars.upgrade_values.ant_damage:
                        group.damage += upgrade.increase_value;
                        break;

                    case vars.upgrade_values.ant_speed:
                        group.movementspeed += upgrade.increase_value;
                        break;
                    case vars.upgrade_values.ant_regeneration:
                        group.regeneration += upgrade.increase_value;
                        break;

                    default:
                        break;
                    }

                    if(group.upgrade_slot_0 == null){
                        group.upgrade_slot_0 = upgrade;
                        //Debug.Log("set upgrade to slot 0");
                        GameObject.Find(vars.ui_manager_name).GetComponent<ui_manager>().upgrade_unit_button_0.GetComponent<Image>().sprite = group.upgrade_slot_0.upgrade_icon;
                    }else 	if(group.upgrade_slot_1 == null){
                        group.upgrade_slot_1 = upgrade;
                        //Debug.Log("set upgrade to slot 1");
                        GameObject.Find(vars.ui_manager_name).GetComponent<ui_manager>().upgrade_unit_button_1.GetComponent<Image>().sprite = group.upgrade_slot_1.upgrade_icon;
                    }else 	if(group.upgrade_slot_2 == null){
                        group.upgrade_slot_2 = upgrade;
                        //Debug.Log("set upgrade to slot 2");
                        GameObject.Find(vars.ui_manager_name).GetComponent<ui_manager>().upgrade_unit_button_2.GetComponent<Image>().sprite = group.upgrade_slot_2.upgrade_icon;
                    }

                    return true;
                }
            }else{
                Debug.Log("err 2");
            }

        }else{
            Debug.Log("err 1");
        }
        return false;
    }
Пример #13
0
    // spawns a waiting unit group
    public void spawnUnitgroup(SavedUnitGroup group)
    {
        GameObject newgroup = Instantiate(unitGroupPrefab, group.position, Quaternion.identity) as GameObject;
        UnitGroupBase unitGroupBase = newgroup.GetComponent<UnitGroupBase>();
        unitGroupBase.setAttributes(group.unitGroupName, group.attackspeed, group.damage, group.health, group.movementspeed, group.attackrange, group.visionRange, group.regeneration);

        GameObject newunit;

        for(int i = 0; i < group.numUnits; i++) {
            newunit = Instantiate(unitPrefab, group.position, Quaternion.identity) as GameObject;
            UnitBase unitBase = newunit.GetComponent<UnitBase>();
            unitBase.setUnitGroup(unitGroupBase);
        }

        deleteUnitGroup(group);
    }
Пример #14
0
 // deletes a unit from a group
 public void deleteUnitFromGroup(SavedUnitGroup group)
 {
     if(group.numUnits > 0) {
         group.numUnits--;
     }
 }
Пример #15
0
    // creates new(empty) group
    public SavedUnitGroup createNewGroup()
    {
        SavedUnitGroup newUnitGroup = new SavedUnitGroup();
        newUnitGroup.initialize(standardAttackspeed, standardMovementspeed, standardDamage, standardHealth, standardAttackrange, standardVisionRange, standardRegeneration);
        newUnitGroup.unitGroupName = "Standard Ants " + unitGroupCounter.ToString();
        newUnitGroup.position = new Vector3(transform.position.x + 5, transform.position.y, transform.position.z);
        unitGroupCounter++;
        unitGroupsSaved.Add (newUnitGroup);

        return newUnitGroup;
    }
Пример #16
0
    // spawns a waiting unit group
    public void spawnUnitgroup(SavedUnitGroup group)
    {
        Vector3         position           = new Vector3(transform.position.x + 5.0f, transform.position.y, transform.position.z);
        GameObject      newgroup           = Instantiate(unitGroupPrefab, position, Quaternion.identity) as GameObject;
        UnitGroupScript newUnitGroupScript = newgroup.GetComponent <UnitGroupFriendlyScript>();

        GameObject        newUnit;
        List <UnitScript> listNewUnits = new List <UnitScript>();

        position = new Vector3(transform.position.x + 5.0f, transform.position.y, transform.position.z);
        for (int i = 0; i < group.numUnits; i++)
        {
            newUnit = Instantiate(unitPrefab, position, Quaternion.identity) as GameObject;
            newUnit.SetActive(false);
            UnitScript unitScript = newUnit.GetComponent <UnitScript>();
            unitScript.unitGroupScript = newUnitGroupScript;

            listNewUnits.Add(unitScript);
        }
        GameObject newUpgrade;
        Skill      newUpgradeSkill;

        if (group.normalUpgrades.Count > 0)
        {
            foreach (string upgrade in group.normalUpgrades)
            {
                newUpgrade      = Instantiate(upgradeManager.getUpgrade(upgrade), position, Quaternion.identity) as GameObject;
                newUpgradeSkill = newUpgrade.GetComponent <Skill>();
                if (newUpgradeSkill.skillType == 1)
                {
                    newUpgrade.SetActive(true);
                    newUpgradeSkill.unitGroupScript = newUnitGroupScript;
                    newUpgradeSkill.skillTarget     = newUnitGroupScript.gameObject;
                    newUpgrade.transform.parent     = newgroup.transform;
                }
                if (newUpgradeSkill.skillType == 0 && listNewUnits.Count > 0)
                {
                    newUpgradeSkill.unitScript  = listNewUnits[0];
                    newUpgrade.transform.parent = listNewUnits[0].transform;
                    newUpgrade.SetActive(true);
                    for (int i = 1; i < listNewUnits.Count; i++)
                    {
                        newUpgrade = Instantiate(upgradeManager.getUpgrade(upgrade), position, Quaternion.identity) as GameObject;
                        newUpgrade.SetActive(true);
                        newUpgradeSkill             = newUpgrade.GetComponent <Skill>();
                        newUpgradeSkill.unitScript  = listNewUnits[i];
                        newUpgradeSkill.skillTarget = listNewUnits[i].gameObject;
                        newUpgrade.transform.parent = listNewUnits[i].transform;
                    }
                }
            }
        }

        if (group.specialUpgrade != null)
        {
            newUpgrade      = Instantiate(upgradeManager.getUpgrade(group.specialUpgrade).gameObject, position, Quaternion.identity) as GameObject;
            newUpgradeSkill = newUpgrade.GetComponent <Skill>();
            if (newUpgradeSkill.skillType == 1)
            {
                newUpgrade.SetActive(true);
                newUpgradeSkill.unitGroupScript = newUnitGroupScript;
                newUpgradeSkill.skillTarget     = newUnitGroupScript.gameObject;
                newUpgrade.transform.parent     = newgroup.transform;
            }
            if (newUpgradeSkill.skillType == 0 && listNewUnits.Count > 0)
            {
                newUpgradeSkill.unitScript  = listNewUnits[0];
                newUpgrade.transform.parent = listNewUnits[0].transform;
                newUpgrade.SetActive(true);
                for (int i = 1; i < listNewUnits.Count; i++)
                {
                    newUpgrade = Instantiate(upgradeManager.getUpgrade(group.specialUpgrade), position, Quaternion.identity) as GameObject;
                    newUpgrade.SetActive(true);
                    newUpgradeSkill             = newUpgrade.GetComponent <Skill>();
                    newUpgradeSkill.unitScript  = listNewUnits[i];
                    newUpgradeSkill.skillTarget = listNewUnits[i].gameObject;
                    newUpgrade.transform.parent = listNewUnits[i].transform;
                }
            }
        }

        deleteUnitGroup(group);
        StartCoroutine(setListGroupUnitsActive(listNewUnits));
    }
Пример #17
0
    // spawns a waiting unit group
    public void spawnUnitgroup(SavedUnitGroup group)
    {
        Vector3 position = new Vector3(transform.position.x + 5.0f, transform.position.y, transform.position.z);
        GameObject newgroup = Instantiate(unitGroupPrefab, position, Quaternion.identity) as GameObject;
        UnitGroupScript newUnitGroupScript = newgroup.GetComponent<UnitGroupFriendlyScript>();

        GameObject newUnit;
        List <UnitScript> listNewUnits = new List<UnitScript>();
        position = new Vector3(transform.position.x + 5.0f, transform.position.y, transform.position.z);
        for(int i = 0; i < group.numUnits; i++) {
            newUnit = Instantiate(unitPrefab, position, Quaternion.identity) as GameObject;
            newUnit.SetActive(false);
            UnitScript unitScript = newUnit.GetComponent<UnitScript>();
            unitScript.unitGroupScript = newUnitGroupScript;

            listNewUnits.Add(unitScript);
        }
        GameObject newUpgrade;
        Skill newUpgradeSkill;

        if(group.normalUpgrades.Count > 0) {
            foreach(string upgrade in group.normalUpgrades) {
                newUpgrade = Instantiate(upgradeManager.getUpgrade(upgrade), position, Quaternion.identity) as GameObject;
                newUpgradeSkill = newUpgrade.GetComponent<Skill>();
                if(newUpgradeSkill.skillType == 1) {
                    newUpgrade.SetActive(true);
                    newUpgradeSkill.unitGroupScript = newUnitGroupScript;
                    newUpgradeSkill.skillTarget = newUnitGroupScript.gameObject;
                    newUpgrade.transform.parent = newgroup.transform;
                }
                if(newUpgradeSkill.skillType == 0 && listNewUnits.Count > 0) {
                    newUpgradeSkill.unitScript = listNewUnits[0];
                    newUpgrade.transform.parent = listNewUnits[0].transform;
                    newUpgrade.SetActive(true);
                    for(int i = 1; i < listNewUnits.Count; i++) {
                        newUpgrade = Instantiate(upgradeManager.getUpgrade(upgrade), position, Quaternion.identity) as GameObject;
                        newUpgrade.SetActive(true);
                        newUpgradeSkill = newUpgrade.GetComponent<Skill>();
                        newUpgradeSkill.unitScript = listNewUnits[i];
                        newUpgradeSkill.skillTarget = listNewUnits[i].gameObject;
                        newUpgrade.transform.parent = listNewUnits[i].transform;
                    }
                }
            }
        }

        if(group.specialUpgrade != null) {
            newUpgrade = Instantiate(upgradeManager.getUpgrade(group.specialUpgrade).gameObject, position, Quaternion.identity) as GameObject;
            newUpgradeSkill = newUpgrade.GetComponent<Skill>();
            if(newUpgradeSkill.skillType == 1) {
                newUpgrade.SetActive(true);
                newUpgradeSkill.unitGroupScript = newUnitGroupScript;
                newUpgradeSkill.skillTarget = newUnitGroupScript.gameObject;
                newUpgrade.transform.parent = newgroup.transform;
            }
            if(newUpgradeSkill.skillType == 0 && listNewUnits.Count > 0) {
                newUpgradeSkill.unitScript = listNewUnits[0];
                newUpgrade.transform.parent = listNewUnits[0].transform;
                newUpgrade.SetActive(true);
                for(int i = 1; i < listNewUnits.Count; i++) {
                    newUpgrade = Instantiate(upgradeManager.getUpgrade(group.specialUpgrade), position, Quaternion.identity) as GameObject;
                    newUpgrade.SetActive(true);
                    newUpgradeSkill = newUpgrade.GetComponent<Skill>();
                    newUpgradeSkill.unitScript = listNewUnits[i];
                    newUpgradeSkill.skillTarget = listNewUnits[i].gameObject;
                    newUpgrade.transform.parent = listNewUnits[i].transform;
                }
            }
        }

        deleteUnitGroup(group);
        StartCoroutine(setListGroupUnitsActive(listNewUnits));
    }