示例#1
0
    public static void Reset()
    {
        List <Champion> t_OwnedChampions = new List <Champion>(Champion.Filter(Champion.FilterType.Owned, Champion.GetSortedBy(Champion.SortValue.Name)));

        foreach (EditChampionDropdown t_Element in m_UIElements)
        {
            if (t_Element.Value != null)
            {
                t_OwnedChampions.Remove(t_Element.Value);
            }
        }

        foreach (EditChampionDropdown t_Element in m_UIElements)
        {
            t_Element.SetChampionList(t_OwnedChampions);
        }
    }
    void Update()
    {
        if (SpawnImages)
        {
            SpawnImages = false;
            foreach (ChampionListElement t_Element in GetComponentsInChildren <ChampionListElement>())
            {
                Champion t_Champion = Champion.Get(t_Element.name);
                if (t_Champion.Image != null)
                {
                    Transform t_ImageObject = t_Element.transform.Find("Image");
                    if (t_ImageObject != null)
                    {
                        t_ImageObject.GetComponent <Image>().sprite = t_Champion.Image;
                    }
                }
                else
                {
                    // Spawn them later
                    SpawnImages = true;
                }
            }
        }

        if (m_Setup == false && Champion.All.Length != 0)
        {
            GameObject    t_Prefab          = Resources.Load("Prefabs/ChampionListObject") as GameObject;
            RectTransform t_PrefabTransform = t_Prefab.GetComponent <RectTransform>();

            int y = 0;
            foreach (Champion t_Champion in Champion.Filter(Champion.FilterType.Owned, Champion.GetSortedBy(Champion.SortValue.Name, Champion.SortType.ASC)))
            {
                GameObject t_Instance = Instantiate(t_Prefab);
                t_Instance.name = t_Champion.Name;
                t_Instance.GetComponent <ChampionListElement>().FillInfo(t_Champion);
                t_Instance.transform.SetParent(transform);

                t_Instance.transform.localPosition = new Vector3(0, (-y * t_PrefabTransform.sizeDelta.y));
                t_Instance.transform.localScale    = Vector3.one;
                y++;

                Transform t_Masteryimage = t_Instance.transform.Find("Mastery");

                if (t_Champion.Mastery.Level != 0)
                {
                    t_Masteryimage.GetComponent <Image>().sprite = MasteryIcons[t_Champion.Mastery.Level - 1];
                }

                else if (t_Champion.Mastery.Level == 0)
                {
                    t_Masteryimage.GetComponent <Image>().color = Color.clear;
                }

                if (t_Champion.Price > Info.Player.Cash)
                {
                    t_Instance.transform.Find("Price").GetComponent <Text>().color = Color.red;
                }

                if (t_Champion.Image != null)
                {
                    Transform t_ImageObject = t_Instance.transform.Find("Image");
                    if (t_ImageObject != null)
                    {
                        t_ImageObject.GetComponent <Image>().sprite = t_Champion.Image;
                    }
                }
                else
                {
                    // Spawn them later
                    SpawnImages = true;
                }
            }

            GetComponent <RectTransform>().sizeDelta = new Vector2(0, 40 + (y * t_PrefabTransform.sizeDelta.y));
            m_Setup = true;
        }
    }
示例#3
0
    public void OnFilterClicked()
    {
        FilteredArray = Champion.All;

        Toggle togglebuyable = transform.Find("Buyable").GetComponent <Toggle>();

        if (togglebuyable.isOn == true)
        {
            FilteredArray = Champion.Filter(Champion.FilterType.Buyable, FilteredArray);
        }

        Toggle toggleunbuyable = transform.Find("Unbuyable").GetComponent <Toggle>();

        if (toggleunbuyable.isOn == true)
        {
            FilteredArray = Champion.Filter(Champion.FilterType.Unbuyable, FilteredArray);
        }

        Toggle toggletop = transform.Find("Top").GetComponent <Toggle>();

        if (toggletop.isOn == true)
        {
            FilteredArray = Champion.Filter(Champion.FilterType.Top, FilteredArray);
        }

        Toggle togglemid = transform.Find("Mid").GetComponent <Toggle>();

        if (togglemid.isOn == true)
        {
            FilteredArray = Champion.Filter(Champion.FilterType.Mid, FilteredArray);
        }

        Toggle togglesupport = transform.Find("Support").GetComponent <Toggle>();

        if (togglesupport.isOn == true)
        {
            FilteredArray = Champion.Filter(Champion.FilterType.Support, FilteredArray);
        }

        Toggle togglemarksman = transform.Find("Marksman").GetComponent <Toggle>();

        if (togglemarksman.isOn == true)
        {
            FilteredArray = Champion.Filter(Champion.FilterType.Marksman, FilteredArray);
        }

        Toggle togglejungle = transform.Find("Jungle").GetComponent <Toggle>();

        if (togglejungle.isOn == true)
        {
            FilteredArray = Champion.Filter(Champion.FilterType.Jungle, FilteredArray);
        }

        if (CurrentState == State.AZ)
        {
            FilteredArray = Champion.GetSortedBy(Champion.SortValue.Name, Champion.SortType.ASC, FilteredArray);
        }

        else if (CurrentState == State.ZA)
        {
            FilteredArray = Champion.GetSortedBy(Champion.SortValue.Name, Champion.SortType.DESC, FilteredArray);
        }

        else if (CurrentState == State.priceascending)
        {
            FilteredArray = Champion.GetSortedBy(Champion.SortValue.Price, Champion.SortType.ASC, FilteredArray);
        }

        else if (CurrentState == State.pricedescending)
        {
            FilteredArray = Champion.GetSortedBy(Champion.SortValue.Price, Champion.SortType.DESC, FilteredArray);
        }

        else if (CurrentState == State.masteryascending)
        {
            FilteredArray = Champion.GetSortedBy(Champion.SortValue.UserMastery, Champion.SortType.ASC, FilteredArray);
        }

        else if (CurrentState == State.masterydescending)
        {
            FilteredArray = Champion.GetSortedBy(Champion.SortValue.UserMastery, Champion.SortType.DESC, FilteredArray);
        }

        SetupShop();
    }
示例#4
0
    public void SetupShop()
    {
        Champion[] ChampionArray = Champion.Filter(Champion.FilterType.NotOwned, FilteredArray);
        // ChampionArray = Champion.Filter(Champion.FilterType.Buyable, ChampionArray); // Too confusing?

        GameObject Prefab      = Resources.Load("Prefabs/ShopListObject") as GameObject;
        GameObject ShopContent = GameObject.FindGameObjectWithTag("ShopContent");

        int I = 0;
        int J = 0;

        foreach (Transform Child in ShopContent.transform)
        {
            Destroy(Child.gameObject);
        }

        foreach (Champion CurrentChampion in ChampionArray)
        {
            GameObject Instance = Instantiate(Prefab) as GameObject;
            Instance.transform.SetParent(ShopContent.transform);
            Instance.transform.localPosition = new Vector3((I * 250) + 40, (J * 300), 0);

            Instance.name = CurrentChampion.Name;
            Instance.transform.Find("Name").GetComponent <Text>().text  = CurrentChampion.Name;
            Instance.transform.Find("Price").GetComponent <Text>().text = Cash.Format(CurrentChampion.Price);

            I += 1;
            if (I > 4)
            {
                J = J - 1;
                I = 0;
            }

            Transform t_Masteryimage = Instance.transform.Find("Mastery");

            if (CurrentChampion.Mastery.Level != 0)
            {
                t_Masteryimage.GetComponent <Image>().sprite = MasteryIcons[CurrentChampion.Mastery.Level - 1];
            }

            else if (CurrentChampion.Mastery.Level == 0)
            {
                t_Masteryimage.GetComponent <Image>().color = Color.clear;
            }

            if (CurrentChampion.Price > Info.Player.Cash)
            {
                Instance.transform.Find("Price").GetComponent <Text>().color = Color.red;
            }

            if (CurrentChampion.Image != null)
            {
                Transform t_ImageObject = Instance.transform.Find("Image");
                if (t_ImageObject != null)
                {
                    t_ImageObject.GetComponent <Image>().sprite = CurrentChampion.Image;
                }
            }
            else
            {
                // Spawn them later
                SpawnImages = true;
            }
            Instance.transform.localScale = Vector3.one;
        }

        ShopContent.GetComponent <RectTransform>().sizeDelta = new Vector2(ShopContent.GetComponent <RectTransform>().sizeDelta.x, (Mathf.Abs(J) + 1) * 300);
    }