public void FlushItem(UILevelItem uiItem, int index)
 {
     if (datas != null)
     {
         uiItem.Init(datas[index]);
     }
 }
Beispiel #2
0
    public void Refresh(LevelDifficulty level_difficulty)
    {
        var datas       = GameControl.Instance.game_data.GetLevelDatas(level_difficulty);
        int child_count = this._level_parent.transform.childCount;

        if (child_count < datas.Count)
        {
            for (int i = 0; i < datas.Count - child_count; i++)
            {
                UILevelItem item = UILevelItem.Create(this._level_parent);
                this.level_items.Add(item);
            }
        }

        for (int i = 0; i < this.level_items.Count; i++)
        {
            this.level_items[i].gameObject.SetActive(false);
        }
        int index = 0;

        foreach (var item in datas)
        {
            this.level_items[index].Init(item.Value);
            this.level_items[index].gameObject.SetActive(true);
            index++;
        }
    }
Beispiel #3
0
    void Start()
    {
        int levelCount = 0;

        //Create level items in UIgrid
        foreach (LevelData _leveldata in levelData)
        {
            //Save level list in globalGameData for later use
            GlobalGameSettings.LevelData.Add(_leveldata);

            //Create a UI level item
            GameObject UILevelItem = GameObject.Instantiate(LevelItemPrefab, UIGrid.transform) as GameObject;

            //Fill UI level item with data
            if (UILevelItem != null)
            {
                UILevelItem.name = _leveldata.levelTitle;

                //pass level data to level item
                UILevelItem levelItem = UILevelItem.GetComponent <UILevelItem>();
                if (levelItem != null)
                {
                    levelItem.levelData         = _leveldata;
                    levelItem.levelData.levelId = levelCount;
                    levelCount++;
                }

                //Select the 1st level
                if (selectFirstLevel)
                {
                    EventSystem.current.SetSelectedGameObject(UILevelItem);
                    selectFirstLevel = false;
                }

                //Set level text
                Text levelTitle = UILevelItem.GetComponentInChildren <Text>();
                if (levelTitle != null)
                {
                    levelTitle.text = _leveldata.levelTitle;
                }

                //Load level sprite...if there is one
                Image levelImg = UILevelItem.GetComponent <Image>();
                if (levelImg == null)
                {
                    return;
                }

                if (_leveldata.levelSprite == null)
                {
                    levelImg.enabled = false;
                    Debug.Log("No level sprite assigned for " + _leveldata.levelTitle);
                }
                else
                {
                    levelImg.sprite = _leveldata.levelSprite;
                }
            }
        }
    }
 public void SelectItem(UIGridView table, UILevelItem selectItem, int Idx)
 {
     if (datas != null)
     {
         m_SelectedHero = selectItem.level_data;
         if (m_SelectedHero != null && GameData.GetPassedLevel(m_SelectedHero.Level_Difficulty) >= m_SelectedHero.CurrentLevel)
         {
             GameControl.Instance.PlayGame(GameType.Custom, m_SelectedHero.Level_Difficulty, m_SelectedHero.CurrentLevel);
             SDK.Instance.StartLevel(string.Format("进入关卡{0}难度{1}类型{2}", m_SelectedHero.CurrentLevel, m_SelectedHero.Level_Difficulty, GameType.Custom));
         }
     }
 }
    public TableViewCell tableCellAtIndex(UIGridView table, TableViewCell cell, int idx)
    {
        UILevelTableViewCell itemCell      = cell as UILevelTableViewCell;
        UILevelItem          m_UILevelItem = null;

        if (itemCell == null)
        {
            itemCell              = new UILevelTableViewCell();
            m_UILevelItem         = UILevelItem.Create();
            itemCell._UILevelItem = m_UILevelItem;
            FlushItem(m_UILevelItem, idx);
            EventTriggerClick.Get(m_UILevelItem.gameObject).onClick = (o) =>
            {
                SelectItem(table, m_UILevelItem, itemCell.Idx);
            };
        }
        else
        {
            m_UILevelItem = itemCell._UILevelItem;
            FlushItem(m_UILevelItem, idx);
        }
        return(itemCell);
    }
Beispiel #6
0
    public void OnLevelInfo(NetworkMessage netMsg)
    {
        MObjects.LevelInfo mObject = netMsg.ReadMessage <MObjects.LevelInfo>();

        string step   = "\r\n";
        int    lCount = mObject.levels.Length;

        /*
         * CLEAR
         * */
        // Clear level panel
        int cCount = levels_Grid.childCount;

        for (int i = 0; i < cCount; i++)
        {
            Destroy(levels_Grid.GetChild(i).gameObject);
        }

        /*
         * BUILD
         * */
        for (int i = 0; i < lCount; i++)
        {
            Transform l = Instantiate(level_Prefab, levels_Grid);
            l.Find("reqLevel").GetComponent <Text>().text = mObject.levels[i].level.ToString();

            l.name = mObject.levels[i].level.ToString();

            UILevelItem ul = l.GetComponent <UILevelItem>();

            ul.myLevelInfo = mObject.levels[i];

            ul.core = new System.Text.StringBuilder();
            ul.pro  = new System.Text.StringBuilder();

            ul.core.Append("<color=#b7e0e2>" + Language.GetText(48) + "</color>" + step);
            ul.pro.Append(mObject.levels[i].level + step);

            if (mObject.levels[i].Percent_health > 0)
            {
                ul.core.Append(step + Language.GetText(50));
                ul.pro.Append(step + "%" + mObject.levels[i].Percent_health);
            }

            if (mObject.levels[i].Percent_effect > 0)
            {
                ul.core.Append(step + Language.GetText(51));
                ul.pro.Append(step + "%" + mObject.levels[i].Percent_effect);
            }

            if (mObject.levels[i].Percent_fastercast > 0)
            {
                ul.core.Append(step + Language.GetText(52));
                ul.pro.Append(step + "%" + mObject.levels[i].Percent_fastercast);
            }

            if (mObject.levels[i].Percent_cooldown > 0)
            {
                ul.core.Append(step + Language.GetText(53));
                ul.pro.Append(step + "%" + mObject.levels[i].Percent_cooldown);
            }

            if (mObject.levels[i].Percent_movespeed > 0)
            {
                ul.core.Append(step + Language.GetText(54));
                ul.pro.Append(step + "%" + mObject.levels[i].Percent_movespeed);
            }
        }
    }
Beispiel #7
0
    public void OnAgentLevel(NetworkMessage netMsg) // agent level info
    {
        MObjects.AgentLevel mObject = netMsg.ReadMessage <MObjects.AgentLevel>();

        MobileAgent ma = MobileAgent.list.Find(x => x.id == mObject.id);

        if (ma == null)
        {
            return;
        }

        if (ma.level != 0 && ma.level != mObject.level)
        {
            // LEVEL UP PARTICLE
            CreateParticle("LevelUp", ma.transform);
            ma.CreateTextEffect(Language.GetText(59), Color.green);
        }

        else if (ma.exp != 0 && ma.exp != mObject.exp)
        {
            ma.CreateTextEffect((mObject.exp - ma.exp) + " " + Language.GetText(45), Color.yellow);
        }

        ma.level = mObject.level;
        ma.exp   = mObject.exp;

        if (MobileAgent.user == ma)
        {
            /*
             * OUR CLIENTS WORK
             * */

            clientLevelFiller.fillAmount = mObject.exp / (float)mObject.requiredExp;
            clientLevelText.text         = mObject.level.ToString();

            /*
             * UPDATE USER LEVEL TOOLTIP
             * */

            client_level.myLevelInfo = new MObjects.Level();

            int lCount = levels_Grid.childCount;
            for (int i = mObject.level; i > 0; i--)
            {
                Transform t = levels_Grid.Find(i.ToString());
                if (t != null)
                {
                    t.Find("reveal").gameObject.SetActive(true);
                    UILevelItem ul = t.GetComponent <UILevelItem>();
                    client_level.myLevelInfo.Percent_cooldown   += ul.myLevelInfo.Percent_cooldown;
                    client_level.myLevelInfo.Percent_effect     += ul.myLevelInfo.Percent_effect;
                    client_level.myLevelInfo.Percent_health     += ul.myLevelInfo.Percent_health;
                    client_level.myLevelInfo.Percent_fastercast += ul.myLevelInfo.Percent_fastercast;
                    client_level.myLevelInfo.Percent_movespeed  += ul.myLevelInfo.Percent_movespeed;
                }
            }

            string step = "\r\n";
            client_level.core = new System.Text.StringBuilder();
            client_level.pro  = new System.Text.StringBuilder();

            client_level.core.Append(Language.GetText(50));
            client_level.pro.Append("%" + client_level.myLevelInfo.Percent_health);

            client_level.core.Append(step + Language.GetText(51));
            client_level.pro.Append(step + "%" + client_level.myLevelInfo.Percent_effect);

            client_level.core.Append(step + Language.GetText(52));
            client_level.pro.Append(step + "%" + client_level.myLevelInfo.Percent_fastercast);

            client_level.core.Append(step + Language.GetText(53));
            client_level.pro.Append(step + "%" + client_level.myLevelInfo.Percent_cooldown);

            client_level.core.Append(step + Language.GetText(54));
            client_level.pro.Append(step + "%" + client_level.myLevelInfo.Percent_movespeed);
        }

        Transform tGrid = score_grid.Find(ma.team.ToString());

        if (tGrid == null)
        {
            return;
        }

        Transform p = tGrid.Find(ma.id.ToString());

        if (p == null)
        {
            return;
        }

        p.Find("expFiller").GetComponent <Filler>().fillAmount = mObject.exp / (float)mObject.requiredExp;
        p.Find("level").GetComponent <Text>().text             = Language.GetText(44) + " " + mObject.level;
    }