Exemplo n.º 1
0
    /// <summary>
    /// 添加系统英雄
    /// </summary>
    static void AddHeroMap(string id)
    {
        JsonData heroList = Get(DataType.HeroList);
        HeroJson hero     = JsonMapper.ToObject <HeroJson>(heroList[id].ToJson());

        heroMap.Add(hero.id, hero);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 添加英雄
    /// </summary>
    static void AddUserHeroJson(string id)
    {
        JsonData heroList = Get(DataType.HeroList);
        HeroJson hero     = JsonMapper.ToObject <HeroJson>(heroList[id].ToJson());

        hero.heroId = userHeroMap.Count;
        userHeroMap.Add(userHeroMap.Count, hero);
    }
Exemplo n.º 3
0
    public void InitData(int heroId)
    {
        hero      = HerosModel.GetHeroJsonByHeroId(heroId);
        hero.view = this;

        float         x   = Random.Range(-150, 150);
        float         y   = Random.Range(-300, 300);
        RectTransform rtf = GetComponent <RectTransform>();

        rtf.anchoredPosition = new Vector2(x, y);
        rtf.localScale       = Vector3.one;
        FreshView();
    }
Exemplo n.º 4
0
        public static List <HeroJson> ToJsonListHero(this List <Hero> l)
        {
            List <HeroJson> NewList = new List <HeroJson>();

            foreach (Hero h in l)
            {
                HeroJson hjson = h.ToJsonHero();
                if (hjson.CheckValidity())
                {
                    NewList.Add(hjson);
                }
            }
            return(NewList);
        }
Exemplo n.º 5
0
    /// <summary>
    /// 1对1
    /// </summary>
    /// <param name="json">数据类</param>
    public static void VSOne(HeroJson hero)
    {
        int userAtt = 10;

        hero.hp -= userAtt;
        //刷文本
        hero.view.preHPChangeValue = -userAtt;
        NotiCenter.DispatchEvent(KCEvent.KCHeroHPChange, (object)hero.view);

        if (hero.hp > 0)
        {
            hero.view.Fresh(FreshType.Hp);
            return;
        }
        //死亡
        hero.hp = 0;
        hero.view.Fresh(FreshType.Hp);
        hero.view.Fresh(FreshType.Die);
        ItemsModel.AddItems(hero.items);
    }
Exemplo n.º 6
0
    public override void Parse(Object asset)
    {
        if (asset != null && asset is TextAsset)
        {
            TextAsset          textAsset = (TextAsset)asset;
            string             sJson     = textAsset.text;
            LitJson.JsonReader jsonR     = new LitJson.JsonReader(sJson);
            LitJson.JsonData   jsonD     = LitJson.JsonMapper.ToObject(jsonR);
            foreach (string skey in jsonD.Keys)             // 将解析到的数据放到dict
            {
                LitJson.JsonData itemData = jsonD[skey];
                if (itemData == null)
                {
                    continue;
                }
                HeroJson heroItem = HeroJson.Parse(itemData);
                m_heros.Add(heroItem.id, heroItem);
            }

            Globals.It.BundleMgr.UnLoadBundleLocal(asset);
        }
    }
Exemplo n.º 7
0
    // 解析英雄
    public static HeroJson Parse(LitJson.JsonData data)
    {
        HeroJson json = new HeroJson();

        try {
            json.attrType    = (int)data["attrType"];
            json.energy      = (int)data["energy"];
            json.xy          = (int)data["xy"];
            json.baseQuality = (int)data["baseQuality"];
            json.skill       = (int)data["skill"];

            json.id         = (int)data["id"];
            json.resourceid = (int)data["resourceid"];
            json.type       = (int)data["type"];
            json.maxenergy  = (int)data["maxenergy"];
            json.soulcount  = (int)data["soulcount"];

            json.growpet   = (int)data["growpet"];
            json.VitGrowth = (int)data["VitGrowth"];
            json.coin      = (int)data["coin"];
            json.nickname  = (string)data["nickname"];
            json.icon      = (int)data["icon"];

            json.ordSkill     = (int)data["ordSkill"];
            json.level        = (int)data["level"];
            json.descript     = (string)data["descript"];
            json.soulrequired = (int)data["soulrequired"];
            json.DexGrowth    = (int)data["DexGrowth"];

            json.StrGrowth = (int)data["StrGrowth"];
            json.WisGrowth = (int)data["WisGrowth"];
        }
        catch {
        }
        return(json);
    }
Exemplo n.º 8
0
        public static HeroJson ToJsonHero(this Hero h)
        {
            HeroJson NewHero = new HeroJson(h.Id, h.Name, h.Image, h.Desc, h.Status, h.Team, h.Universe);

            return(NewHero);
        }
Exemplo n.º 9
0
        public void TestHeroInvalidFile()
        {
            HeroJson Hero = new HeroJson("id", "test", "ImagesMovies/ironMan8.png", "desc", 0, 0, 0);

            Assert.IsFalse(Hero.CheckValidity());
        }
Exemplo n.º 10
0
        public void TestHeroInvalidDesc()
        {
            HeroJson Hero = new HeroJson("", "   ", "ImagesMovies/ironMan.png", "desc", 0, 0, 0);

            Assert.IsFalse(Hero.CheckValidity());
        }
Exemplo n.º 11
0
        public void TestHeroInvalidID()
        {
            HeroJson Hero = new HeroJson("", "test", "ImagesHero/ironMan.png", "desc", 0, 0, 0);

            Assert.IsFalse(Hero.CheckValidity());
        }
Exemplo n.º 12
0
        public void TestSerieValid()
        {
            HeroJson Serie = new HeroJson("test", "test", "ImagesHero/ironMan.png", "desc", 0, 0, 0);

            Assert.IsTrue(Serie.CheckValidity());
        }
Exemplo n.º 13
0
        public void TestHeroValid()
        {
            HeroJson Hero = new HeroJson("test", "test", "ImagesHero/ironMan.png", "desc", 0, 0, 0);

            Assert.IsTrue(Hero.CheckValidity());
        }
Exemplo n.º 14
0
 public void setData(HeroJson data)
 {
     this.data = data;
     superInit();
     skillButtonInit();
 }