コード例 #1
0
    IEnumerator Start()
    {
        List <Unit> availableUnitList = DemoCampaign.GetAvailableUnitList();

        for (int i = 0; i < availableUnitList.Count; i++)
        {
            if (i == 0)
            {
                avaiItemList[0].Init();
            }
            else if (i > 0)
            {
                avaiItemList.Add(UIButton.Clone(avaiItemList[0].rootObj, "AvaiItem" + (i + 1)));
            }

            avaiItemList[i].imgIcon.sprite = availableUnitList[i].iconSprite;
            avaiItemList[i].label.text     = "$" + availableUnitList[i].value.ToString();
            avaiItemList[i].SetCallback(null, null, this.OnAvailableItem, null);
        }


        List <Unit> selectedUnitList = DemoCampaign.GetSelectedUnitList();

        for (int i = 0; i < DemoCampaign.GetLoadOutUnitLimit(); i++)
        {
            if (i == 0)
            {
                selectedItemList[0].Init();
            }
            else if (i > 0)
            {
                selectedItemList.Add(UIButton.Clone(selectedItemList[0].rootObj, "SelectedItem" + (i + 1)));
            }

            if (i >= selectedUnitList.Count)
            {
                selectedItemList[i].SetActive(false);
            }
            else
            {
                selectedItemList[i].imgIcon.sprite = selectedUnitList[i].iconSprite;
                selectedItemList[i].label.text     = "$" + selectedUnitList[i].value.ToString();
                selectedItemList[i].SetActive(true);
            }

            selectedItemList[i].SetCallback(null, null, this.OnSelectedItem, null);
        }

        //UpdateAvailableContentRectSize();
        //UpdateSelectedContentRectSize();

        buttonAdd.Init();
        buttonRemove.Init();

        buttonAdd.button.interactable    = true;
        buttonRemove.button.interactable = false;

        yield return(null);
    }
コード例 #2
0
 public void OnStartButton()
 {
     if (DemoCampaign.GetSelectedUnitCount() <= 0)
     {
         Debug.Log("No unit has been selected!");
         return;
     }
     DemoCampaign.StartBattle();
 }
コード例 #3
0
    private void UpdateSelectedContentRectSize()
    {
        int   selectedCount = DemoCampaign.GetSelectedUnitCount();
        int   rowCount      = (int)Mathf.Ceil(selectedCount / (float)layoutSelected.constraintCount);
        float size          = rowCount * layoutSelected.cellSize.y + rowCount * layoutSelected.spacing.y + layoutSelected.padding.top;

        RectTransform contentRect = layoutSelected.gameObject.GetComponent <RectTransform>();

        contentRect.sizeDelta = new Vector2(contentRect.sizeDelta.x, size);
    }
コード例 #4
0
    public void OnAvailableItem(GameObject butObj, int pointerID = -1)
    {
        int newID = GetAvailableItemID(butObj);

        if (selectedTab == _SelectedTab.Available && selectedID == newID)
        {
            return;
        }

        ClearSelected();

        selectedTab = _SelectedTab.Available;
        selectedID  = newID;
        avaiItemList[selectedID].imgHighlight.gameObject.SetActive(true);

        buttonAdd.button.interactable    = true;
        buttonRemove.button.interactable = false;

        DemoUIUnitInfo.UpdateDisplay(DemoCampaign.GetAvailableUnit(selectedID));
    }
コード例 #5
0
    void UpdateSelectedDisplay()
    {
        List <Unit> selectedUnitList = DemoCampaign.GetSelectedUnitList();

        for (int i = 0; i < selectedItemList.Count; i++)
        {
            if (i >= selectedUnitList.Count)
            {
                selectedItemList[i].SetActive(false);
            }
            else
            {
                selectedItemList[i].imgIcon.sprite = selectedUnitList[i].iconSprite;
                selectedItemList[i].label.text     = "$" + selectedUnitList[i].value.ToString();
                selectedItemList[i].SetActive(true);
            }
        }

        //UpdateSelectedContentRectSize();
    }
コード例 #6
0
    public void OnRemoveButton()
    {
        DemoCampaign.RemoveUnit(selectedID);

        UpdateSelectedDisplay();

        if (DemoCampaign.GetSelectedUnitCount() == 0)
        {
            buttonRemove.button.interactable = false;
            OnAvailableItem(avaiItemList[0].rootObj);
            return;
        }

        if (DemoCampaign.GetSelectedUnitCount() <= selectedID)
        {
            OnSelectedItem(selectedItemList[DemoCampaign.GetSelectedUnitCount() - 1].rootObj);
        }
        else
        {
            selectedTab = _SelectedTab.Available;
            OnSelectedItem(selectedItemList[selectedID].rootObj);
        }
    }
コード例 #7
0
 public void OnResetProgressButton()
 {
     DemoCampaign.ResetDemo();
     OnMainMenuButton();
 }
コード例 #8
0
 public void OnMainMenuButton()
 {
     DemoCampaign.MainMenu();
 }
コード例 #9
0
    public void OnAddButton()
    {
        DemoCampaign.AddUnit(selectedID);

        UpdateSelectedDisplay();
    }
コード例 #10
0
 public void OnFullFeatureButton(GameObject butObj, int pointerID = -1)
 {
     DemoCampaign.LoadLevel("DemoFullFeature");
 }
コード例 #11
0
 public void OnJRPGButton(GameObject butObj, int pointerID = -1)
 {
     DemoCampaign.LoadLevel("DemoJRPG");
 }
コード例 #12
0
 public void OnSimpleButton(GameObject butObj, int pointerID = -1)
 {
     DemoCampaign.LoadLevel("DemoSimple");
 }
コード例 #13
0
 public void OnCampaignButton(GameObject butObj, int pointerID = -1)
 {
     DemoCampaign.LoadLevel("DemoCampaignMenu");
 }
コード例 #14
0
ファイル: DemoCampaign.cs プロジェクト: Hengle/TBTKPrototype
    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();
            }
        }
    }