コード例 #1
0
ファイル: RoleCtrl.cs プロジェクト: wtrd1234/GameProject3
    private void OnAck_AddHeroExp(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckAddPlayerExp        ack = Serializer.Deserialize <AckAddPlayerExp>(ms);

        XCharacter player   = RoleModule.Instance.GetCurPlayer();
        int        oldLevel = player.Level;

        int maxLevel = ReadCfgRoleLevel.Count;

        if (player.Level >= maxLevel)
        {
            return;
        }
        player.CurExp += ack.Exp;
        DRoleLevel levelDB = ReadCfgRoleLevel.GetDataById(player.Level);

        while (player.CurExp >= levelDB.RequireExp)
        {
            player.CurExp -= levelDB.RequireExp;
            player.Level++;
            if (player.Level >= maxLevel)
            {
                player.CurExp = 0;
                break;
            }
            levelDB = ReadCfgRoleLevel.GetDataById(player.Level);
        }
        DataDBSRole.Update(player.Id, player);
        GTItemHelper.ShowExpTip(ack.Exp);


        int newLevel = player.Level;

        if (newLevel > oldLevel)
        {
            CharacterManager.Instance.SyncMainPlayerData(ESyncDataType.TYPE_LEVEL);
            GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_HEROLEVEL);
            GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_FIGHTVALUE);
        }
        GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_HEROEXP);
    }
コード例 #2
0
ファイル: UIHeroInfo.cs プロジェクト: zyb2013/GameProject3
    private void ShowView()
    {
        for (int i = 0; i < moneyViewList.Count; i++)
        {
            MoneyView mv = moneyViewList[i];
            DItem     db = ReadCfgItem.GetDataById(i + 1);
            GTItemHelper.ShowItemTexture(mv.moneyTexture, db.Id);
            mv.moneyNumText.text = GTDataManager.Instance.GetItemCountById(db.Id).ToString();
        }

        XCharacter role        = GTGlobal.Main;
        DRoleLevel heroLevelDB = ReadCfgRoleLevel.GetDataById(role.Level);

        heroName.text    = role.Name;
        heroLevel.text   = GTTools.Format("等级 {0}", role.Level);
        heroVIP.text     = GTTools.Format("VIP {0}", role.VipLevel);
        heroExpNum.text  = GTTools.Format("{0}/{1}", role.CurExp, heroLevelDB.RequireExp);
        heroExpBar.value = role.CurExp / (heroLevelDB.RequireExp * 1f);
        int fightValue = GTAttrHelper.GetFightValue(role);

        heroFightValue.text = GTTools.Format("战斗力 {0}", fightValue);
    }