Пример #1
0
 private void Awake()
 {
     unitStats     = GetComponent <CombatantStats>();
     unitEquipment = GetComponent <Equipment>();
     unitDB        = GetComponent <BuildDB>();
     unitSM        = GetComponent <CombatantStateMachine>();
 }
Пример #2
0
 private void Awake()
 {
     unitStats         = GetComponent <CombatantStats>();
     unitMoveComponent = GetComponent <Move>();
     unitDB            = GetComponent <BuildDB>();
     unitSM            = GetComponent <CombatantStateMachine>();
 }
Пример #3
0
    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);
        }
    }
Пример #4
0
 public void Reset(CombatantStats stats)
 {
     this.combatantStats = stats;
     this.MovesLeft      = stats.MovesPerTurn;
     this.AttacksLeft    = stats.AttacksPerTurn;
     this.AITurnPlan     = null;
 }
Пример #5
0
    // 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;
    }
Пример #6
0
 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;
 }
Пример #7
0
    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;
    }
Пример #8
0
 void BossAttacks(CombatantStats attacker)
 {
     chooseAttack = Random.Range(0, 1); // choose an attack
     if (chooseAttack == 0)
     {
         Debug.Log("Attack type: Smack");
         dmg = 3;
     }
 }
Пример #9
0
 public void RestoreHealth()
 {
     targetStats     = target.GetComponent <CombatantStats>();
     targetStats.HP += restore;
     if (targetStats.HP > targetStats.maxHP)
     {
         targetStats.HP = targetStats.maxHP;
     }
 }
Пример #10
0
 private void Awake()
 {
     unitDB            = GetComponent <BuildDB>();
     unitLootActions   = GetComponent <LootActions>();
     unitMoveComponent = GetComponent <Move>();
     unitStats         = GetComponent <CombatantStats>();
     unitStateMachine  = GetComponent <CombatantStateMachine>();
     unitCombat        = GetComponent <Combat>();
     unitObjectInfo    = GetComponent <ObjectInfo>();
 }
Пример #11
0
    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");
    }
Пример #12
0
    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();
            }
        }
    }
Пример #13
0
 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.
     }
 }
Пример #14
0
    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();
        }
    }
Пример #15
0
 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 = "-/-";
     }
 }
Пример #16
0
    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();
        }
    }
Пример #17
0
    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); //***
    }
Пример #18
0
 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;
 }
Пример #19
0
    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);
    }
Пример #20
0
    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;
    }
Пример #21
0
    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();
        }
    }
Пример #22
0
 public void Reset(CombatantStats stats)
 {
     this.combatantStats = stats;
     this.MovesLeft = stats.MovesPerTurn;
     this.AttacksLeft = stats.AttacksPerTurn;
     this.AITurnPlan = null;
 }
Пример #23
0
 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;
 }
Пример #25
0
 // Use this for initialization
 void Start()
 {
     // Create reference to player stats
     stats = GetComponent <Player>().combatantStats;
 }
Пример #26
0
 private void Awake()
 {
     unitStats           = GetComponent <CombatantStats>();
     combatantObjectInfo = GetComponent <ObjectInfo>();
     unitSM = GetComponent <CombatantStateMachine>();
 }
Пример #27
0
 public void Consume(CombatantStats stats)
 {
     Debug.Log("Used Test Consumable");
 }
Пример #28
0
 void Awake()
 {
     combatantStats = new CombatantStats(10, 10, 5);
 }
Пример #29
0
    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);
        }
    }
Пример #30
0
 private void Awake()
 {
     unitStats = GetComponent <CombatantStats>();
 }
Пример #31
0
 private void Awake()
 {
     unitStats          = GetComponent <CombatantStats>();
     combatantComponent = GetComponent <Combatant>();
     unitSM             = GetComponent <CombatantStateMachine>();
 }