Пример #1
0
        public static string CharacterIdentifierToString(CharacterKind value)
        {
            switch (value)
            {
            case CharacterKind.Barbarian:
                return("barbarian");

            case CharacterKind.Crusader:
                return("crusader");

            case CharacterKind.DemonHunter:
                return("demon-hunter");

            case CharacterKind.Monk:
                return("monk");

            case CharacterKind.Necromancer:
                return("necromancer");

            case CharacterKind.WitchDoctor:
                return("witch-doctor");

            case CharacterKind.Wizard:
                return("wizard");

            default:
                throw new DiabloApiEnumConversionException(nameof(value), value);
            }
        }
 protected Character(int xPosition, int health, CharacterKind kind, Color color, int yPosition, int damage)
 {
     XPosition = xPosition;
     Health    = health;
     Kind      = kind;
     Color     = color;
     YPosition = yPosition;
     Damage    = damage;
 }
Пример #3
0
 private void Start()
 {
     for (int n = 0; n < TableManager._instance.Get(eTableType.CharacterData)._datas.Count; n++)
     {
         GameObject    go    = ResourcePoolManager._instance.GetObj <GameObject>(ResourcePoolManager.eResourceKind.Prefab, "CharacterKind");
         CharacterKind cKind = Instantiate(go, _characterKindTr).GetComponent <CharacterKind>();
         cKind.InitKind(ResourcePoolManager._instance.GetObj <Sprite>(ResourcePoolManager.eResourceKind.Image,
                                                                      TableManager._instance.Get(eTableType.CharacterData).ToS(n + 1, "EnglishName")), this, n + 1);
         _cKindList.Add(cKind);
     }
 }
Пример #4
0
    /// <summary>
    /// Constructor.
    /// </summary>
    /// <param name="id">character identifier</param>
    /// <param name="name">character name</param>
    /// <param name="commandHint">command hint for interaction with character</param>
    /// <param name="kind">character kind</param>
    /// <param name="sceneId">reference to scene by its identifier</param>
    /// <param name="age">character age</param>
    /// <param name="gender">character gender</param>
    /// <param name="statistics">character statistics</param>
    /// <param name="inventory">character inventory</param>
    public CharacterModel(string id, string name, string commandHint, CharacterKind kind, string sceneId, int age, CharacterGender gender,
                          CharacterStatisticsModel statistics, InventoryModel inventory) :
        base(id, name, commandHint)
    {
        SceneId       = sceneId;
        Age           = age;
        Gender        = gender;
        CharacterType = kind;

        Statistics = statistics;
        statistics.SetCharacterModel(this);

        Inventory = inventory;

        TimeStamp = DateTime.UtcNow;
    }
Пример #5
0
    public CharacterProperty(CharacterProperty charProp)
    {
        this.ID            = charProp.ID;
        this.Name          = charProp.Name;
        this.Faction       = charProp.Faction;
        this.Type          = charProp.Type;
        this.EquipmentProp = new EquipProp(charProp.EquipmentProp);
        this.BuffItemProp  = new BuffProp(charProp.BuffItemProp);
        this.AllExperience = charProp.AllExperience;
        this.Sprite        = charProp.Sprite;
        this.Resistance    = charProp.Resistance;
        this.Constitution  = charProp.Constitution;
        this.Strength      = charProp.Strength;
        this.Agility       = charProp.Agility;
        this.Dexterous     = charProp.Dexterous;
        this.Concentration = charProp.Concentration;
        this.HealthLevel   = charProp.HealthLevel;
        this.charKind      = charProp.charKind;

        this.Level             = charProp.Level;
        this.CurrentExperience = charProp.CurrentExperience;
        this.MaxHealth         = charProp.MaxHealth;
        this.MaxStamina        = charProp.MaxStamina;
        this.HealthRecovery    = charProp.HealthRecovery;
        this.StaminaRecovery   = charProp.StaminaRecovery;
        this.MoveSpeed         = charProp.MoveSpeed;
        this.AimingSpeed       = charProp.AimingSpeed;
        this.Critical          = charProp.Critical;
        this.MeleeRaise        = charProp.MeleeRaise;
        this.ShootRaise        = charProp.ShootRaise;
        this.ThrowRaise        = charProp.ThrowRaise;
        this.MaxAngle          = charProp.MaxAngle;
        this.KickDamage        = charProp.KickDamage;
        this.PunchDamage       = charProp.PunchDamage;

        this.MeleeDamage    = charProp.MeleeDamage;
        this.ThrowDamage    = charProp.ThrowDamage;
        this.AttackInterval = charProp.AttackInterval;

        this.MinAngle     = charProp.MinAngle;
        this.PullingTime  = charProp.PunchDamage;
        this.ReloadTime   = charProp.ReloadTime;
        this.ShootDamage  = charProp.ShootDamage;
        this.DeclineRange = charProp.DeclineRange;
        this.Power        = charProp.Power;

        this.SkillA = charProp.SkillA;
        this.SkillB = charProp.SkillB;
        this.SkillC = charProp.SkillC;
        this.SkillD = charProp.SkillD;
        this.SkillE = charProp.SkillE;
        this.SkillF = charProp.SkillF;
        this.SkillH = charProp.SkillH;
        this.SkillI = charProp.SkillI;
        this.SkillJ = charProp.SkillJ;
        this.SkillK = charProp.SkillK;
        this.SkillL = charProp.SkillL;
        this.SkillM = charProp.SkillM;
        this.SkillN = charProp.SkillN;
        this.SkillO = charProp.SkillO;
        this.SkillP = charProp.SkillP;
        this.SkillQ = charProp.SkillQ;
        this.SkillR = charProp.SkillR;
        this.SkillS = charProp.SkillS;
        this.SkillT = charProp.SkillT;

        this.CurrentHealth      = charProp.CurrentHealth;
        this.CurrentStamina     = charProp.CurrentStamina;
        this.CurrentEnergy      = charProp.CurrentEnergy;
        this.CurrentHealthLevel = charProp.CurrentHealthLevel;
        this.WeaponWith         = charProp.WeaponWith;
    }
Пример #6
0
    /// <summary>
    /// 创建角色(base,无装备,有武器)
    /// </summary>
    /// <param name="id">ID</param>
    /// <param name="name">名字</param>
    /// <param name="faction">势力(玩家,友军,敌人)</param>
    /// <param name="type">(英雄,普通)</param>
    /// <param name="constitution">体质</param>
    /// <param name="strength">力量</param>
    /// <param name="agility">灵巧</param>
    /// <param name="dexterous">洞察</param>
    /// <param name="concentration">专注</param>
    /// <param name="weapon">武器</param>
    /// <param name="allExperience">全部经验</param>
    /// <param name="skills">技能</param>
    /// <param name="currentExperience">当前经验</param>
    public CharacterProperty(int id, string name, CharacterFaction faction, CharacterType type, string sprite, CharacterKind kind,
                             int constitution, int strength, int agility, int dexterous, int concentration, Item weapon, float allExperience, float resistance = 0,
                             int[] skills = null, float currentExperience = 0, int headID = 0, int clothID = 0, int pantsID = 0, int beltID = 0, BuffProp buffProp = null)
    {
        #region 装备处理
        if (this.EquipmentProp == null)
        {
            this.EquipmentProp = new EquipProp(headID, clothID, pantsID, beltID);
        }
        if ((headID != 0) || (clothID != 0) || (pantsID != 0) || (beltID != 0))
        {
            this.EquipmentProp = new EquipProp(headID, clothID, pantsID, beltID);
            resistance        += EquipmentProp.Resistance;
            constitution      += EquipmentProp.Constitution;
            strength          += EquipmentProp.Strength;
            dexterous         += EquipmentProp.Dexterous;
            agility           += EquipmentProp.Agility;
            concentration     += EquipmentProp.Concentration;
        }
        #endregion

        #region 加成处理
        if (buffProp != null)
        {
            this.BuffItemProp = buffProp;
            constitution     += buffProp.Constitution;
            strength         += buffProp.Strength;
            dexterous        += buffProp.Dexterous;
            agility          += buffProp.Agility;
            concentration    += buffProp.Concentration;

            //else ...
        }
        #endregion

        this.ID            = id;
        this.Name          = name;
        this.Faction       = faction;
        this.Type          = type;
        this.Sprite        = sprite;
        this.AllExperience = allExperience;
        this.Resistance    = resistance;
        this.Constitution  = constitution;
        this.Strength      = strength;
        this.Agility       = agility;
        this.Dexterous     = dexterous;
        this.Concentration = concentration;
        this.HealthLevel   = 100;
        this.charKind      = kind;

        this.Level             = CountLevel(allExperience, out currentExperience);
        this.CurrentExperience = currentExperience;
        this.Power             = constitution + strength + agility + dexterous + concentration;

        this.WeaponWith = weapon;

        //通常角色
        if (type == CharacterType.Common)
        {
            this.MaxHealth       = 100 + 3 * constitution;
            this.MaxStamina      = 100 + 1 * constitution;
            this.HealthRecovery  = 0.2f;
            this.StaminaRecovery = 5f;
            this.MoveSpeed       = 1.3f * (1 + 0.01f * agility);
            this.AimingSpeed     = 2 * (1 + 0.02f * concentration);
            this.Critical        = 0.1f + 0.01f * dexterous;
            this.MeleeRaise      = 1.5f;
            this.ShootRaise      = 1.5f;
            this.ThrowRaise      = 1.5f;
            this.MaxAngle        = 10 * (1 - 0.01f * concentration);
            this.KickDamage      = 20 + strength;
            this.PunchDamage     = 20 + strength;

            if (weapon is MeleeWeapon)
            {
                MeleeWeapon melee = (MeleeWeapon)weapon;
                this.MeleeDamage    = melee.MeleeDamage + strength;
                this.ThrowDamage    = melee.ThrowDamage + strength;
                this.AttackInterval = melee.AttackInterval * (1 - 0.02f * agility);
            }
            else if (weapon is ShootWeapon)
            {
                ShootWeapon shoot = (ShootWeapon)weapon;
                this.MinAngle       = (110 - shoot.Accuracy / 15);
                this.Capacity       = shoot.Accuracy * MaxAngle / 10;
                this.PullingTime    = shoot.LaShuanTime * (1 - 0.02f * agility);
                this.ReloadTime     = shoot.ReloadTime * (1 - 0.01f * agility);
                this.MeleeDamage    = shoot.MeleeDamage + strength;
                this.ShootDamage    = shoot.ShootDamage;
                this.AttackInterval = shoot.AttackInterval * (1 - 0.01f * agility);
                this.DeclineRange   = shoot.DamageRange;
            }
        }
        //英雄角色
        else if (type == CharacterType.Hero)
        {
            this.SkillA = skills[0];
            this.SkillB = skills[1];
            this.SkillC = skills[2];
            this.SkillD = skills[3];
            this.SkillE = skills[4];
            this.SkillF = skills[5];
            this.SkillG = skills[6];
            this.SkillH = skills[7];
            this.SkillI = skills[8];
            this.SkillJ = skills[9];
            this.SkillK = skills[10];
            this.SkillL = skills[11];
            this.SkillM = skills[12];
            this.SkillN = skills[13];
            this.SkillO = skills[14];
            this.SkillP = skills[15];
            this.SkillQ = skills[16];
            this.SkillR = skills[17];
            this.SkillS = skills[18];
            this.SkillT = skills[19];

            this.MaxHealth       = 100 + 3 * constitution + 20 * SkillA;
            this.MaxStamina      = 100 + 1 * constitution + 20 * SkillF;
            this.HealthRecovery  = 0.2f + 2 * SkillM + 100 * SkillN;
            this.StaminaRecovery = 5 + 2 * SkillL;
            this.MoveSpeed       = 1.3f * (1 + 0.01f * agility + 0.15f * SkillR);
            this.AimingSpeed     = 2f * (1 + 0.02f * concentration + 0.1f * SkillQ);
            this.Critical        = 0.1f + 0.01f * dexterous + 0.04f * SkillD;
            this.MeleeRaise      = 1.5f + 0.5f * SkillI;
            this.ShootRaise      = 1.5f + 0.5f * SkillJ;
            this.ThrowRaise      = 1.5f + 1 * SkillT;
            this.MaxAngle        = 10 * (1 - 0.01f * concentration - 0.04f * SkillE);
            this.Resistance      = this.Resistance + 0.04f * SkillG + 0.1f * SkillN;
            this.KickDamage      = 20 + 20 * SkillH;

            if (weapon is MeleeWeapon)
            {
                MeleeWeapon melee = (MeleeWeapon)weapon;
                this.MeleeDamage    = (melee.MeleeDamage + strength) * (1 + 0.04f * SkillB);
                this.AttackInterval = melee.AttackInterval * (1 - 0.02f * agility - 0.04f * SkillC);
                this.ThrowDamage    = melee.ThrowDamage * (1 + SkillT) + strength;
            }
            else if (weapon is ShootWeapon)
            {
                ShootWeapon shoot = (ShootWeapon)weapon;
                this.MinAngle       = (110 - shoot.Accuracy / 15) * (1 - 0.1f * SkillP);
                this.Capacity       = shoot.Accuracy * MaxAngle / 10f;
                this.ReloadTime     = shoot.ReloadTime * (1 - 0.01f * agility - 0.1f * SkillO);
                this.PullingTime    = shoot.LaShuanTime * (1 - 0.02f * agility - 0.08f * SkillK);
                this.MeleeDamage    = (shoot.MeleeDamage * (1 + SkillT) + strength) * (1 + 0.04f * SkillB);
                this.ShootDamage    = shoot.ShootDamage;
                this.AttackInterval = shoot.AttackInterval * (1 - 0.01f * agility - 0.04f * SkillC);
            }
        }
    }
Пример #7
0
        public async Task <Character> GetCharacterAsync(IAuthenticationScope authenticationScope, CharacterKind characterKind)
        {
            var mapper      = new CharacterMapper();
            var artisanSlug = EnumConversionHelper.CharacterIdentifierToString(characterKind);

            using (var client = CreateClient(authenticationScope))
            {
                var characterClass = await client.GetCharacterClassAsync(artisanSlug);

                /* GetApiSkill only extends active skills with runes, all the other properties are already retrieved via GetCharacterClass */
                var activeApiSkills = new List <CharacterApiSkillDto>();
                foreach (var skill in characterClass.Skills.Actives)
                {
                    var apiSkill = await client.GetApiSkillAsync(artisanSlug, skill.Slug);

                    activeApiSkills.Add(apiSkill);
                }

                mapper.Actives = activeApiSkills;
                return(mapper.Map(characterClass));
            }
        }