void Update() { CharacterResource health = characterSheet.GetResource(CharacterResources.Health); CharacterResource mana = characterSheet.GetResource(CharacterResources.Mana); healthSlider.maxValue = health.MaxAmmount; manaSlider.maxValue = mana.MaxAmmount; healthSlider.value = health.CurrentAmmount; manaSlider.value = mana.CurrentAmmount; }
public void Init(CharacterSheet characterSheet) { this.characterSheet = characterSheet; CharacterResource health = characterSheet.GetResource(CharacterResources.Health); CharacterResource mana = characterSheet.GetResource(CharacterResources.Mana); Debug.LogFormat("[HUDInLevel.Init] Initalizing HUD, maxHealh: {0}, maxMana: {1}, health: {2}, mana: {3} ", health.MaxAmmount, mana.MaxAmmount, health.CurrentAmmount, mana.CurrentAmmount); healthSlider.maxValue = health.MaxAmmount; manaSlider.maxValue = mana.MaxAmmount; healthSlider.value = health.CurrentAmmount; manaSlider.value = mana.CurrentAmmount; }
public bool CanReceiveDamage() { bool result = true; // can't receive damage if dead CharacterResource health = characterSheet.GetResource(CharacterResources.Health); if (health.CurrentAmmount <= 0) { result &= false; } return(result); }
public void SpendResource(CharacterResources resourceKey, long resourceToSpend) { if (resourceToSpend < 0) { return; } CharacterResource resource = GetResource(resourceKey); resource.CurrentAmmount -= resourceToSpend; if (resource.CurrentAmmount < 0) { resource.CurrentAmmount = 0; } Debug.LogFormat("[CharacterResources.SpendResource] Spend resource {0}, ammount to spend: {1}, new current ammount: {2}", resourceKey, resourceToSpend, resource.CurrentAmmount); }
// Use this for initialization public override void Start() { base.Start(); navMeshAgent = gameObject.GetComponent <NavMeshAgent>(); player = GameObject.FindGameObjectWithTag("Player"); // create enemy stats CharacterStat power = new CharacterStat(CharacterStats.Power, 10); characterSheet.AddStat(CharacterStats.Strength, power); // create enemy resources CharacterResource health = new CharacterResource(CharacterResources.Health, 20, 20); characterSheet.AddResource(CharacterResources.Health, health); EnemyManager.Instance.AddEnemy(this); }
public void ReceiveResource(CharacterResources resourceKey, long resourceToReceive) { if (resourceToReceive < 0) { return; } CharacterResource resource = GetResource(resourceKey); Debug.LogFormat("[CharacterResources.ReceiveMana] Get resource {0} ", resourceToReceive); resource.CurrentAmmount += resourceToReceive; if (resource.CurrentAmmount > resource.MaxAmmount) { resource.CurrentAmmount = resource.MaxAmmount; } Debug.LogFormat("[CharacterResources.ReceiveResource] Recieving resource {0}, ammount: {0}, new current ammount: {2}", resourceKey, resourceToReceive, resource.CurrentAmmount); }
// ----------------------- Unity Overriden Methods ------------------------- // Use this for initialization public override void Start() { base.Start(); // create player abilities MeleeAbility cleave = new CleaveAbility(this, "Cleave"); abilityController.AddAbility("Primary", cleave); RangedAbility magicMissile = new MagicMissileAbility(this, "Magic Missile"); abilityController.AddAbility("Secondary", magicMissile); AreaAbility avalanche = new AreaAbility(this, "Avalanche"); abilityController.AddAbility("Ability01", avalanche); SelfCastAbility battleShout = new SelfCastAbility(this, "Battle Shout"); abilityController.AddAbility("Ability02", battleShout); // create player stats CharacterStat strength = new CharacterStat(CharacterStats.Strength, 12); CharacterStat agility = new CharacterStat(CharacterStats.Agility, 15); CharacterStat inteligence = new CharacterStat(CharacterStats.Inteligence, 18); CharacterStat vitality = new CharacterStat(CharacterStats.Vitality, 10); characterSheet.AddStat(CharacterStats.Strength, strength); characterSheet.AddStat(CharacterStats.Agility, agility); characterSheet.AddStat(CharacterStats.Inteligence, inteligence); characterSheet.AddStat(CharacterStats.Vitality, vitality); // create player resources CharacterResource health = new CharacterResource(CharacterResources.Health, 50, 100); CharacterResource mana = new CharacterResource(CharacterResources.Mana, 50, 100); characterSheet.AddResource(CharacterResources.Health, health); characterSheet.AddResource(CharacterResources.Mana, mana); HUDInLevel.Instance.Init(characterSheet); }
public void AddResource(CharacterResources resourceKey, CharacterResource resource) { resources.Add(resourceKey, resource); }