Beispiel #1
0
    public void OnClick()
    {
        BuyWindow.Instance.SetActive(true);

        Champion ClickedChampion = Champion.Get(gameObject.transform.parent.name);

        BuyWindow.Instance.transform.Find("Content/ChampionName").GetComponent <Text>().text = ClickedChampion.Name;
        BuyWindow.Instance.transform.Find("Content/Role").GetComponent <Text>().text         = ClickedChampion.GetBestLanes();

        BuyWindow.Instance.transform.Find("Content/Price").GetComponent <Text>().text = Cash.Format(ClickedChampion.Price);

        foreach (Role t_Lane in Enum.GetValues(typeof(Role)))
        {
            Transform t_ProgressBar = BuyWindow.Instance.transform.Find("Content/" + t_Lane.ToString());

            t_ProgressBar.Find("Role").GetComponent <Text>().text = t_Lane.ToString();

            float t_Efficiency = (float)ClickedChampion.GetLaneEfficiency(t_Lane);
            // Debug.Log(t_Efficiency);

            t_ProgressBar.Find("Fill").GetComponent <RectTransform>().sizeDelta = new Vector2(t_Efficiency * 595, t_ProgressBar.Find("Fill").GetComponent <RectTransform>().sizeDelta.y);
            t_ProgressBar.Find("Percentage").GetComponent <Text>().text         = (t_Efficiency * 100.0).ToString("F2") + "%";

            string InWords = "Not Recommended";
            if (t_Efficiency > 0.33 && t_Efficiency < 0.5)
            {
                InWords = "Mediocre";
            }
            else if (t_Efficiency >= 0.5 && t_Efficiency < 0.7)
            {
                InWords = "Above average";
            }
            else if (t_Efficiency >= 0.7 && t_Efficiency < 0.95)
            {
                InWords = "Recommended";
            }
            else if (t_Efficiency >= 0.95)
            {
                InWords = "Perfect";
            }


            t_ProgressBar.Find("InWords").GetComponent <Text>().text = InWords;
        }

        string SplashArt = "http://ddragon.leagueoflegends.com/cdn/img/champion/loading/" + ClickedChampion.Key + "_0.jpg";

        HTTP.Request(SplashArt, delegate(WWW a_Request)
        {
            Rect Rectangle   = new Rect();
            Rectangle.x      = Rectangle.y = 0;
            Rectangle.width  = a_Request.texture.width;
            Rectangle.height = a_Request.texture.height;

            BuyWindow.Instance.transform.Find("Content/SplashArt").GetComponent <Image>().sprite = Sprite.Create(a_Request.texture, Rectangle, Vector2.zero);
            BuyWindow.Instance.transform.Find("Content/SplashArt").GetComponent <Image>().color  = Color.white;
        }, false);
    }
Beispiel #2
0
    void Update()
    {
        if (m_Champion == -1)
        {
            return;
        }

        if (m_ReloadImage == true && Champion.Get(m_Champion).Image != null)
        {
            FillInfo(Champion.Get(m_Champion));
        }
    }
Beispiel #3
0
    public void OnBuy()
    {
        if (BuySound != null)
        {
            Sound.Play(BuySound);
        }

        GameObject BuyWindow = GameObject.FindGameObjectWithTag("BuyWindow");

        string   ChampionName   = BuyWindow.transform.Find("Content/ChampionName").GetComponent <Text>().text;
        Champion BoughtChampion = Champion.Get(ChampionName);

        Info.Player.Buy(BoughtChampion);

        // Close window
        BuyWindow.transform.Find("Content/Cancel").GetComponent <CloseBuyWindow>().OnClick();
        Message.Create("You've bought a champion!", "Congratulations, " + Info.Player.Name + "! You've just strengthened your forces by buying " + BoughtChampion.Name + ". Have fun playing!", false);
    }
Beispiel #4
0
    void Update()
    {
        if (Champion.All.Length != 0 && Done == false)
        {
            FilteredArray = Champion.All;
            OnFilterClicked();
            Done = true;
        }

        // If we are supposed to spawn images and Annie's image is available (indicator that possibly all are)
        if (SpawnImages && Champion.Get(1).Image != null)
        {
            // Don't keep doing this if unnecessary
            SpawnImages = false;

            // For each shop item
            foreach (Transform t_ChampionTransform in GameObject.FindGameObjectWithTag("ShopContent").transform)
            {
                Transform t_ImageObject = t_ChampionTransform.Find("Image");
                Sprite    t_Sprite      = Champion.Get(t_ChampionTransform.name).Image;

                // If this champion doesn't have an image yet, try again later
                if (t_Sprite == null)
                {
                    SpawnImages = true;
                    continue;
                }

                // Set image
                if (t_ImageObject != null)
                {
                    t_ImageObject.GetComponent <Image>().sprite = t_Sprite;
                }
            }
        }
    }
    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;
        }
    }
Beispiel #6
0
    void CheckSetup()
    {
        if (m_Setup == false && Info != null)
        {
            Debug.Log(Info.Request.text);

            JSONNode t_GameInfo = JSON.Parse(Info.Request.text);
            foreach (JSONNode t_Team in t_GameInfo["teams"].AsArray)
            {
                //if(t_Team["is_player"].AsInt == 1)
                //{
                //    GameObject.FindGameObjectWithTag("GameTeamPlayer").transform.Find("Name").GetComponent<Text>().text = ;
                //}

                string[] t_Roles = { "support", "marksman", "mid", "top", "jungle" };

                // Setup games below
                int i = 0;
                if (GameObject.FindGameObjectWithTag("GameLoadingScreen") != null)
                {
                    GameObject t_LoadingScreen = GameObject.FindGameObjectWithTag("GameLoadingScreen").transform.Find((t_Team["is_player"].AsBool ? "Top" : "Bottom")).Find("Champs").gameObject;
                    Text       t_Name          = t_LoadingScreen.transform.parent.Find("Name").GetComponent <Text>();
                    t_Name.text = t_Team["player"]["name"] + "'s " + t_Team["team"]["Name"].Value;

                    foreach (string t_RoleString in t_Roles)
                    {
                        JSONNode t_Role = t_Team["champions"][t_RoleString];

                        GameObject t_Prefab   = Resources.Load("Prefabs/GameLoadingScreenChampion") as GameObject;
                        GameObject t_Instance = Instantiate(t_Prefab) as GameObject;

                        t_Instance.transform.SetParent(t_LoadingScreen.transform);
                        t_Instance.transform.localScale    = Vector3.one * 0.8f;
                        t_Instance.transform.localPosition = new Vector3(((float)i - 2) * t_Instance.GetComponent <RectTransform>().rect.width, 0);
                        i++;

                        t_Instance.name = t_Role["name"].Value;
                        t_Instance.transform.Find("Name").GetComponent <Text>().text = t_Role["name"].Value;

                        int t_MasteryLevel = t_Role["mastery"]["level"].AsInt - 1;
                        if (t_MasteryLevel >= 0 && t_MasteryLevel < m_MasteryLevels.Length)
                        {
                            Image t_Image = t_Instance.transform.Find("Mastery").GetComponent <Image>();
                            t_Image.sprite = m_MasteryLevels[t_MasteryLevel];
                            t_Image.color  = Color.white;
                        }

                        string t_URL = Settings.ChampionLoadingImageDirectory + t_Role["key"].Value + "_" + t_Role["skin"].AsInt.ToString() + ".jpg";
                        HTTP.Request(t_URL, delegate(WWW a_Request)
                        {
                            t_Instance.transform.Find("Loading").GetComponent <Image>().sprite = Sprite.Create(a_Request.texture, new Rect(0.0f, 0.0f, a_Request.texture.width, a_Request.texture.height), Vector2.zero);
                            t_Instance.transform.Find("Loading").GetComponent <Image>().color  = Color.white;
                        }, false);
                    }
                }
                else
                {
                    m_WaitAtLoading = 3.0f;
                }

                i = 0;
                GameObject[] t_TeamObjects    = GameObject.FindGameObjectsWithTag("GameTeamUI");
                GameTeamUI   t_TeamUI         = Array.Find(t_TeamObjects, g => g.GetComponent <GameTeamUI>().Team == (t_Team["is_player"].AsBool ? 0 : 1)).GetComponent <GameTeamUI>();
                Transform    t_ChampContainer = t_TeamUI.transform.Find("Champs");
                t_TeamUI.transform.Find("Name").GetComponent <Text>().text = t_Team["team"]["Name"].Value;

                // Debug.Log("Teamname: "+t_Team["team"]["Name"].Value);
                foreach (string t_RoleString in t_Roles)
                {
                    GameObject t_Prefab   = Resources.Load("Prefabs/GameTeamUIChampion") as GameObject;
                    GameObject t_Instance = Instantiate(t_Prefab) as GameObject;

                    t_Instance.transform.SetParent(t_ChampContainer.transform);
                    t_Instance.transform.localScale = Vector3.one;
                    Vector3 t_BasePosition = new Vector3(-450, 350);
                    t_Instance.transform.localPosition = t_BasePosition + new Vector3(((float)i) * t_Instance.GetComponent <RectTransform>().rect.width, ((float)-i) * t_Instance.GetComponent <RectTransform>().rect.height * 1.1f);
                    if (t_Team["is_player"].AsBool == false)
                    {
                        foreach (Text t_Text in t_Instance.GetComponentsInChildren <Text>())
                        {
                            t_Text.transform.localScale     = new Vector3(-1, 1);
                            t_Text.transform.localPosition -= new Vector3(t_Text.GetComponent <RectTransform>().rect.width *0.5f, 0);
                        }
                    }
                    i++;

                    Teams[(t_Team["is_player"].AsBool) ? 0 : 1].Name = t_Team["team"]["Name"].Value;
                    switch (t_RoleString)
                    {
                    case "support":
                        Teams[(t_Team["is_player"].AsBool) ? 0 : 1].Support = t_Instance.GetComponent <GameChampion>();
                        break;

                    case "marksman":
                        Teams[(t_Team["is_player"].AsBool) ? 0 : 1].Marksman = t_Instance.GetComponent <GameChampion>();
                        break;

                    case "mid":
                        Teams[(t_Team["is_player"].AsBool) ? 0 : 1].Mid = t_Instance.GetComponent <GameChampion>();
                        break;

                    case "top":
                        Teams[(t_Team["is_player"].AsBool) ? 0 : 1].Top = t_Instance.GetComponent <GameChampion>();
                        break;

                    case "jungle":
                        Teams[(t_Team["is_player"].AsBool) ? 0 : 1].Jungle = t_Instance.GetComponent <GameChampion>();
                        break;
                    }


                    JSONNode t_Role = t_Team["champions"][t_RoleString];
                    t_Instance.name = t_Role["name"].Value;

                    var t_GameChamp = t_Instance.GetComponent <GameChampion>();
                    t_GameChamp.Champion = Champion.Get(t_Role["id"].AsInt);
                    t_Instance.GetComponent <Image>().sprite = GetFlipped(t_GameChamp.Champion.Image);
                }
            }

            Timeline.Fetch();

            if (Matchmaking.IsTesting() == false)
            {
                SceneManager.UnloadScene("Combined");
            }
            else
            {
                Matchmaking.UnsetTestEnvironment();
            }
            m_Setup = true;
        }

        if (m_Setup == true && m_ReadyToPlay == false)
        {
            m_WaitAtLoading -= Time.deltaTime;
            if (GameObject.FindGameObjectWithTag("GameLoadingScreen") == null)
            {
                m_ReadyToPlay = Timeline.Ready;
            }

            else if (m_WaitAtLoading <= 0.0f)
            {
                if (m_WaitAtLoading < -1.0f)
                {
                    m_ReadyToPlay = Timeline.Ready;
                    GameObject.FindGameObjectWithTag("GameLoadingScreen").SetActive(false);
                }
                else
                {
                    Image t_Background = GameObject.FindGameObjectWithTag("GameLoadingScreen").GetComponent <Image>();

                    foreach (Image t_Image in t_Background.GetComponentsInChildren <Image>())
                    {
                        Fade(t_Image);
                    }

                    foreach (Text t_Text in t_Background.GetComponentsInChildren <Text>())
                    {
                        Fade(t_Text);
                    }
                }
            }
        }
    }
Beispiel #7
0
    void Update()
    {
        if (m_Setup == false && m_InProgress == false && Champion.Get(1) != null && Champion.Get(1).Image != null)
        {
            HTTP.Request(Settings.FormAjaxURL("teams.php"), delegate(WWW a_Request)
            {
                var t_JSON = JSON.Parse(a_Request.text);

                m_Array = t_JSON.AsArray;

                Team.Setup(m_Array);

                // Debug.Log("Teams loaded.");
                m_Setup = true;
            }, true);
            m_InProgress = true;
        }

        if (m_Array != null && GameObject.FindGameObjectWithTag("TeamsContent") != null)
        {
            GameObject t_Content = GameObject.FindGameObjectWithTag("TeamsContent");

            foreach (Transform t_Child in t_Content.transform)
            {
                Destroy(t_Child.gameObject);
            }

            GameObject    t_Prefab          = Resources.Load("Prefabs/TeamListObject") as GameObject;
            RectTransform t_PrefabTransform = t_Prefab.GetComponent <RectTransform>();

            int y = 0;
            foreach (JSONNode t_Team in m_Array)
            {
                GameObject t_Instance = Instantiate(t_Prefab);
                t_Instance.transform.SetParent(t_Content.transform);

                t_Instance.name = t_Team["name"];
                t_Instance.transform.Find("Name").GetComponent <Text>().text = t_Team["name"].Value;
                t_Instance.transform.Find("ID").GetComponent <Text>().text   = t_Team["id"].Value;



                // t_Team.Wins = t_Node["wins"].AsInt;
                //t_Team.Losses = t_Node["losses"].AsInt;
                //t_Team.Kills = t_Node["kills"].AsInt;
                //t_Team.Deaths = t_Node["deaths"].AsInt;
                //t_Team.CreepScore = t_Node["creep_score"].AsInt;

                Team EditTeam = Team.Get(t_Team["id"].AsInt);
                t_Instance.transform.Find("Stats/Winrate").GetComponent <Text>().text = (EditTeam.WinRate * 100).ToString() + "% Winrate";

                t_Instance.transform.Find("Stats/KillDeath").GetComponent <Text>().text = (EditTeam.KillDeathRate).ToString("F2") + " KD";

                t_Instance.transform.Find("Stats/CS").GetComponent <Text>().text = (EditTeam.CreepScore / EditTeam.Games).ToString("F0") + " CS Average";


                t_Instance.transform.Find("Champions/Top").GetComponentInChildren <Image>().sprite      = Champion.Get(t_Team["top"].AsInt).Image;
                t_Instance.transform.Find("Champions/Mid").GetComponentInChildren <Image>().sprite      = Champion.Get(t_Team["mid"].AsInt).Image;
                t_Instance.transform.Find("Champions/Support").GetComponentInChildren <Image>().sprite  = Champion.Get(t_Team["support"].AsInt).Image;
                t_Instance.transform.Find("Champions/Marksman").GetComponentInChildren <Image>().sprite = Champion.Get(t_Team["marksman"].AsInt).Image;
                t_Instance.transform.Find("Champions/Jungle").GetComponentInChildren <Image>().sprite   = Champion.Get(t_Team["jungle"].AsInt).Image;

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

            t_Content.GetComponent <RectTransform>().sizeDelta = new Vector2(0, 40 + (y * t_PrefabTransform.sizeDelta.y));
            m_Array = null;
        }
    }