예제 #1
0
    public void Awake()
    {
        instance = this;
        //thisObj=gameObject;
        //rectT=thisObj.GetComponent<RectTransform>();


        AbilityManagerUnit abManagerUnit = (AbilityManagerUnit)FindObjectOfType(typeof(AbilityManagerUnit));

        if (abManagerUnit != null)
        {
            abManagerUnit.Init();
        }

        InitiateElement();

        abilityTooltipObj.SetActive(false);
    }
예제 #2
0
    void Awake()
    {
        instance = this;

        PerkManager perkManager = (PerkManager)FindObjectOfType(typeof(PerkManager));

        if (perkManager != null)
        {
            perkManager.Init();
        }

        AbilityManagerUnit abManagerUnit = (AbilityManagerUnit)FindObjectOfType(typeof(AbilityManagerUnit));

        if (abManagerUnit != null)
        {
            abManagerUnit.Init();
        }


        availableUnitList = new List <Unit>(UnitDB.Load());             //load the unit from DB, you manually assign this if you want

        //since we are loading from DB, we dont want the AI unit, which started from 6 (so we remove them)
        while (availableUnitList.Count > 9)
        {
            availableUnitList.RemoveAt(availableUnitList.Count - 1);
        }

        //if this there isn't any save
        if (!PlayerPrefs.HasKey("TBTK_Demo"))
        {
            //for demo purpose, we are using perk currency as the universal currency
            //so we set the perk currency to our starting value and let PerkManager keep track of it
            PerkManager.SetPerkCurrency(startingCurrency);

            PlayerPrefs.SetInt("TBTK_Demo", 1);
        }
        else
        {
            //check with data to see if the scene is loaded from a battle
            if (TBData.BattleEndDataExist())
            {
                List <TBDataUnit> dataList = TBData.GetEndData(0);              //get the data, the ID is zero, since we start the battle with 0
                //note that the faction in the battle scene is configured to load data from 0 too

                if (dataList != null)                   //add the unit based on the dataList
                {
                    for (int i = 0; i < dataList.Count; i++)
                    {
                        selectedUnitList.Add(dataList[i].unit);
                    }
                }

                for (int i = 0; i < selectedUnitList.Count; i++)                        //fill up the availableUnitMapList (for saving)
                {
                    bool match = false;
                    for (int n = 0; n < availableUnitList.Count; n++)                           //find the corresponding unit in availableList and add the index to selectedUnitMapList
                    {
                        if (selectedUnitList[i] == availableUnitList[n])
                        {
                            selectedUnitMapList.Add(n);
                            match = true;
                            break;
                        }
                    }
                    //if there's no match in availableUnitList, unit no longer available in game, remove it from selected list
                    if (!match)
                    {
                        selectedUnitList.RemoveAt(i);
                        i -= 1;
                    }
                }

                _SaveLoadOut();
            }
            else                //if we are not loading the scene from a battle, load the selectedUnitList from previous save in stead of getting it from data
            {
                _LoadLoadOut();
            }
        }
    }