Exemplo n.º 1
0
    void LoadAvatar(int avatarResourceId)
    {
        if (role != null)
        {
            MonoBehaviour.Destroy(role.gameObject);
        }

        AvatarConfig.Avatar avatarCfg = ConfigDatabase.DefaultCfg.AvatarConfig.GetAvatarById(avatarResourceId);
        if (avatarCfg == null)
        {
            Debug.LogError(string.Format("Miss Avatar Setting : Id({0:X})", avatarResourceId));
        }

        Avatar avatar = Avatar.CreateAvatar(0x00000000);

        role = avatar.gameObject.AddComponent <BattleRole>();
        WeihuaGames.ClientClass.CombatAvatarData avatarData = new WeihuaGames.ClientClass.CombatAvatarData();
        avatarData.ResourceId = avatarResourceId;

        role.AvatarData = avatarData;
        role.Awake();
        role.AvatarAssetId = avatarCfg.breakThroughs[0].assetId;
        role.Avatar.Load(avatarCfg.breakThroughs[0].assetId, true, false);

        role.UseDefaultWeapons();
    }
Exemplo n.º 2
0
    public static BattleRole Create(WeihuaGames.ClientClass.CombatAvatarData avatarData, int teamIndex, int avatarIndex)
    {
        Avatar     avatar = Avatar.CreateAvatar((teamIndex << 24 | avatarData.BattlePosition));
        BattleRole role   = avatar.GetComponent <BattleRole>();

        if (role == null)
        {
            role = avatar.gameObject.AddComponent <BattleRole>();
        }
        AvatarConfig.Avatar avatarCfg = ConfigDatabase.DefaultCfg.AvatarConfig.GetAvatarById(avatarData.ResourceId);
        int avatarAssetId             = avatarCfg.GetAvatarAssetId(avatarData.BreakThrough);

        role.AvatarAssetId = avatarAssetId;
        role.avatarData    = new WeihuaGames.ClientClass.CombatAvatarData();
        role.AvatarData.Copy(avatarData);

        role.teamIndex      = teamIndex;
        role.avatarIndex    = avatarIndex;
        role.battlePosition = avatarData.BattlePosition;
        role.AvatarHP       = avatarData.GetAttributeByType(_AvatarAttributeType.HP).Value;

        role.Awake();

        return(role);
    }
Exemplo n.º 3
0
    public static BattleRole Create(int avatarResourceId, float maxHP, float hp, float sp, string name, int weaponResourceId)
    {
        Avatar     avatar = Avatar.CreateAvatar(avatarResourceId);
        BattleRole role   = avatar.GetComponent <BattleRole>();

        if (role == null)
        {
            role = avatar.gameObject.AddComponent <BattleRole>();
        }
        AvatarConfig.Avatar avatarCfg = ConfigDatabase.DefaultCfg.AvatarConfig.GetAvatarById(avatarResourceId);
        int avatarAssetId             = avatarCfg.breakThroughs[0].assetId;

        role.AvatarAssetId = avatarAssetId;
        // Generate a CombatAvatarData
        WeihuaGames.ClientClass.CombatAvatarData bossAvatarData = new WeihuaGames.ClientClass.CombatAvatarData();
        bossAvatarData.ResourceId  = avatarResourceId;
        bossAvatarData.DisplayName = name;
        bossAvatarData.Attributes  = new List <WeihuaGames.ClientClass.Attribute>();
        WeihuaGames.ClientClass.Attribute maxHPAttr = new WeihuaGames.ClientClass.Attribute();
        maxHPAttr.Type  = _AvatarAttributeType.MaxHP;
        maxHPAttr.Value = maxHP;
        bossAvatarData.Attributes.Add(maxHPAttr);
        WeihuaGames.ClientClass.Attribute spAttr = new WeihuaGames.ClientClass.Attribute();
        spAttr.Type  = _AvatarAttributeType.SP;
        spAttr.Value = sp;
        bossAvatarData.Attributes.Add(spAttr);

        if (weaponResourceId != IDSeg.InvalidId)
        {
            WeihuaGames.ClientClass.EquipmentData edata = new WeihuaGames.ClientClass.EquipmentData();
            edata.BreakThrough = 0;
            edata.Id           = weaponResourceId;
            bossAvatarData.Equipments.Add(edata);
        }

        role.avatarData = bossAvatarData;
        role.AvatarHP   = hp;

        role.Awake();

        return(role);
    }