Esempio n. 1
0
 //this will save the current build
 //only can be called if full modules and type selected
 public void continueOn()
 {
     DropDownUpdate();
     if (type == UnitType.fighter)
     {
         string name = "Unit" + dropDownValue;
         unitData = new UnitData(name, UnitType.fighter, modules[0], modules[1]);
         unitSave.save(unitData);
         Debug.Log(unitSave.load(dropDownValue - 1).unitName + " " + unitSave.load(dropDownValue - 1).type);
     }
     else if (type == UnitType.frigate)
     {
         string name = "Unit" + dropDownValue;
         unitData = new UnitData(name, UnitType.frigate, modules[0], modules[1], modules[2]);
         unitSave.save(unitData);
         Debug.Log(unitSave.load(dropDownValue - 1).unitName + " " + unitSave.load(dropDownValue - 1).type);
     }
 }
    // Use this for initialization
    void Start()
    {
        BM.gameObject.SetActive(true);

        var tiles = FindObjectsOfType <Tile>();

        mapTiles = new List <Tile>(tiles);

        var Units = FindObjectsOfType <Unit>();

        unitPlayer = new List <Unit>(Units);

        //remove non-player units from list
        foreach (Unit t in Units)
        {
            if (t.PlayerNumber == 1)
            {
                unitPlayer.Remove(t);
            }
        }

        //3 default loads just in case player wants more options
        unitDatas.Add(new UnitData("Default 1", UnitType.fighter, ModuleType.shortRange, ModuleType.shortRange));
        unitDatas.Add(new UnitData("Default 2", UnitType.fighter, ModuleType.longRange, ModuleType.longRange));
        unitDatas.Add(new UnitData("Default 3", UnitType.frigate, ModuleType.heal, ModuleType.heal, ModuleType.heal));

        //load the 9 available saves
        for (int i = 0; i < 9; i++)
        {
            unitDatas.Add(saves.load(i));
        }

        //add saves to menu
        for (int i = 0; i < 12; i++)
        {
            if (unitDatas[i].type == UnitType.fighter)
            {
                loadbuttons[i].GetComponentInChildren <Text>().text = unitDatas[i].unitName + ": " + unitDatas[i].type + "\n" + "Module 1: " + unitDatas[i].module1 + "   Module 2: " + unitDatas[i].module2;
            }
            else
            {
                loadbuttons[i].GetComponentInChildren <Text>().text = unitDatas[i].unitName + ": " + unitDatas[i].type + "\n" + "Module 1: " + unitDatas[i].module1 + "   Module 2: " + unitDatas[i].module2 + "   Module 3: " + unitDatas[i].module3;
            }
        }

        count = unitPlayer.Count;
        updateCount();
        BM.gameObject.SetActive(false);
        map.gameObject.SetActive(true);
    }