示例#1
0
    public IconBase addIcon(Button btn, JsonObject jo, int turn = 0)
    {
        IconBase icon = (IconBase)PoolManager.getInstance().getGameObject(jo["color"].ToString());

        icon.transform.SetParent(btn.transform);
        icon.transform.localPosition = Vector3.zero;
        icon.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
        if (!pveHero.isCanUseSkill(jo))
        {
            icon.init(jo);
            icon.setCDTime("");
        }
        else
        {
            icon.init(jo).Func = new callBackFunc <JsonObject> (onClickCallBack);
        }


        //equip.gameObject.SetActive (true);
        if (turn > 0)
        {
            icon.setCDTime(turn.ToString());
        }

        IconBaseList.Add(icon);
        return(icon);
    }
    public void setHeChengStone(int stoneId)
    {
        if (stoneId > 0)
        {
            if (stoneItemId == 0)
            {
                JsonObject stoneData = DataManager.getInstance().itemDicJson [stoneId];
                //JsonObject jo = BagManager.getInstance ().getItemStaticData (stoneData);
                //	data = BagManager.getInstance ().getEquipById (id);
                //}

                //Button stoneKuang = stones[pos];
                //equip.sprite =
                IconBase icon = (IconBase)PoolManager.getInstance().getGameObject(stoneData ["color"].ToString());
                icon.init(stoneData).Func = new callBackFunc <JsonObject> (onClickStone);
                //icon.Func = new callBackFunc<JsonObject> (onClickStone);
                icon.transform.SetParent(stoneNew.transform);
                icon.transform.localPosition = Vector3.zero;
                icon.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
                IconBaseArr.Add(icon);
            }
        }
        else
        {
            TipManager.instance.showTip(1003);
            //onClose();
        }
    }
示例#3
0
    public void addHero(JsonObject herodata)
    {
        JsonObject staticdata = HeroManager.getInstance().getHeroStaticData(herodata);
        IconBase   icon       = (IconBase)PoolManager.getInstance().getGameObject(staticdata["color"].ToString());

        icon.init(herodata).Func = new callBackFunc <JsonObject> (onClickHead);
        //icon.init (equip).Func = new callBackFunc<JsonObject> (onClickStone);
        icon.transform.SetParent(content);
        //icon.transform.localScale = new Vector3 (0.5f,0.5f,0.5f);
        icon.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
        Button btn = icon.GetComponent <Button> ();

        /**string name = staticdata ["name"].ToString ();
         * if (content.childCount == 0) {
         *      heroHeadDemo.transform.FindChild ("Text").GetComponent<Text>().text = name;
         *      heroHeadDemo.transform.SetParent (content.transform);
         *      btn = heroHeadDemo;
         *      OnChangeHero(herodata,heroHeadDemo);
         * } else {
         *      btn = (Button)GameObject.Instantiate (heroHeadDemo,heroHeadDemo.transform.position,heroHeadDemo.transform.rotation,heroHeadDemo.transform.parent);
         *      btn.interactable = true;
         *      btn.transform.FindChild ("Text").GetComponent<Text>().text = name;
         *
         *      //btn.transform.SetParent (content.transform);
         * }**/
        heroHeadList.Add(btn);
        //btn.onClick.AddListener(delegate() {
        //	JsonObject data = herodata;
        //
        //
        //});
    }
示例#4
0
    public void OnChangeHero(JsonObject herodata)
    {
        if (herodata == null || heroHeadList == null)
        {
            return;
        }
        selectKind       = null;
        staticdata       = HeroManager.getInstance().getHeroStaticData(herodata);
        data             = herodata;
        heroStyle.sprite = Resources.Load("hero/" + staticdata["style"].ToString(), typeof(Sprite)) as Sprite;
        heroStyle.SetNativeSize();

        for (int i = 0; i < heroHeadList.Count; i++)
        {
            Button btn2 = (Button)heroHeadList[i];
            btn2.interactable = true;
        }
        //if (skeletonAnimation != null && skeletonAnimation.isActiveAndEnabled) {
        //	skeletonAnimation.transform.parent = null;
        //	skeletonAnimation.gameObject.SetActive (false);
        //}
        //skeletonGraphic.init(herodata);

        //skeletonGraphic.startingAnimation = "attack";
        //btn.interactable = false;
        //技能
        for (int i = 1; i <= 4; i++)
        {
            JsonObject skilldata = DataManager.getInstance().skillDicJson[int.Parse(staticdata["skill" + i.ToString()].ToString())];
            //skillName.text = skilldata["name"].ToString();
            Button skill = (Button)skillList[i - 1];
            skill.image.sprite = Resources.Load(skilldata["icon"].ToString(), typeof(Sprite)) as Sprite;
            skill.image.SetNativeSize();
            IconBase icon = (IconBase)PoolManager.getInstance().getGameObject(skilldata["color"].ToString());
            icon.init(skilldata).Func = new callBackFunc <JsonObject> (onCallBack);
            //icon.Func = new callBackFunc<JsonObject> (onCallBack);
            icon.transform.SetParent(skill.transform);
            icon.transform.localPosition = Vector3.zero;
            icon.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
            //iTween.ScaleTo(icon.gameObject, iTween.Hash("y", 0.5f,"x", 0.5f,"z", 0.5f ,"delay", 0.0f,"time",0.5f));
            //skill.gameObject.SetActive (true);
        }


        for (int i = 0; i < starArr.Count; i++)
        {
            RawImage star = (RawImage)starArr [i];
            star.gameObject.SetActive(true);
            //Destroy (star);
        }

        heroSharedId = int.Parse(staticdata["heroSharedId"].ToString());
        updateHero(herodata);
        //yield return isUpdate;
    }
示例#5
0
    public void intiData(int _number, JsonObject jo, int _phb_type)
    {
        data        = jo;
        phb_type    = _phb_type;
        number.text = _number.ToString();
        if (jo.ContainsKey("name"))
        {
            name.text = jo ["name"].ToString();
        }
        else
        {
            name.text = jo ["id"].ToString();
        }
        if (data.ContainsKey("playerId"))
        {
            playerId = int.Parse(data ["playerId"].ToString());
        }
        else
        {
            playerId = int.Parse(data ["id"].ToString());
        }
        //icon.gameObject.SetActive (true);
        //icon.transform.localScale = new Vector3 (0.5f,0.5f,0.5f);
        if (icon != null)
        {
            PoolManager.getInstance().addToPool(icon.type, icon);
            icon = null;
        }
        JsonObject sjo = null;

        if (jo.ContainsKey("itemId"))
        {
            sjo = BagManager.getInstance().getItemStaticData(jo);
        }
        else if (jo.ContainsKey("heroId"))
        {
            sjo = HeroManager.getInstance().getHeroStaticData(jo);
        }

        if (sjo != null)
        {
            //if (icon == null) {
            icon = (IconBase)PoolManager.getInstance().getGameObject(sjo["color"].ToString());
            //}
            icon.transform.SetParent(this.transform);

            icon.transform.localScale    = new Vector3(0.5f, 0.5f, 0.5f);
            icon.transform.localPosition = new Vector3(25.0f, 0.0f, 0.0f);

            icon.init(sjo);
        }

        fight.text = jo ["fightPoint"].ToString();
    }
示例#6
0
    public void addHero(JsonObject herodata)
    {
        JsonObject staticdata = HeroManager.getInstance().getHeroStaticData(herodata);
        IconBase   icon       = (IconBase)PoolManager.getInstance().getGameObject(staticdata["color"].ToString());

        icon.init(herodata).Func = new callBackFunc <JsonObject> (onClickHead);
        icon.transform.SetParent(content);
        //icon.transform.localScale = new Vector3 (0.5f,0.5f,0.5f);
        icon.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
        //Button btn = icon.GetComponent<Button> ();
        heroHeadList.Add(icon);
    }
示例#7
0
    public void initStone()     //宝石系统
    //List<object> stones = jo["stones"] as List<object>;


    {
        for (int i = 0; i < stoneArr.Count; i++)
        {
            stoneArr [i].gameObject.SetActive(i < pinzhi?true:false);
        }
        //if (openType > 0) {
        List <JsonObject> theEquipHaveStones = BagManager.getInstance().getStoneByEquipId(Id);

        for (int k = 0; k < theEquipHaveStones.Count; k++)
        {
            JsonObject stoneData = theEquipHaveStones [k];
            JsonObject jo        = BagManager.getInstance().getItemStaticData(stoneData);
            int        pos       = int.Parse(stoneData ["pos"].ToString());
            if (pos > 0)
            {
                Button stoneKuang = stoneArr [pos - 1];
                //equip.sprite =
                IconBase icon = (IconBase)PoolManager.getInstance().getGameObject(jo ["color"].ToString());
                if (openType > 0)
                {
                    icon.init(stoneData).Func = new callBackFunc <JsonObject> (onClickStone);
                }
                else
                {
                    icon.init(stoneData);
                }
                //icon.Func = new callBackFunc<JsonObject> (onClickStone);
                icon.transform.SetParent(stoneKuang.transform);
                icon.transform.localPosition = Vector3.zero;
                icon.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
                IconBaseArr.Add(icon);
            }
        }
        //}
    }
示例#8
0
    public void sortEntityBySpeed()
    {
        if (actIndex > 0 && PveEntityList.Count > actIndex)
        {
            PveEntityList [actIndex - 1].disActive();
        }
        actIndex = 0;
        PveEntityList.Clear();
        foreach (KeyValuePair <int, PveHero> kvp in PveHeroList)
        {
            PveEntityList.Add(kvp.Value);
        }
        foreach (KeyValuePair <int, PveMonster> kvp in PveMonsterList)
        {
            PveEntityList.Add(kvp.Value);
        }
        PveEntity temp;

        //冒泡排序
        for (int i = 0; i < PveEntityList.Count; i++)
        {
            for (int j = i + 1; j < PveEntityList.Count; j++)
            {
                if (PveEntityList[j].PropertyDic[Property.SPEED] > PveEntityList[i].PropertyDic[Property.SPEED])
                {
                    temp             = PveEntityList[j];
                    PveEntityList[j] = PveEntityList[i];
                    PveEntityList[i] = temp;
                }
            }
        }
        IconBase[] array = attackList.GetComponentsInChildren <IconBase> ();
        for (int i = 0; i < array.Length; i++)
        {
            IconBase icon = array [i];
            PoolManager.getInstance().addToPool(icon.type, icon);
        }
        for (int i = 0; i < PveEntityList.Count; i++)
        {
            JsonObject jo   = DataManager.getInstance().getStaticData(PveEntityList [i].entityData);
            IconBase   icon = (IconBase)PoolManager.getInstance().getGameObject(jo["color"].ToString());
            icon.init(PveEntityList [i].entityData).Func = new callBackFunc <JsonObject> (onClickCallBack);
            icon.transform.SetParent(attackList);
            //icon.transform.localPosition = Vector3.zero;
            icon.transform.localScale  = new Vector3(1.0f, 1.0f, 1.0f);
            PveEntityList [i].iconBase = icon;
        }
    }
示例#9
0
    public void addHeroHead(JsonObject herodata)
    {
        string     heroId         = herodata ["heroId"].ToString();
        JsonObject heroStaticdata = HeroManager.getInstance().getHeroStaticData(herodata);
        string     heroName       = heroStaticdata["name"].ToString();

        /**for (int i = 0; i < heroHeadList.Count; i++)
         * {
         *      IconBase btn2 = (IconBase)heroHeadList [i];
         *
         *      if (btn2.name == heroId) {
         *              btn2.gameObject.SetActive (true);
         *              btn2.transform.SetParent (content);
         *              return;
         *      }
         * }
         * Image btn;
         **/


        //heroHeadDemo.gameObject.SetActive (true);

        IconBase icon = (IconBase)PoolManager.getInstance().getGameObject(heroStaticdata["color"].ToString());

        /**if (num > i) {
         *              icon = dropIconArray [i];
         *              index++;
         *      } else {
         *              icon = (IconBase)PoolManager.getInstance ().getGameObject (jo["color"].ToString());
         *      }**/
        icon.init(heroStaticdata);         //.Func = new callBackFunc<JsonObject>(onClickDropItem);
        icon.transform.SetParent(content);
        //icon.transform.localScale = new Vector3 (0.5f,0.5f,0.5f);
        //icon.transform.localPosition = new Vector3 (xoffset,0,0);
        icon.name = heroId;
        heroHeadList.Add(icon);
        //btn.onClick.AddListener(delegate () {
        //this.OnChangeHero(herodata, btn);
        //Debug.Log ("asfdasfa");

        //});
        //UGUIEventTrigger.Get(btn.gameObject).AddEventListener(EventTriggerType.PointerDown, OnHeadClickDown);
        //UGUIEventTrigger.Get(btn.gameObject).AddEventListener(EventTriggerType.EndDrag, OnClickUp);
        //UGUIEventTrigger.Get(btn.gameObject).AddEventListener(EventTriggerType.PointerExit, OnMove);
    }
示例#10
0
    public void addStone(JsonObject stoneData, int pos)
    {
        JsonObject jo = BagManager.getInstance().getItemStaticData(stoneData);

        //	data = BagManager.getInstance ().getEquipById (id);
        //}

        stoneInUseId.Add(int.Parse(stoneData ["id"].ToString()));
        Button stoneKuang = stones[pos];
        //equip.sprite =
        IconBase icon = (IconBase)PoolManager.getInstance().getGameObject(jo ["color"].ToString());

        icon.init(stoneData).Func = new callBackFunc <JsonObject> (onClickStone);
        //icon.Func = new callBackFunc<JsonObject> (onClickStone);
        icon.transform.SetParent(stoneKuang.transform);
        icon.transform.localPosition = Vector3.zero;
        icon.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
        IconBaseArr.Add(icon);
    }
示例#11
0
    public void showDropItem(string[] dropArr)
    {
        //Rect rect = this.GetComponent<Image> ().rectTransform.rect;
        float xoffset = 40;

        IconBase[] dropIconArray = dropPanel.transform.GetComponentsInChildren <IconBase> ();
        int        num           = dropIconArray.Length;
        int        index         = 0;

        for (int j = index; j < dropIconArray.Length; j++)
        {
            IconBase icon = dropIconArray [j];
            if (icon != null)
            {
                PoolManager.getInstance().addToPool(icon.type, icon);
            }
        }
        for (int i = 0; i < dropArr.Length; i++)
        {
            string[]   itemInfo = dropArr [i].Split('_');
            int        itemId   = int.Parse(itemInfo[0]);
            JsonObject jo       = DataManager.getInstance().getItemDataById(itemId);
            IconBase   icon     = (IconBase)PoolManager.getInstance().getGameObject(jo["color"].ToString());

            /**if (num > i) {
             *      icon = dropIconArray [i];
             *      index++;
             * } else {
             *      icon = (IconBase)PoolManager.getInstance ().getGameObject (jo["color"].ToString());
             * }**/
            index++;
            icon.init(jo).Func = new callBackFunc <JsonObject>(onClickDropItem);
            icon.transform.SetParent(dropPanel.transform);
            icon.transform.localScale    = new Vector3(0.5f, 0.5f, 0.5f);
            icon.transform.localPosition = new Vector3(xoffset, 0, 0);
            xoffset += 55;
        }
    }
示例#12
0
    public void updateHero(JsonObject herodata)
    {
        //if (data == null || herodata.heroId == data.heroId) {
        //data = herodata;
        staticdata = HeroManager.getInstance().getHeroStaticData(herodata);
        data       = herodata;
        for (int i = 0; i < equipedList.Count; i++)
        {
            //Button btn = equips [kvp.Key];
            IconBase icon = (IconBase)equipedList[i];
            if (icon != null)
            {
                PoolManager.getInstance().addToPool(icon.type, icon);
            }
        }
        equipedList.Clear();
        //JsonObject staticdata = data ["staticdata"] as JsonObject;
        //JsonObject data = data ["data"] as JsonObject;
        heroId          = int.Parse(data ["heroId"].ToString());
        heroAttack.text = DataManager.getInstance().getHeroDamage(data).ToString();
        //heroAttackRange.text = data["attackRange"].ToString();
        heroAttackSpeed.text = DataManager.getInstance().getHeroAttackSpeed(data).ToString();
        heroHP.text          = DataManager.getInstance().getHeroHp(data).ToString();
        heroDefence.text     = DataManager.getInstance().getHeroDefence(data).ToString();

        //升星更新
        //updateBtn(shengxingBtn,shengxingNeedInfo,heroSharedId,"starLevel","starLevelUpNeed","levelUp");


        //升级更新
        //updateBtn(shengjiBtn,shengjiNeedInfo,1000,"level","needExpPoint","levelUp");


        heroPingFen.text = (int.Parse(heroAttack.text) * 8 + int.Parse(heroDefence.text) * 5 + (int.Parse(heroAttackSpeed.text) * 6)).ToString();
        heroBB.text      = staticdata["desc"].ToString();
        heroName.text    = "Lv." + data["level"].ToString() + " " + staticdata["name"].ToString();
        heroName.color   = DataManager.getInstance().getColor(staticdata["color"].ToString());
        ArrayList equipArr = BagManager.getInstance().getEquipByHeroId(heroId);

        for (int i = 0; i < equipArr.Count; i++)
        {
            JsonObject jo   = equipArr [i] as JsonObject;
            JsonObject sdjo = BagManager.getInstance().getItemStaticData(jo);
            string     key  = sdjo ["kind"].ToString();
            if (equips.ContainsKey(key))
            {
                Button equip = equips [key];

                //equip.sprite =
                IconBase icon = (IconBase)PoolManager.getInstance().getGameObject(sdjo["color"].ToString());
                icon.init(jo).Func = new callBackFunc <JsonObject> (onCallBack);
                //icon.Func = new callBackFunc<JsonObject> (onCallBack);
                icon.transform.SetParent(equip.transform);
                icon.transform.localPosition = Vector3.zero;
                icon.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
                //iTween.ScaleTo(icon.gameObject, iTween.Hash("y", 0.5f,"x", 0.5f,"z", 0.5f ,"delay", 0.0f,"time",0.5f));
                equip.gameObject.SetActive(true);
                //(icon.GetComponent<Button>()).interactable = false;
                equipedList.Add(icon);
            }
        }
        int starLevel = int.Parse(data ["starLevel"].ToString());

        for (int i = 0; i < starLevel; i++)
        {
            RawImage star = (RawImage)starArr [i];
            star.gameObject.SetActive(false);
            //Destroy (star);
        }
        //isUpdate = false;
        //}
    }
示例#13
0
    public void initSuit(JsonObject jo)     //套装系统
    {
        JsonObject suit = DataManager.getInstance().getSuitByEquip(jo);

        int suitNum = 0;

        if (suit != null)
        {
            suitNum += 1;
            suitPanel.gameObject.SetActive(true);
            foreach (KeyValuePair <string, object> kvp in suit)
            {
                if (suitArr.ContainsKey(kvp.Key))
                {
                    string value = kvp.Value.ToString();
                    bool   isInt = Regex.IsMatch(value, @"^[+-]?\d*$");

                    if (isInt)
                    {
                        JsonObject equip = DataManager.getInstance().itemDicJson [int.Parse(value)];
                        suitArr [kvp.Key].text = equip ["name"].ToString();
                        ///////////////////////////////////////////////////
                        Button stoneKuang = equipArr [kvp.Key];
                        //equip.sprite =
                        IconBase icon = (IconBase)PoolManager.getInstance().getGameObject(jo ["color"].ToString());
                        if (openType > 0)
                        {
                            icon.init(equip).Func = new callBackFunc <JsonObject> (onClickStone);
                        }
                        else
                        {
                            icon.init(equip);
                        }
                        //icon.Func = new callBackFunc<JsonObject> (onClickStone);
                        icon.transform.SetParent(stoneKuang.transform);
                        icon.transform.localPosition = Vector3.zero;
                        icon.transform.localScale    = new Vector3(1.0f, 1.0f, 1.0f);
                        IconBaseArr.Add(icon);
                        /////////////////////////////////////////
                        int heroId = 0;
                        if (data.ContainsKey("owerId"))
                        {
                            heroId = int.Parse(data ["owerId"].ToString());
                        }
                        if (heroId > 0)
                        {
                            if (kvp.Key == kind)
                            {
                                suitArr [kvp.Key].color = DataManager.getInstance().getColor(equip ["color"].ToString());
                            }
                            else
                            {
                                JsonObject otherEquip = BagManager.getInstance().getEquipByHeroIdAndItemId(heroId, int.Parse(value));

                                if (otherEquip != null)
                                {
                                    suitNum += 1;
                                    JsonObject otherEquipStaticData = BagManager.getInstance().getItemStaticData(otherEquip);
                                    suitArr [kvp.Key].color = DataManager.getInstance().getColor(otherEquipStaticData ["color"].ToString());
                                }
                                else
                                {
                                    suitArr [kvp.Key].color = Color.gray;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (kvp.Key.IndexOf("suit") >= 0)
                        {
                            string   format     = DataManager.getInstance().suitJson [0] [kvp.Key].ToString();
                            string[] shuxingArr = value.Split('_');
                            if (shuxingArr.Length == 2)
                            {
                                suitArr [kvp.Key].text = string.Format(format, shuxingArr [0], shuxingArr [1]);
                            }
                            else if (shuxingArr.Length == 3)
                            {
                                suitArr [kvp.Key].text = string.Format(format, shuxingArr [0], shuxingArr [1], shuxingArr [2]);
                            }
                            else
                            {
                                suitArr [kvp.Key].text = value;
                            }
                        }
                        else
                        {
                            suitArr [kvp.Key].text = value;
                        }

                        suitArr [kvp.Key].color = Color.gray;
                    }
                }
            }
            suitArr ["name"].text += "[" + suitNum.ToString() + "/4]";
            suitArr["name"].color  = suitArr [kind].color;
            if (suitNum == 2)
            {
                suitArr ["suit2"].color = Color.green;
            }
            else if (suitNum == 3)
            {
                suitArr ["suit2"].color = Color.green;
                suitArr ["suit3"].color = Color.green;
            }
            else if (suitNum == 4)
            {
                suitArr ["suit2"].color = Color.green;
                suitArr ["suit3"].color = Color.green;
                suitArr ["suit4"].color = Color.green;
            }
        }
        else
        {
            suitPanel.gameObject.SetActive(false);
        }
    }