Fix attack & defense & health calculation
This commit is contained in:
parent
7db7398c75
commit
84fe5a450f
@ -130,7 +130,7 @@ public class FollowingEnemy : Enemy
|
||||
{
|
||||
if(timerHit >= hitWaitTime)
|
||||
{
|
||||
TakeDamage(1.0f);
|
||||
TakeDamage(PlayerPrefs.GetFloat("attackValue"));
|
||||
hit = false;
|
||||
timerHit = 0f;
|
||||
TakeKnockback();
|
||||
|
@ -104,7 +104,7 @@ public class FollowingPatrollingEnemy : Enemy
|
||||
{
|
||||
if (timerHit >= hitWaitTime)
|
||||
{
|
||||
TakeDamage(1.0f);
|
||||
TakeDamage(PlayerPrefs.GetFloat("attackValue"));
|
||||
hit = false;
|
||||
timerHit = 0f;
|
||||
TakeKnockback();
|
||||
|
@ -35,21 +35,32 @@ public class Player : MonoBehaviour
|
||||
|
||||
private bool canWalk = true;
|
||||
|
||||
public float currentHealth;
|
||||
public float maxHealth;
|
||||
[Header("Player Starts values")]
|
||||
public const int BaseHealth = 10;
|
||||
public const float BaseSpeed = 4f;
|
||||
|
||||
|
||||
[Header("Player Skills Points")]
|
||||
public int healthPoints;
|
||||
public int defensePoints;
|
||||
public int strengthPoints;
|
||||
public int intelligencePoints;
|
||||
|
||||
[Header("Player current values")]
|
||||
public float attackValue;
|
||||
public float defenseValue;
|
||||
public float currentSpeed; // as WalkSpeed
|
||||
|
||||
public float currentHealth;
|
||||
public float maxHealth;
|
||||
|
||||
public float exp;
|
||||
public int lvl;
|
||||
public float maxExp;
|
||||
public LevelBar levelBar;
|
||||
public FloatValue minPlayerExp;
|
||||
|
||||
public float attackValue;
|
||||
|
||||
|
||||
public static void putPlayerInCollider()
|
||||
{
|
||||
@ -84,7 +95,11 @@ public class Player : MonoBehaviour
|
||||
//healthBar.SetHealth(currentHealth);
|
||||
//levelBar.SetStartExp(minPlayerExp.initialValue);
|
||||
//levelBar.SetExp(exp);
|
||||
walkSpeed = 4f;
|
||||
|
||||
ManageSpeed();
|
||||
walkSpeed = PlayerPrefs.GetFloat("speed");
|
||||
|
||||
|
||||
ManageLevels(exp);
|
||||
}
|
||||
|
||||
@ -144,18 +159,12 @@ public class Player : MonoBehaviour
|
||||
{
|
||||
|
||||
defensePoints = PlayerPrefs.GetInt(SkillsPointsManger.PLAYER_SKILS_DEFENSE_POINTS);
|
||||
if(defensePoints == 1)
|
||||
{
|
||||
damage = damage * 0.95f;
|
||||
}
|
||||
else if(defensePoints == 2)
|
||||
{
|
||||
damage = damage * 0.9f;
|
||||
}
|
||||
else if(defensePoints == 3)
|
||||
{
|
||||
damage = damage * 0.85f;
|
||||
}
|
||||
|
||||
Debug.Log($"Minion Damage: {damage}; \nDefense: {PlayerPrefs.GetFloat("defenseValue")}");
|
||||
|
||||
damage = damage - PlayerPrefs.GetFloat("defenseValue");
|
||||
|
||||
Debug.Log($"RealDamage: {damage}");
|
||||
|
||||
currentHealth = PlayerPrefs.GetFloat("health");
|
||||
currentHealth = currentHealth - damage;
|
||||
@ -189,21 +198,30 @@ public class Player : MonoBehaviour
|
||||
|
||||
if (canWalk == true)
|
||||
{
|
||||
if (EquipmentUIManager.Instance.GetList().Count() == 0 || EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).Count() == 0)
|
||||
return;
|
||||
/* if (EquipmentUIManager.Instance.GetList().Count() == 0 || EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).Count() == 0)
|
||||
return;*/
|
||||
|
||||
if (EquipmentUIManager.Instance.GetList().Count() != 0 && EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).First().Value.Name.Equals("Pickaxe") && attackSword)
|
||||
if (attackFist)
|
||||
{
|
||||
myAnimator.SetTrigger("attackFist");
|
||||
} else if (attackSword &&
|
||||
EquipmentUIManager.Instance.GetList().Count() != 0 &&
|
||||
EquipmentUIManager.Instance.GetList()
|
||||
.Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).Count() > 0 &&
|
||||
EquipmentUIManager.Instance.GetList()
|
||||
.Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).First().Value.Name.Equals("Pickaxe"))
|
||||
{
|
||||
myAnimator.SetTrigger("pickaxe");
|
||||
}
|
||||
else if (attackSword && EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).First().Value.EquipmentType == EquipmentTypeEnum.Weapon)
|
||||
else if (attackSword &&
|
||||
EquipmentUIManager.Instance.GetList().Count() != 0 &&
|
||||
EquipmentUIManager.Instance.GetList()
|
||||
.Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).Count() > 0 &&
|
||||
EquipmentUIManager.Instance.GetList()
|
||||
.Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).First().Value.EquipmentType == EquipmentTypeEnum.Weapon)
|
||||
{
|
||||
myAnimator.SetTrigger("attack");
|
||||
}
|
||||
else if (attackFist)
|
||||
{
|
||||
myAnimator.SetTrigger("attackFist");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -245,6 +263,7 @@ public class Player : MonoBehaviour
|
||||
ManageDefense();
|
||||
ManageIntelligence();
|
||||
ManageStrength();
|
||||
ManageSpeed();
|
||||
|
||||
if (canWalk == true)
|
||||
{
|
||||
@ -252,8 +271,12 @@ public class Player : MonoBehaviour
|
||||
inputHorizontal = Input.GetAxisRaw("Horizontal");
|
||||
inputVertical = Input.GetAxisRaw("Vertical");
|
||||
|
||||
// speed calculated in ManageSpeed function
|
||||
walkSpeed = PlayerPrefs.GetFloat("speed");
|
||||
|
||||
myAnimator.SetFloat("moveX", inputHorizontal * walkSpeed);
|
||||
myAnimator.SetFloat("moveY", inputVertical * walkSpeed);
|
||||
|
||||
if (inputHorizontal != 0)
|
||||
{
|
||||
myAnimator.SetFloat("speed", walkSpeed);
|
||||
@ -341,23 +364,18 @@ public class Player : MonoBehaviour
|
||||
|
||||
public void ManageHealth()
|
||||
{
|
||||
//nie wiem czy to potrzebne ale zostawiam tak
|
||||
healthPoints = PlayerPrefs.GetInt(SkillsPointsManger.PLAYER_SKILS_HEALTH_POINTS);
|
||||
if (healthPoints == 0)
|
||||
{
|
||||
PlayerPrefs.SetFloat("maxHealth", 10);
|
||||
}
|
||||
else if (healthPoints == 1)
|
||||
{
|
||||
PlayerPrefs.SetFloat("maxHealth", 12);
|
||||
}
|
||||
else if (healthPoints == 2)
|
||||
{
|
||||
PlayerPrefs.SetFloat("maxHealth", 14);
|
||||
}
|
||||
else if (healthPoints == 3)
|
||||
{
|
||||
PlayerPrefs.SetFloat("maxHealth", 16);
|
||||
}
|
||||
|
||||
|
||||
// nowe - analogicznie jak w ataku
|
||||
var healthCalculltor = new HealthCalcullator();
|
||||
|
||||
var health = BaseHealth + healthCalculltor.CalculateWithoutItem();
|
||||
|
||||
PlayerPrefs.SetFloat("maxHealth", health);
|
||||
|
||||
Debug.Log("Health: " + PlayerPrefs.GetFloat("maxHealth"));
|
||||
}
|
||||
|
||||
public void AddHealthPoint()
|
||||
@ -374,42 +392,29 @@ public class Player : MonoBehaviour
|
||||
{
|
||||
if (EquipmentUIManager.Instance.GetList().Count() == 0 || EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).Count() == 0)
|
||||
{
|
||||
attackValue = 0f;
|
||||
}
|
||||
else if (EquipmentUIManager.Instance.GetList().Count() != 0 &&
|
||||
EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).Count() > 0 &&
|
||||
EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).First().Value.Name.Equals("Pickaxe"))
|
||||
{
|
||||
attackValue = 0.5f;
|
||||
var attackCalculator = new AttackCalcullator();
|
||||
|
||||
attackValue = attackCalculator.CalculateWithoutItem();
|
||||
|
||||
PlayerPrefs.SetFloat("attackValue", attackValue);
|
||||
}
|
||||
else if (EquipmentUIManager.Instance.GetList().Count() != 0 &&
|
||||
EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).Count() > 0 &&
|
||||
EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).First().Value.Name.Equals("Basic Sword"))
|
||||
EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).First().Value.EquipmentType == EquipmentTypeEnum.Weapon)
|
||||
{
|
||||
attackValue = 1.0f;
|
||||
var equippedItem = EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.WeaponSlot && el.Value != null).First().Value;
|
||||
|
||||
var attackCalculator = new AttackCalcullator();
|
||||
|
||||
attackValue = attackCalculator.Calculate(equippedItem.Value);
|
||||
|
||||
PlayerPrefs.SetFloat("attackValue", attackValue);
|
||||
} else
|
||||
{
|
||||
throw new System.Exception("Attack Calculation Error");
|
||||
}
|
||||
|
||||
strengthPoints = PlayerPrefs.GetInt(SkillsPointsManger.PLAYER_SKILS_STRENGHT_POINTS);
|
||||
if(strengthPoints == 1)
|
||||
{
|
||||
attackValue = PlayerPrefs.GetFloat("attackValue");
|
||||
attackValue = attackValue * 1.1f;
|
||||
PlayerPrefs.SetFloat("attackValue", attackValue);
|
||||
}
|
||||
else if(strengthPoints == 2)
|
||||
{
|
||||
attackValue = PlayerPrefs.GetFloat("attackValue");
|
||||
attackValue = attackValue * 1.2f;
|
||||
PlayerPrefs.SetFloat("attackValue", attackValue);
|
||||
}
|
||||
else if(strengthPoints == 3)
|
||||
{
|
||||
attackValue = PlayerPrefs.GetFloat("attackValue");
|
||||
attackValue = attackValue * 1.3f;
|
||||
PlayerPrefs.SetFloat("attackValue", attackValue);
|
||||
}
|
||||
Debug.Log("Attack: " + PlayerPrefs.GetFloat("attackValue"));
|
||||
}
|
||||
|
||||
public void AddStrengthPoint()
|
||||
@ -424,7 +429,51 @@ public class Player : MonoBehaviour
|
||||
|
||||
public void ManageDefense()
|
||||
{
|
||||
//nie wiem czy to potrzebne ale zostawiam tak
|
||||
defensePoints = PlayerPrefs.GetInt(SkillsPointsManger.PLAYER_SKILS_DEFENSE_POINTS);
|
||||
|
||||
// nowe - analogicznie jak w ataku
|
||||
var defenseCalculator = new DefenseCalculattor();
|
||||
|
||||
if (EquipmentUIManager.Instance.GetList().Count() == 0 ||
|
||||
EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.HelmetSlot && el.Value != null).Count() == 0 &&
|
||||
EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.ArmorSlot && el.Value != null).Count() == 0
|
||||
){
|
||||
|
||||
defenseValue = defenseCalculator.CalculateWithoutItem();
|
||||
|
||||
PlayerPrefs.SetFloat("defenseValue", defenseValue);
|
||||
}
|
||||
else if (EquipmentUIManager.Instance.GetList().Count() != 0 &&
|
||||
|
||||
(EquipmentUIManager.Instance.GetList()
|
||||
.Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.HelmetSlot && el.Value != null).Count() > 0 &&
|
||||
EquipmentUIManager.Instance.GetList()
|
||||
.Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.HelmetSlot && el.Value != null).First().Value.EquipmentType == EquipmentTypeEnum.Helmet) ||
|
||||
|
||||
(EquipmentUIManager.Instance.GetList()
|
||||
.Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.ArmorSlot && el.Value != null).Count() > 0 &&
|
||||
EquipmentUIManager.Instance.GetList()
|
||||
.Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.ArmorSlot && el.Value != null).First().Value.EquipmentType == EquipmentTypeEnum.Chest)
|
||||
) {
|
||||
var helmetSlot = EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.HelmetSlot && el.Value != null);
|
||||
var helmet = (helmetSlot.Count() != 0) ? helmetSlot.First().Value.Value : 0;
|
||||
|
||||
|
||||
var chestplateSlot = EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.ArmorSlot && el.Value != null);
|
||||
var chestplate = (chestplateSlot.Count() != 0) ? chestplateSlot.First().Value.Value : 0;
|
||||
|
||||
|
||||
defenseValue = defenseCalculator.Calculate(helmet + chestplate);
|
||||
|
||||
PlayerPrefs.SetFloat("defenseValue", defenseValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("Defense Calculation Error");
|
||||
}
|
||||
|
||||
Debug.Log("Defense: " + PlayerPrefs.GetFloat("defenseValue"));
|
||||
}
|
||||
|
||||
public void AddDefensePoint()
|
||||
@ -457,5 +506,31 @@ public class Player : MonoBehaviour
|
||||
healthPoints = PlayerPrefs.GetInt(SkillsPointsManger.PLAYER_SKILS_HEALTH_POINTS);
|
||||
}
|
||||
|
||||
public void ManageSpeed()
|
||||
{
|
||||
var speed = 0f;
|
||||
var speedCalculator = new SpeedCalcullator();
|
||||
|
||||
if (EquipmentUIManager.Instance.GetList().Count() == 0 || EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.BootsSlot && el.Value != null).Count() == 0)
|
||||
{
|
||||
speed = BaseSpeed + speedCalculator.CalculateWithoutItem();
|
||||
|
||||
}
|
||||
else if (EquipmentUIManager.Instance.GetList().Count() != 0 &&
|
||||
EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.BootsSlot && el.Value != null).Count() > 0 &&
|
||||
EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.BootsSlot && el.Value != null).First().Value.EquipmentType == EquipmentTypeEnum.Boots)
|
||||
{
|
||||
var boots = EquipmentUIManager.Instance.GetList().Where(el => el.Key == (int)EquipmentPanelSlotsTypeEnum.BootsSlot && el.Value != null).First().Value;
|
||||
|
||||
speed = BaseSpeed + speedCalculator.Calculate(boots.Value);
|
||||
}
|
||||
|
||||
|
||||
PlayerPrefs.SetFloat("speed", speed);
|
||||
|
||||
Debug.Log("Speed: " + PlayerPrefs.GetFloat("speed"));
|
||||
}
|
||||
|
||||
// nowe - analogicznie jak w ataku
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 041cc90253aadb149a2252682aa0ee1a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
class AttackCalcullator : PlayerPramCalcullator
|
||||
{
|
||||
protected override List<EquipmentTypeEnum> EQUIPMENT_TYPE => new List<EquipmentTypeEnum>(){EquipmentTypeEnum.Weapon, EquipmentTypeEnum.Ring, EquipmentTypeEnum.Necklet, EquipmentTypeEnum.Boots};
|
||||
|
||||
protected override ItemBonusEnum BONUS_TYPE => ItemBonusEnum.Strenght;
|
||||
|
||||
|
||||
protected override float Pattern(int itemValue, int SkillPoints, int BonusSum)
|
||||
{
|
||||
return (1 + (2*SkillPoints + BonusSum) / 10f) + itemValue;
|
||||
}
|
||||
|
||||
protected override float WithoutItemPattern(int SkillPoints, int BonusSum)
|
||||
{
|
||||
return (0.7f + (SkillPoints + BonusSum) / 8f);
|
||||
}
|
||||
|
||||
public override int GetSkillPoints()
|
||||
{
|
||||
return PlayerPrefs.HasKey(SkillsPointsManger.PLAYER_SKILS_STRENGHT_POINTS)
|
||||
? PlayerPrefs.GetInt(SkillsPointsManger.PLAYER_SKILS_STRENGHT_POINTS)
|
||||
: 0
|
||||
;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0ff018e0aace844e8bfaae26443489d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
class DefenseCalculattor : PlayerPramCalcullator
|
||||
{
|
||||
protected override List<EquipmentTypeEnum> EQUIPMENT_TYPE => new List<EquipmentTypeEnum>() { EquipmentTypeEnum.Helmet, EquipmentTypeEnum.Chest, EquipmentTypeEnum.Ring, EquipmentTypeEnum.Necklet, EquipmentTypeEnum.Boots };
|
||||
|
||||
protected override ItemBonusEnum BONUS_TYPE => ItemBonusEnum.Enduration;
|
||||
|
||||
|
||||
public override int GetSkillPoints()
|
||||
{
|
||||
return PlayerPrefs.HasKey(SkillsPointsManger.PLAYER_SKILS_DEFENSE_POINTS)
|
||||
? PlayerPrefs.GetInt(SkillsPointsManger.PLAYER_SKILS_DEFENSE_POINTS)
|
||||
: 0
|
||||
;
|
||||
}
|
||||
|
||||
protected override float Pattern(int itemValue, int SkillPoints, int BonusSum)
|
||||
{
|
||||
return (1 + (2*SkillPoints + BonusSum) / 10f) + itemValue;
|
||||
}
|
||||
|
||||
protected override float WithoutItemPattern(int SkillPoints, int BonusSum)
|
||||
{
|
||||
return (SkillPoints + BonusSum) / 6f;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d729aa51d142f641965f8b47e1e334a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
class HealthCalcullator : PlayerPramCalcullator
|
||||
{
|
||||
protected override List<EquipmentTypeEnum> EQUIPMENT_TYPE => new List<EquipmentTypeEnum>() {
|
||||
EquipmentTypeEnum.Weapon,
|
||||
EquipmentTypeEnum.Helmet,
|
||||
EquipmentTypeEnum.Chest,
|
||||
EquipmentTypeEnum.Ring,
|
||||
EquipmentTypeEnum.Necklet,
|
||||
EquipmentTypeEnum.Boots
|
||||
};
|
||||
|
||||
protected override ItemBonusEnum BONUS_TYPE => ItemBonusEnum.Vitality;
|
||||
|
||||
public override int GetSkillPoints()
|
||||
{
|
||||
return PlayerPrefs.HasKey(SkillsPointsManger.PLAYER_SKILS_HEALTH_POINTS)
|
||||
? PlayerPrefs.GetInt(SkillsPointsManger.PLAYER_SKILS_HEALTH_POINTS)
|
||||
: 0
|
||||
;
|
||||
}
|
||||
|
||||
protected override float Pattern(int baseValue, int SkillPoints, int BonusSum)
|
||||
{
|
||||
throw new NotImplementedException("HealthCalcullator - Pattern - Not implemented");
|
||||
return baseValue + WithoutItemPattern(SkillPoints, BonusSum);
|
||||
}
|
||||
|
||||
protected override float WithoutItemPattern(int SkillPoints, int BonusSum)
|
||||
{
|
||||
return 2 * SkillPoints + BonusSum;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d184b461015cf345826716a7a2fef77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// takie same jak w bonusach itemow
|
||||
public enum ItemBonusEnum
|
||||
{
|
||||
None,
|
||||
Strenght,
|
||||
Enduration,
|
||||
Vitality,
|
||||
Inteligence,
|
||||
Speed
|
||||
}
|
||||
|
||||
public abstract class PlayerPramCalcullator
|
||||
{
|
||||
protected virtual List<EquipmentTypeEnum> EQUIPMENT_TYPE => new List<EquipmentTypeEnum>();
|
||||
protected virtual ItemBonusEnum BONUS_TYPE => ItemBonusEnum.None;
|
||||
|
||||
|
||||
public virtual float Calculate(int itemValue)
|
||||
{
|
||||
var skillPoints = GetSkillPoints();
|
||||
|
||||
var bonusSum = CalculateBonusByType();
|
||||
|
||||
return Pattern(itemValue, skillPoints, bonusSum);
|
||||
}
|
||||
|
||||
public virtual float CalculateWithoutItem()
|
||||
{
|
||||
var skillPoints = GetSkillPoints();
|
||||
|
||||
var bonusSum = CalculateBonusByType();
|
||||
|
||||
return WithoutItemPattern(skillPoints, bonusSum);
|
||||
}
|
||||
|
||||
protected abstract float Pattern(int itemValue, int SkillPoints, int BonusSum);
|
||||
|
||||
protected abstract float WithoutItemPattern(int SkillPoints, int BonusSum);
|
||||
|
||||
public abstract int GetSkillPoints();
|
||||
|
||||
public int CalculateBonusByType()
|
||||
{
|
||||
var bonusSum = 0;
|
||||
|
||||
if (EquipmentUIManager.Instance.GetList().Count() == 0)
|
||||
return bonusSum;
|
||||
|
||||
// Every equipped item by player with mached type
|
||||
foreach(var equipmentType in EQUIPMENT_TYPE)
|
||||
{
|
||||
var machedEquippedItems = EquipmentUIManager
|
||||
.Instance
|
||||
.GetList()
|
||||
.Where(slot => (slot.Value != null && slot.Value.EquipmentType == equipmentType))
|
||||
.Select(slot => slot.Value)
|
||||
.ToList()
|
||||
;
|
||||
|
||||
foreach(var equippedItem in machedEquippedItems)
|
||||
{
|
||||
bonusSum += GetBonusFromItem(equippedItem, BONUS_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
return bonusSum;
|
||||
}
|
||||
|
||||
protected int GetBonusFromItem(EquippableItem item, ItemBonusEnum itemBonus)
|
||||
{
|
||||
switch(itemBonus)
|
||||
{
|
||||
case ItemBonusEnum.Strenght:
|
||||
{
|
||||
return item.StrengthBonus;
|
||||
}
|
||||
case ItemBonusEnum.Enduration:
|
||||
{
|
||||
return item.EnduranceBonus;
|
||||
}
|
||||
case ItemBonusEnum.Vitality:
|
||||
{
|
||||
return item.VitalityBonus;
|
||||
}
|
||||
case ItemBonusEnum.Inteligence:
|
||||
{
|
||||
return item.InteligenceBonus;
|
||||
}
|
||||
case ItemBonusEnum.Speed:
|
||||
{
|
||||
return item.SpeedBonus;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a40e38539ac24d45b160435e7641ad6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
class SpeedCalcullator : PlayerPramCalcullator
|
||||
{
|
||||
protected override List<EquipmentTypeEnum> EQUIPMENT_TYPE => new List<EquipmentTypeEnum>() {
|
||||
EquipmentTypeEnum.Weapon,
|
||||
EquipmentTypeEnum.Ring,
|
||||
EquipmentTypeEnum.Necklet,
|
||||
EquipmentTypeEnum.Boots
|
||||
};
|
||||
|
||||
protected override ItemBonusEnum BONUS_TYPE => ItemBonusEnum.Speed;
|
||||
|
||||
public override int GetSkillPoints()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected override float Pattern(int itemValue, int SkillPoints, int BonusSum)
|
||||
{
|
||||
return WithoutItemPattern(SkillPoints, BonusSum) + itemValue * 0.1f;
|
||||
}
|
||||
|
||||
protected override float WithoutItemPattern(int SkillPoints, int BonusSum)
|
||||
{
|
||||
return BonusSum * 0.05f;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aed30e6e0776bb140b87e4734498ace2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -96,8 +96,6 @@ class SkillsPointsManger : MonoBehaviour
|
||||
|
||||
if (SkillsUIManager.Instance.GetPanelStatus())
|
||||
{
|
||||
Debug.Log("UpdatePanelView");
|
||||
|
||||
//SkillsUIManager
|
||||
SkillsUIManager.Instance.DynamicPanel.GetComponent<SkillsPanelController>().RefreshPanelView(
|
||||
FreePoints,
|
||||
|
@ -6,10 +6,11 @@ using UnityEngine;
|
||||
[CreateAssetMenu(fileName = "New Item", menuName = "Inventory/EquippableItem")]
|
||||
public class EquippableItem : Item
|
||||
{
|
||||
public int StrengthBonus = 0;
|
||||
public int AgilityBonus = 0;
|
||||
public int StrengthBonus = 0; // attack
|
||||
public int EnduranceBonus = 0; // defence
|
||||
public int VitalityBonus = 0; // health
|
||||
public int InteligenceBonus = 0;
|
||||
public int VitalityBonus = 0;
|
||||
public int SpeedBonus = 0;
|
||||
|
||||
[Space]
|
||||
public bool isStackable = false;
|
||||
@ -24,11 +25,13 @@ public class EquippableItem : Item
|
||||
public EquippableItem(EquippableItem _item) : base(_item.name, _item.description, _item.level, _item.value, _item.price, _item.itemModel, _item.image)
|
||||
{
|
||||
StrengthBonus = _item.StrengthBonus;
|
||||
AgilityBonus = _item.AgilityBonus;
|
||||
InteligenceBonus = _item.InteligenceBonus;
|
||||
EnduranceBonus = _item.EnduranceBonus;
|
||||
VitalityBonus = _item.VitalityBonus;
|
||||
|
||||
InteligenceBonus = _item.InteligenceBonus;
|
||||
|
||||
EquipmentType = _item.EquipmentType;
|
||||
SpeedBonus = _item.SpeedBonus;
|
||||
}
|
||||
|
||||
public EquippableItem(string _name, string _description, int _level, int _value, int _price, GameObject _itemModel, Sprite _image) : base(_name, _description, _level, _value, _price, _itemModel, _image) { }
|
||||
|
@ -8,7 +8,7 @@ public class EquippableItemData : ItemData
|
||||
public int strengthBonus;
|
||||
|
||||
[SerializeField]
|
||||
public int agilityBonus;
|
||||
public int enduranceBonus;
|
||||
|
||||
[SerializeField]
|
||||
public int inteligenceBonus;
|
||||
@ -16,6 +16,9 @@ public class EquippableItemData : ItemData
|
||||
[SerializeField]
|
||||
public int vitalityBonus;
|
||||
|
||||
[SerializeField]
|
||||
public int speedBonus;
|
||||
|
||||
[SerializeField]
|
||||
public bool isStackable;
|
||||
|
||||
@ -25,9 +28,10 @@ public class EquippableItemData : ItemData
|
||||
public EquippableItemData(EquippableItem equippableItem) : base(equippableItem)
|
||||
{
|
||||
strengthBonus = equippableItem.StrengthBonus;
|
||||
agilityBonus = equippableItem.AgilityBonus;
|
||||
enduranceBonus = equippableItem.EnduranceBonus;
|
||||
inteligenceBonus = equippableItem.InteligenceBonus;
|
||||
vitalityBonus = equippableItem.VitalityBonus;
|
||||
speedBonus = equippableItem.SpeedBonus;
|
||||
|
||||
isStackable = equippableItem.isStackable;
|
||||
equipmentType = equippableItem.EquipmentType;
|
||||
@ -36,9 +40,10 @@ public class EquippableItemData : ItemData
|
||||
public EquippableItemData(Item item) : base(item)
|
||||
{
|
||||
strengthBonus = 0;
|
||||
agilityBonus = 0;
|
||||
enduranceBonus = 0;
|
||||
inteligenceBonus = 0;
|
||||
vitalityBonus = 0;
|
||||
speedBonus = 0;
|
||||
|
||||
isStackable = true;
|
||||
equipmentType = EquipmentTypeEnum.Other;
|
||||
|
@ -43,7 +43,7 @@ public abstract class ItemData : ModelData<Item, Item>
|
||||
///
|
||||
|
||||
// equippableItem.StrengthBonus = strengthBonus;
|
||||
// equippableItem.AgilityBonus = agilityBonus;
|
||||
// equippableItem.EnduranceBonus = enduranceBonus;
|
||||
// equippableItem.InteligenceBonus = inteligenceBonus;
|
||||
// equippableItem.VitalityBonus = vitalityBonus;
|
||||
// equippableItem.isStackable = isStackable;
|
||||
|
Loading…
Reference in New Issue
Block a user