private void Awake() { unitStats = GetComponent <CombatantStats>(); unitEquipment = GetComponent <Equipment>(); unitDB = GetComponent <BuildDB>(); unitSM = GetComponent <CombatantStateMachine>(); }
private void Awake() { unitStats = GetComponent <CombatantStats>(); unitMoveComponent = GetComponent <Move>(); unitDB = GetComponent <BuildDB>(); unitSM = GetComponent <CombatantStateMachine>(); }
void CalculateDamage(int raw, CombatantStats attacker, CombatantStats targetStats) { moving = true; // Method A - Inspired by Pokemon Go. //int finDmg = attacker.dmgBuff * Mathf.FloorToInt(0.5f * raw * (attacker.power / (targetStats.defense - targetStats.defDebuff))) + 1; // Minimum hit is 1. Defense CANNOT be 0! // Method B - Abby's idea int finDmg = raw - targetStats.defense - targetStats.defDebuff; finDmg = (finDmg < 0) ? 0 : finDmg; // Minimum hit is 0. // Animate battle attacking = attacker.gameObject.GetComponent <AnimatedBattle>().Attacking(); StartCoroutine(attacking); hurt = targetStats.gameObject.GetComponent <AnimatedBattle>().Hurt(); if (hurt != null) { StartCoroutine(hurt); } // Do damage Debug.Log(targetStats.gameObject.name + " is hit for " + finDmg); //*** targetStats.HP -= finDmg; // Subtract damage from target's HP. Debug.Log("HP is " + targetStats.HP); //*** if (targetStats.HP <= 0) { GameObject target = targetStats.gameObject; _wt.EndBattle(target); } }
public void Reset(CombatantStats stats) { this.combatantStats = stats; this.MovesLeft = stats.MovesPerTurn; this.AttacksLeft = stats.AttacksPerTurn; this.AITurnPlan = null; }
// Can be used for shield and armour too - reuse void Start() { // Set projectile spawn position projectileSpawnPosition = transform.Find("ProjectilePosition"); // Get combat stats from player combatantStats = GetComponent <Player>().combatantStats; }
void Start() { magicAttack = Resources.Load <MagicAttack>("Items/Weapons/Projectiles/MagicAttack"); //playerXform = playerGO.transform; //transform.LookAt(playerXform); // Create new loot table LootTable = new LootTable(); // Create new list of loot LootTable.lootDrops = new List <LootDrop> { // Populate loot list new LootDrop("sword", 1), }; for (int i = 0; i < listOfDrops.Length; i++) { LootTable.lootDrops.Add(new LootDrop(listOfDrops[i], chancesOfDrops[i])); } ID = enemyID; Experience = experienceForKilling; // Assign nav mesh agent navMeshAgent = GetComponent <NavMeshAgent>(); combatantStats = new CombatantStats(attackLevel, defenceLevel, attackSpeed); // Set health to full currentHealth = maxHealth; }
void ApplyDamage() { CombatantStats attackerStats = battleOrder.SourceCombatant.Stats; Combatant targetCombatant = battleOrder.TargetTile.GetOccupant(); if (targetCombatant == null || targetCombatant.Stats.HasStatus("dead")) { Debug.Log("targetCombatant " + targetCombatant + "!"); maxTimer = 0.0f; return; } Debug.Log("dmg text"); int damage = attackerStats.AttackPower; targetCombatant.Stats.CurrentHealth = targetCombatant.Stats.CurrentHealth - damage; targetCombatant.StartFlinchingAnimation(); GameObject objToSpawn = (GameObject)Instantiate(Resources.Load("DamageText")); objToSpawn.SetActive(true); objToSpawn.GetComponent <DamageNumber>().SetNumber(damage); objToSpawn.transform.position = targetCombatant.transform.position + new Vector3(0, 1, 0); objToSpawn.transform.rotation = Camera.main.transform.rotation; maxTimer = objToSpawn.GetComponent <DamageNumber>().duration; }
void BossAttacks(CombatantStats attacker) { chooseAttack = Random.Range(0, 1); // choose an attack if (chooseAttack == 0) { Debug.Log("Attack type: Smack"); dmg = 3; } }
public void RestoreHealth() { targetStats = target.GetComponent <CombatantStats>(); targetStats.HP += restore; if (targetStats.HP > targetStats.maxHP) { targetStats.HP = targetStats.maxHP; } }
private void Awake() { unitDB = GetComponent <BuildDB>(); unitLootActions = GetComponent <LootActions>(); unitMoveComponent = GetComponent <Move>(); unitStats = GetComponent <CombatantStats>(); unitStateMachine = GetComponent <CombatantStateMachine>(); unitCombat = GetComponent <Combat>(); unitObjectInfo = GetComponent <ObjectInfo>(); }
public IEnumerator EndPause(GameObject target) { battleEnded = false; yield return(new WaitForSeconds(1.5f)); // Clear animations from remaining combatants. foreach (GameObject combatant in order) { Animator animator = combatant.GetComponent <Animator>(); animator.SetBool("attacking", false); animator.SetBool("hurt", false); CombatantStats stats = combatant.GetComponent <CombatantStats>(); stats.dmgBuff = 1; stats.defDebuff = 0; } Destroy(GameObject.FindGameObjectWithTag("Move")); // Clear lists. order.Clear(); _attacks.allies.Clear(); _attacks.enemies.Clear(); _br.combatants.Clear(); battleEnded = true; // Reset readiness. _br.ready = true; battleStarted = false; Debug.Log("Battle ends."); // Kill the target. if (target != null) { if (target.tag == "Ally") { target.SetActive(false); // Don't destroy allies } else { Destroy(target); } Debug.Log(target.name + " defeated!"); } // Reload overworld. _pd = FindObjectOfType <PersistentData>().GetComponent <PersistentData>(); _pd.ReactivateEnemies(); _br.RestoreOverworld(); SceneManager.UnloadSceneAsync("ModeledBattleScene"); }
public void ChefAttacks(CombatantStats chef) { chefAttackMenu.SetActive(true); if (chefAttackChoice == 1 && moveSelected == false) { Debug.Log("Attack type: Punch"); dmg = 5; moveSelected = true; } if (chefAttackChoice == 2 && moveSelected == false) { Debug.Log("Attack type: Flaming Punch"); if (chef.magic >= 2) { dmg = 8; chef.magic -= 2; moveSelected = true; } else { Debug.Log("Not enough magic left!"); } } if (dmg != 0) { TargetSelection(); if (target != null) { Debug.Log("The target is " + target.name); //*** if (dmg < 8) { normalPunchSource.PlayOneShot(normalPunchClip); // The normal punch sound GameObject flyingPunch = Instantiate(punch, (chef.transform.position + moveOffset), Quaternion.identity); flyingPunch.GetComponent <Animator>().SetBool("impact", false); } else { flamePunchSource.PlayOneShot(flamePunchClip); // Flame Punch sound effect plays GameObject flame = Instantiate(fB, (chef.transform.position + moveOffset), Quaternion.identity); } CalculateDamage(dmg, chef, target.GetComponent <CombatantStats>()); chefAttackMenu.SetActive(false); ResetAttacks(); } } }
void ApplySpFX(string spfx, CombatantStats targetStats) { if (spfx == "2xD") { targetStats.dmgBuff = 2; Debug.Log("Target " + targetStats.name + "has 2* damage buff (" + targetStats.dmgBuff + ")"); } if (spfx == "defDebuff") { targetStats.defDebuff = 1; //*** MAKE THIS A TEMPORARY DEBUFF! WITH 10% CHANCE OF HAPPENING. } }
void OnionAttacks(CombatantStats attacker) { Debug.Log("The onion attacks!"); chooseAttack = Random.Range(0, 2); // choose an attack if (chooseAttack == 0) { Debug.Log("Attack type: Smack"); dmg = 3; } else if (chooseAttack == 1) { Debug.Log("Attack type: Peel"); if (attacker.magic >= 2) { dmg = 2 + attacker.power; float chance = Random.value; if (chance <= 0.1) { spfx = "defDebuff"; } attacker.magic -= 2; attacker.HP -= 1; } else { Debug.Log("Not enough magic left!"); chooseAttack = 0; Debug.Log("New choice is " + chooseAttack); } } chooseTarget = Random.Range(0, allies.Count()); // Choose a target target = allies.ElementAt <GameObject>(chooseTarget); targetStats = target.GetComponent <CombatantStats>(); if (target != null) { Debug.Log("The target is " + target.name); //*** if (spfx != null) { Debug.Log("Applying SpFX"); ApplySpFX(spfx, targetStats); GameObject stinkCloud = Instantiate(stinky, attacker.transform.position - moveOffset, Quaternion.identity); } CalculateDamage(dmg, attacker, targetStats); ResetAttacks(); } }
public void Populate(BattleOrder order) { this.order = order; actionText.text = order.Action; if (order.TargetTile.GetOccupant() != null && !order.TargetTile.GetOccupant().Stats.HasStatus("dead")) { CombatantStats stats = order.SourceCombatant.Stats; damageText.text = " " + stats.AttackPower + " Dmg \n " + stats.Accuracy + " % Acc"; } else { damageText.text = "-/-"; } }
void BeetAttacks(CombatantStats attacker) { Debug.Log("The beet attacks!"); Debug.Log("Attack type: Bash"); dmg = 4; chooseTarget = Random.Range(0, allies.Count()); // Choose a target target = allies.ElementAt <GameObject>(chooseTarget); if (target != null) { Debug.Log("The target is " + target.name); //*** CalculateDamage(dmg, attacker, target.GetComponent <CombatantStats>()); ResetAttacks(); } }
void HealMove(int heal, CombatantStats target) { moving = true; healed = target.gameObject.GetComponent <AnimatedBattle>().Healed(); StartCoroutine(healed); target.HP += heal; if (target.HP > target.maxHP) { target.HP = target.maxHP; } else { target.HP -= 0; } Debug.Log(target.gameObject.name + " is healed. New HP: " + target.HP); //*** }
void Start() { // Create new loot table LootTable = new LootTable(); // Create new list of loot LootTable.lootDrops = new List <LootDrop> { // Populate loot list new LootDrop("sword", 1), }; for (int i = 0; i < listOfDrops.Length; i++) { LootTable.lootDrops.Add(new LootDrop(listOfDrops[i], chancesOfDrops[i])); } ID = enemyID; Experience = experienceForKilling; // Assign nav mesh agent navMeshAgent = GetComponent <NavMeshAgent>(); combatantStats = new CombatantStats(attackLevel, defenceLevel, attackSpeed); // Set health to full currentHealth = maxHealth; }
public CombatantStats Apply(CombatantStats target) { switch (Operator) { case OperatorType.Add: target.MaxHealth += (int)(HealthFactor + 0.5f); target.Strength += (int)(StrengthFactor + 0.5f); target.Defense += (int)(DefenseFactor + 0.5f); target.Agility += (int)(AgilityFactor + 0.5f); target.Mass += (int)(MassFactor + 0.5f); break; case OperatorType.Multiply: target.MaxHealth = (int)(target.MaxHealth * HealthFactor); target.Strength = (int)(target.Strength * StrengthFactor); target.Defense = (int)(target.Defense * DefenseFactor); target.Agility = (int)(target.Agility * AgilityFactor); target.Mass = (int)(target.Mass * MassFactor); break; } return(target); }
private void CalculateEffectiveStats() { CombatantStats baseAccumulator = m_baseStats; CombatantStats effectiveAccumulator = m_baseStats; m_modifiers.Sort(); foreach (CombatantModifier modifier in m_modifiers) { switch (modifier.Effect) { case CombatantModifier.EffectType.Base: CombatantStats modifiedStats = modifier.Apply(m_baseStats); baseAccumulator += modifiedStats; break; case CombatantModifier.EffectType.Effective: effectiveAccumulator = modifier.Apply(effectiveAccumulator); break; } } m_effectiveStats = effectiveAccumulator + baseAccumulator; }
void CarrotAttacks(CombatantStats attacker) { Debug.Log("The carrot attacks!"); chooseAttack = Random.Range(0, 2); // choose an attack if (chooseAttack == 0) { Debug.Log("Attack type: Drill"); dmg = 3; } else if (chooseAttack == 1) { Debug.Log("Attack type: Deadly Drill"); if (attacker.magic >= 2) { dmg = 6; attacker.magic -= 2; } else { Debug.Log("Not enough magic left!"); chooseAttack = 0; Debug.Log("New choice is " + chooseAttack); } } chooseTarget = Random.Range(0, allies.Count()); // Choose a target target = allies.ElementAt <GameObject>(chooseTarget); if (target != null) { Debug.Log("The target is " + target.name); //*** CalculateDamage(dmg, attacker, target.GetComponent <CombatantStats>()); ResetAttacks(); } }
public void Reset(CombatantStats stats) { this.combatantStats = stats; this.MovesLeft = stats.MovesPerTurn; this.AttacksLeft = stats.AttacksPerTurn; this.AITurnPlan = null; }
public void RestoreMana() { targetStats = target.GetComponent <CombatantStats>(); targetStats.magic += restore; }
// Use this for initialization void Start() { // Get combat stats from player combatantStats = GetComponent <Player>().combatantStats; }
// Use this for initialization void Start() { // Create reference to player stats stats = GetComponent <Player>().combatantStats; }
private void Awake() { unitStats = GetComponent <CombatantStats>(); combatantObjectInfo = GetComponent <ObjectInfo>(); unitSM = GetComponent <CombatantStateMachine>(); }
public void Consume(CombatantStats stats) { Debug.Log("Used Test Consumable"); }
void Awake() { combatantStats = new CombatantStats(10, 10, 5); }
void DeliveryMoves(CombatantStats dG) { dGMoveMenu.SetActive(true); if (dGMoveChoice == 1 && moveSelected == false) { Debug.Log("Attack type: Smack"); dmg = 3; heal = 0; spfx = null; moveSelected = true; } if (dGMoveChoice == 2 && moveSelected == false) { Debug.Log("Attack type: Healing Meal"); if (dG.magic >= 2) { dmg = 0; heal = 5; spfx = null; dG.magic -= 2; moveSelected = true; } else { Debug.Log("Not enough magic left!"); } } if (dGMoveChoice == 3 && moveSelected == false) { Debug.Log("Attack type: On the Go"); if (dG.magic >= 2) { dmg = 0; heal = 0; spfx = "2xD"; dG.magic -= 2; moveSelected = true; } else { Debug.Log("Not enough magic left!"); } } if (dmg != 0 || heal != 0 || spfx != null) { TargetSelection(); } if (target != null) { Debug.Log("The target is " + target.name); //*** if (spfx != null) { spfxSource.PlayOneShot(spfxClip); // Buff: On the Go SFX plays ApplySpFX(spfx, target.GetComponent <CombatantStats>()); } if (dmg != 0) { aquaSmackSource.PlayOneShot(aquaSmackClip); // Smack sound effect plays CalculateDamage(dmg, dG, target.GetComponent <CombatantStats>()); } else if (heal != 0) { healingMealSource.PlayOneShot(healingMealClip); // Healing Meal SFX HealMove(heal, target.GetComponent <CombatantStats>()); GameObject healMeal = Instantiate(bP, (dG.transform.position + moveOffset), Quaternion.identity); healMeal.GetComponent <Animator>().SetBool("openNow", true); } ResetAttacks(); dGMoveMenu.SetActive(false); } }
private void Awake() { unitStats = GetComponent <CombatantStats>(); }
private void Awake() { unitStats = GetComponent <CombatantStats>(); combatantComponent = GetComponent <Combatant>(); unitSM = GetComponent <CombatantStateMachine>(); }