Exemplo n.º 1
0
        //Calculates damage for base weapon (which has no additional abilities like poison, magic etc.)
        public static int CalculateBaseDamage(WeaponStats weaponStats, CharacterStats charStats, float multiplier = 1)
        {
            //Extract the resistance from weapon's standalone damage
            float physical = (weaponStats.attackPhysical * multiplier) - charStats.physical;
            float strike   = (weaponStats.attackStrike * multiplier) - charStats.vs_strike;
            float slash    = (weaponStats.attackSlash * multiplier) - charStats.vs_slash;
            float thrust   = (weaponStats.attackThrust * multiplier) - charStats.vs_thrust;

            //Total base damage
            float totalDamage = physical + strike + slash + thrust;

            float magic    = (weaponStats.attackMagic * multiplier) - charStats.magic;
            float fire     = (weaponStats.attackFire * multiplier) - charStats.fire;
            float lighting = (weaponStats.attackLigthning * multiplier) - charStats.lightning;
            float dark     = (weaponStats.attackDark * multiplier) - charStats.dark;

            //Add the extra attributes of weapon
            totalDamage += magic + fire + lighting + dark;

            if (totalDamage <= 0)
            {
                totalDamage = 1;
            }

            return(Mathf.RoundToInt(totalDamage));
        }
        public RuntimeWeapon WeaponToRuntimeWeapon(Weapon weapon, bool isLeftHand = false)
        {
            //Debug.Log("Converting to runtime weapon: " + weapon.item_id);
            GameObject go = new GameObject();

            go.transform.parent = referencesParent.transform;
            RuntimeWeapon inst = go.AddComponent <RuntimeWeapon>();

            go.name = weapon.item_id;

            inst.Instance = new Weapon();
            StaticFunctions.DeepCopyWeapon(weapon, inst.Instance);

            inst.weaponStats = new WeaponStats();
            WeaponStats weaponStats = ResourcesManager.Instance.GetWeaponStats(weapon.item_id);

            if (weaponStats == null)
            {
                Debug.Log("Couldn't find weaponStats");
            }
            StaticFunctions.DeepCopyWeaponStats(weaponStats, inst.weaponStats);

            //Create weapon 3D model to scene
            inst.weaponModel = Instantiate(weapon.weaponModelPrefab) as GameObject;

            //If the weapon is used by left hand, assign left hand as weapon's parents and vice versa
            Transform parent = states.animator.GetBoneTransform((isLeftHand) ? HumanBodyBones.LeftHand : HumanBodyBones.RightHand);

            inst.weaponModel.transform.parent = parent;

            //Reset the transform properties of the weapon
            inst.weaponModel.transform.localPosition =
                (isLeftHand) ?
                inst.Instance.left_model_pos : inst.Instance.right_model_pos;

            inst.weaponModel.transform.localEulerAngles =
                (isLeftHand) ?
                inst.Instance.left_model_eulerRot : inst.Instance.right_model_eulerRot;

            inst.weaponModel.transform.localScale = (isLeftHand) ?
                                                    inst.Instance.left_model_scale : inst.Instance.right_model_scale;;

            inst.weaponHook = inst.weaponModel.GetComponentInChildren <WeaponHook>();
            if (inst.weaponHook == null)
            {
                Debug.Log("Missing component 'WeaponHook' on weapon: " + weapon.item_id);
            }

            inst.weaponHook.InitDamageColliders(states);

            inst.weaponModel.SetActive(false);

            return(inst);
        }
Exemplo n.º 3
0
        void LoadWeaponItem(ResourcesManager resManager, IconBase icon)
        {
            ItemInventoryInstance invInstance = session.GetWeaponItem(icon.id);
            string      weaponID    = invInstance.itemId;
            WeaponStats weaponStats = resManager.GetWeaponStats(weaponID);
            Item        item        = resManager.GetItem(weaponID, Itemtype.Weapon);

            equipment_Left.currentItem.text = item.name_item;

            //Update Center Overlay UI Panel
            UpdateCenterOverlay(item);
            center_Overlay.skillName.text = weaponStats.skillName;

            //Center Main UI
            weaponInfo.smallIcon.sprite = item.itemIcon;
            weaponInfo.itemName.text    = item.name_item;
            weaponInfo.weaponType.text  = weaponStats.weaponType;
            weaponInfo.damageType.text  = weaponStats.damageType;
            weaponInfo.skillName.text   = weaponStats.skillName;
            weaponInfo.weightCost.text  = weaponStats.weightCost.ToString();

            //Update the min durability!!!
            weaponInfo.durability_Min.text = weaponInfo.durability_Max.ToString();
            weaponInfo.durability_Max.text = weaponInfo.durability_Max.ToString();

            //Attack Power
            UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Physical, weaponStats.attackPhysical.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Magic, weaponStats.attackMagic.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Fire, weaponStats.attackFire.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Lightning, weaponStats.attackLigthning.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Dark, weaponStats.attackDark.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Critical, weaponStats.attackCritical.ToString());

            UpdateAttackDefenseUIElement(weaponInfo.additionalEffects, AttackDefenseType.Frost, weaponStats.attackFrost.ToString(), true);
            UpdateAttackDefenseUIElement(weaponInfo.additionalEffects, AttackDefenseType.Curse, weaponStats.attackCurse.ToString(), true);
            //UpdateAttackDefenseUIElement(weaponInfo.additionalEffects, AttackDefenseType.Poison, weaponStats.poisonDamage.ToString());
            //UpdateAttackDefenseUIElement(weaponInfo.additionalEffects, AttackDefenseType.Bleed, weaponStats.frostDamage.ToString(), true);

            //Guard Absorptions
            UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Physical, weaponStats.defensePhysical.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Magic, weaponStats.defenseMagic.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Fire, weaponStats.defenseFire.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Lightning, weaponStats.defenseLigthning.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Dark, weaponStats.defenseDark.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Dark, weaponStats.defenseDark.ToString());
            UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Stability, weaponStats.defenseStability.ToString());
        }
Exemplo n.º 4
0
        public static void DeepCopyWeaponStats(WeaponStats weaponStats_From, WeaponStats weaponStats_To)
        {
            if (weaponStats_From == null)
            {
                Debug.Log(weaponStats_From.weaponID + " weren't found! Assigning all stats as zero (0).");
                return;
            }

            weaponStats_To.weaponID       = weaponStats_From.weaponID;
            weaponStats_To.attackPhysical = weaponStats_From.attackPhysical;
            weaponStats_To.attackStrike   = weaponStats_From.attackStrike;
            weaponStats_To.attackThrust   = weaponStats_From.attackThrust;
            weaponStats_To.attackSlash    = weaponStats_From.attackSlash;

            weaponStats_To.attackMagic     = weaponStats_From.attackMagic;
            weaponStats_To.attackLigthning = weaponStats_From.attackLigthning;
            weaponStats_To.attackFire      = weaponStats_From.attackFire;
            weaponStats_To.attackDark      = weaponStats_From.attackDark;
        }