Esempio n. 1
0
    public void CollectWeaponUpgrade()
    {
        if (!upgraded)
        {
            int         upgradeChoice = Random.Range(0, 3);
            UpgradeType upgradeType;

            if (upgradeChoice == 0)
            {
                upgradeType = UpgradeType.NUM_PROJECTILES;
            }
            else if (upgradeChoice == 1)
            {
                upgradeType = UpgradeType.BIGGER_PROJECTILES;
            }
            else
            {
                upgradeType = UpgradeType.FIRE;
            }


            gameState.WeaponUpgradeCollected(upgradeType);

            GameObject  textPopup    = Instantiate(textPopupComponent, transform.position + new Vector3(0.5f, 0.5f, 0), Quaternion.identity);
            DamagePopup textPopupObj = textPopup.GetComponent <DamagePopup>();
            textPopupObj.SetupVendingMachineUpgrade(upgradeType);
            audioSource.PlayOneShot(audioClip, 0.50f);

            upgraded = true;
        }
    }
Esempio n. 2
0
    public virtual void DoDamage(DamageInfo info)
    {
        bool toPlayer = info.faction == Faction.ToPlayer;
        bool heal     = info.damage < 0;

        if (health == 0)
        {
            return;
        }
        if (heal)
        {
            DamagePopup.Create(transform.position, info.damage, 3.41f, GameAssets.curr.hpUpColor);
        }
        else
        {
            if (toPlayer)
            {
                DamagePopup.Create(transform.position, info.damage, 3f, GameAssets.curr.hpDownPlayerColor);
                SoundManager.PlaySound("PlayerHit");
            }
            else
            {
                DamagePopup.Create(transform.position, info.damage, 3.41f, GameAssets.curr.hpDownColor);
                SoundManager.PlaySound("EnemyHit");
            }
        }
    }
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "PlayerSpell")
        {
            sr.material = matRed;
            if (currentHealth == 1)
            {
                ScoreScript.ScoreValue1 += 100;
                DamagePopup.Create(floatingDamageP1, transform.position, 100);
            }
            currentHealth--;
        }
        else
        {
            Invoke("ResetMaterial", 0.3f);
        }


        if (col.gameObject.tag == "PlayerSpell2")
        {
            sr.material = matRed;
            if (currentHealth == 1)
            {
                ScoreScript2.ScoreValue2 += 100;
                DamagePopup.Create(floatingDamageP2, transform.position, 100);
            }
            currentHealth--;
        }
        else
        {
            Invoke("ResetMaterial", 0.3f);
        }
    }
Esempio n. 4
0
    public override void Activate(int atk, Team targets, Hero self)
    {
        int damage = atk * power / 100;

        foreach (Hero target in targets.heroes)
        {
            // Skip if dead
            if (target.isDead)
            {
                continue;
            }

            // Hitcheck based on accuracy
            if (HitCheck(accuracy))
            {
                // Apply damage to the enemy
                target.applyDamage(damage, this);

                // Show floating damage number
                DamagePopup.CreateDamage(target.transform.position, damage);
            }
            else // Miss
            {
                // Show miss text
                DamagePopup.CreateText(target.transform.position, "Miss");
            }
        }
    }
Esempio n. 5
0
        public bool MultipleMelee(float damage, int amountTargets, List <Collider2D> enemies, Vector3 playerPosition)
        {
            AttackedEnemies.Clear();
            if (!HasEnemies(enemies))
            {
                return(false);
            }


            var closest = MultiClosestTarget(amountTargets, enemies, playerPosition);

            if (closest != null)
            {
                AttackedEnemies = closest;
                foreach (Collider2D coll in AttackedEnemies)
                {
                    CharActions charActions = coll.GetComponent <CharActions>();
                    charActions.TakeDamage(damage);
                    bool isCrit = Random.Range(0, 100) < 30;
                    DamagePopup.Create(damageInfo, coll.transform.position, damage, isCrit);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 6
0
    public void Damage(IEnemyTargetable attacker)
    {
        Vector3 bloodDir = (GetPosition() - attacker.GetPosition()).normalized;

        Blood_Handler.SpawnBlood(GetPosition(), bloodDir);

        int damageAmount = 30;

        DamagePopup.Create(GetPosition(), damageAmount, false);
        healthSystem.Damage(damageAmount);
        if (IsDead())
        {
            FlyingBody.Create(GameAssets.i.pfEnemyFlyingBody, GetPosition(), bloodDir);
            Destroy(gameObject);
        }
        else
        {
            // Knockback
            transform.position += bloodDir * 5f;
            if (hitUnitAnim != null)
            {
                state = State.Busy;
                characterBase.PlayHitAnimation(bloodDir * (Vector2.one * -1f), SetStateNormal);
            }
        }
    }
Esempio n. 7
0
    public override void TakeHit(float damage, Vector3 hitPoint, Vector3 hitDir)
    {
        AudioManager.instance.PlaySound("Impact", transform.position);

        if (damage >= health)     //if it died, make big particle go whoosh
        {
            ParticleSystem instDeathFX = Instantiate(deathEffect, hitPoint, Quaternion.FromToRotation(Vector3.forward, hitDir)) as ParticleSystem;
            Material       mat         = instDeathFX.GetComponent <Renderer>().material;
            mat.color = originalColour;
            AudioManager.instance.PlaySound("Enemy Death", transform.position);
            Destroy(instDeathFX, 3f);
            DiedAt(transform.position, originalColour);
        }
        else     //if took damage but didnt die, make smol particle go wosh
        {
            ParticleSystem instHitFx = Instantiate(hitEffect, hitPoint, Quaternion.FromToRotation(Vector3.back, hitDir)) as ParticleSystem;
            Material       mat       = instHitFx.GetComponent <Renderer>().material;
            mat.color = originalColour;
            Destroy(instHitFx, 3f);
            //StartCoroutine(Stagger(.5f));
        }

        DamagePopup popupInstance = Instantiate(dmgPopup, hitPoint, Quaternion.AngleAxis(70, Vector3.right)) as DamagePopup;

        popupInstance.Customize(2f, damage, hitPoint);

        base.TakeHit(damage, hitPoint, hitDir);
    }
Esempio n. 8
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "PlayerSpell")
        {
            if (currentHealth == 1)
            {
                ScoreScript.ScoreValue1 += 25;
                DamagePopup.Create(floatingDamageP1, transform.position, 25);
            }
            currentHealth--;
        }
        else if (col.gameObject.tag == "Player")
        {
            FindObjectOfType <AudioManager>().Play("Seagull");
            GameObject die = (GameObject)Instantiate(dieflame, transform.position, transform.rotation);
            Destroy(gameObject);
        }

        if (col.gameObject.tag == "PlayerSpell2")
        {
            if (currentHealth == 1)
            {
                ScoreScript2.ScoreValue2 += 25;
                DamagePopup.Create(floatingDamageP2, transform.position, 25);
            }
            currentHealth--;
        }
        else if (col.gameObject.tag == "Player2")
        {
            FindObjectOfType <AudioManager>().Play("Seagull");
            GameObject die = (GameObject)Instantiate(dieflame, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    }
Esempio n. 9
0
    private void EnemyMain_OnDamaged(object sender, EnemyMain.OnDamagedEventArgs e)
    {
        Vector3 bloodDir = (GetPosition() - e.attacker.GetPosition()).normalized;

        BloodParticleSystemHandler.Instance.SpawnBlood(5, GetPosition(), bloodDir);

        int damageAmount = Mathf.RoundToInt(30 * e.damageMultiplier * UnityEngine.Random.Range(.8f, 1.2f));

        DamagePopup.Create(GetPosition(), damageAmount, false);
        enemyMain.HealthSystem.Damage(damageAmount);

        Sound_Manager.PlaySound(Sound_Manager.Sound.BodyHit_1, GetPosition());

        if (enemyMain.HealthSystem.IsDead())
        {
            FlyingBody.Create(GameAssets.i.pfEnemyFlyingBody, GetPosition(), bloodDir);
            enemyMain.DestroySelf();
            Sound_Manager.PlaySound(Sound_Manager.Sound.Minion_Dead, GetPosition());
        }
        else
        {
            // Knockback
            enemyMain.EnemyRigidbody2D.MovePosition(transform.position + bloodDir * 5f);
        }
    }
    public static DamagePopup Create(int damage, Vector3 position)
    {
        damagePrefab = Instantiate(GameAsset.Instance.damageHitInfo, position + new Vector3(0.5f, 2f, 0), Quaternion.identity);
        DamagePopup dmg = damagePrefab.GetComponent <DamagePopup>();

        dmg.Setup(damage);
        return(dmg);
    }
Esempio n. 11
0
    public static DamagePopup Create(Vector3 position, string text, Color color)
    {
        DamagePopup damagePopup = Create(position, 0, false);

        damagePopup.SetText(text);
        damagePopup.SetTextColor(color);
        return(damagePopup);
    }
Esempio n. 12
0
    public static DamagePopup Create(Vector3 pos, int damageAmount)
    {
        GameObject  damagePopupTransform = Instantiate(GameAssets.assets.DamagePopupPrefab, pos, Quaternion.identity);
        DamagePopup damagePopup          = damagePopupTransform.GetComponent <DamagePopup>();

        damagePopup.Setup(damageAmount);
        return(damagePopup);
    }
Esempio n. 13
0
 protected void InstantiateDamagePopup(FightingEntity target, int damage, DamageType damageType)
 {
     if (damagePopupCanvasPrefab != null)
     {
         DamagePopup popup = Instantiate(damagePopupCanvasPrefab).GetComponent <DamagePopup>();
         popup.Initialize(target, damage, damageType);
     }
 }
Esempio n. 14
0
    public static DamagePopup Create(Vector3 position, int damageAmount)
    {
        Transform   damagePopupTransform = Instantiate(GameAssets.i.pfDamagePopup, position, Quaternion.identity);
        DamagePopup damagePopup          = damagePopupTransform.GetComponent <DamagePopup>();

        damagePopup.Setup(damageAmount);
        return(damagePopup);
    }
Esempio n. 15
0
    public static DamagePopup Create(int dmg, Transform parent)
    {
        DamagePopup instance = Instantiate(Resources.Load("Prefabs/DamagePopup") as GameObject,
                                           parent.position + new Vector3(0, 0.5f, 0), Quaternion.identity).GetComponent <DamagePopup>();

        instance.tmp.text = dmg.ToString();
        return(instance);
    }
    public static DamagePopup Create(Transform floatingDamage, Vector3 position, int damageAmount)
    {
        Transform floatingDmgPopupTransform = Instantiate(floatingDamage, position, Quaternion.identity);

        DamagePopup damagePopup = floatingDmgPopupTransform.GetComponent <DamagePopup>();

        damagePopup.setup(damageAmount);
        return(damagePopup);
    }
Esempio n. 17
0
    // Use this for initialization
    public static void Initialize()
    {
        canvasDamage = GameObject.Find("CanvasDamage");

        if (!damagePopup)
        {
            damagePopup = Resources.Load <DamagePopup> ("Prefabs/Inimigos/CanvasUtilites/DamagePopupTextParent");
        }
    }
Esempio n. 18
0
    // Let the enemy attack.
    private IEnumerator EnemyAttack()
    {
        List <int> characters = new List <int>();

        for (int i = 0; i < activeBattleCharacters.Count; i++)
        {
            if (activeBattleCharacters[i].isPlayer && activeBattleCharacters[i].currentHP > 0)
            {
                characters.Add(i);
            }
        }

        //Target to attack of the enemy
        int          target    = characters[Random.Range(0, characters.Count)];
        BattleSkills skillUsed = null;

        // Select a skill to use.
        int selectedAttack = Random.Range(0, activeBattleCharacters[currentTurn].skillsAvailable.Length);

        for (int i = 0; i < skillsList.Length; i++)
        {
            if (skillsList[i].skillName == activeBattleCharacters[currentTurn].skillsAvailable[selectedAttack])
            {
                skillUsed = skillsList[i];
            }
        }

        // Roll the dice to get the dice values.
        Dice.selfReference.playerNumberOfDiceFaces = activeBattleCharacters[target].numberOfDiceFaces;
        Dice.selfReference.enemyNumberOfDiceFaces  = activeBattleCharacters[currentTurn].numberOfDiceFaces;
        yield return(StartCoroutine(Dice.selfReference.RollTheDice()));

        yield return(new WaitForSeconds(0.5f));

        // Play the enemy's attack effect.
        if (activeBattleCharacters[currentTurn].isABoss)
        {
            activeBattleCharacters[currentTurn].GetComponent <Animator>().SetTrigger("Attack");
        }

        else
        {
            Instantiate(enemyAttackEffect, activeBattleCharacters[currentTurn].transform.position, activeBattleCharacters[currentTurn].transform.rotation);
        }

        //Play the skill's animation.
        Instantiate(skillUsed.visualEffect, activeBattleCharacters[target].transform.position, activeBattleCharacters[target].transform.rotation);

        // Inflict damage/heal a target
        int damageInflicted = inflictDamage(target, skillUsed.damagePower, skillUsed.isAHealMove, Dice.selfReference.enemyValue, Dice.selfReference.playerValue);

        activeBattleCharacters[target].currentHP -= damageInflicted;
        DamagePopup.Create(activeBattleCharacters[target].transform.position, System.Math.Abs(damageInflicted), false);

        // Update stats to the screen.
        UpdateStats();
    }
Esempio n. 19
0
    public static DamagePopup Create(GameObject pfDamagePopup, Vector3 position, float damageAmount)
    {
        GameObject  damagePopupTransform = Instantiate(pfDamagePopup, position, Quaternion.identity);
        DamagePopup damagePopup          = damagePopupTransform.transform.GetComponent <DamagePopup>();

        damagePopup.Setup(damageAmount);

        return(damagePopup);
    }
Esempio n. 20
0
    public static DamagePopup Create(Vector3 Position, int damageAmount, float FontSize, Color color)
    {
        Transform   damagePopupTransform = Instantiate(GameAssets.curr.pfDamagePopup, Position, Quaternion.identity);
        DamagePopup damagePopup          = damagePopupTransform.GetComponent <DamagePopup>();

        damagePopup.Setup(damageAmount, color, FontSize);

        return(damagePopup);
    }
Esempio n. 21
0
    public static DamagePopup Create(GameObject pfText, Vector3 position, float damageAmount, bool isCriticalHit)
    {
        var damagePopupTransform = Instantiate(pfText, position + new Vector3(0, 1.7f, 0), Quaternion.identity);

        DamagePopup damagePopup = damagePopupTransform.GetComponent <DamagePopup>();

        damagePopup.Setup(damageAmount, isCriticalHit);
        return(damagePopup);
    }
    public static DamagePopup Create(Vector3 position, float damage, bool isCriticalHit, CharacterData player, bool isXp)
    {
        Transform   obj   = Instantiate(ImpactManager.instance.PopupText, position, Quaternion.identity);
        DamagePopup popup = obj.GetComponent <DamagePopup>();

        popup.Setup(damage, isCriticalHit, player, isXp);

        return(popup);
    }
Esempio n. 23
0
    public static DamagePopup Create(Vector3 position, Quaternion rotation, int damageAmout, bool isCriticalHit)
    {
        Transform   damageTransform = Instantiate(GlobalParameter.Global.DamagePopup.transform, position, rotation);
        DamagePopup damagePopup     = damageTransform.GetComponent <DamagePopup>();

        // int damage = Random.Range(250, 300);
        damagePopup.Setup(damageAmout, isCriticalHit);
        return(damagePopup);
    }
 void OnCollisionEnter(Collision collision)
 {
     if (shouldTriggerDamage(collision))
     {
         float randomizedX = transform.position.x + Random.Range(0f, 3f);
         float randomizedY = transform.position.y + Random.Range(1.0f, 2.0f);
         DamagePopup.Create(new Vector3(randomizedX, randomizedY, transform.position.z), (int)collision.relativeVelocity.magnitude);
     }
 }
Esempio n. 25
0
    public static DamagePopup Create(Transform popup, Vector3 position, int damageAmount, bool isCriticalHit)
    {
        Transform   damagePopupTransform = Instantiate(popup, position, Quaternion.identity);
        DamagePopup damagePopup          = damagePopupTransform.GetComponent <DamagePopup>();

        damagePopup.Setup(damageAmount, isCriticalHit);

        return(damagePopup);
    }
Esempio n. 26
0
 public void SetReferences(Animator a, DamagePopup d, HealthBarUI h, StatusEffectOverlays o, Transform UITransform, GameObject abilityTarget)
 {
     animator          = a;
     damagePopup       = d;
     healthBarUI       = h;
     overlays          = o;
     uiTransform       = UITransform;
     tempAbilityTarget = abilityTarget;
 }
Esempio n. 27
0
    protected void ShowText(string text, Color c, int offset)
    {
        GameObject  o      = Object.Instantiate(Resources.Load("Prefabs/DamagePopupPrefab", typeof(GameObject))) as GameObject;
        DamagePopup script = o.GetComponent <DamagePopup>();

        script.setText(text);
        script.setColor(c);
        o.transform.position = new Vector3(game_object.transform.position.x, 0, game_object.transform.position.z + 1.0f + offset / 2.0f);
    }
    // Create a Damage Popup
    public static DamagePopup Create(Vector3 position, int damageAmount, bool isCriticalHit)
    {
        Transform damagePopupTransform = Instantiate(Resources.Load <Transform>("pfDialoguePopup"), position, Quaternion.identity);

        DamagePopup damagePopup = damagePopupTransform.GetComponent <DamagePopup>();

        damagePopup.Setup(damageAmount, isCriticalHit);

        return(damagePopup);
    }
Esempio n. 29
0
    // Update is called once per frame
    public static void CreatingDamagePopupText(string text, Transform location)
    {
        DamagePopup instance            = Instantiate(damagePopup);
        Vector2     positionDamagePopup = Camera.main.WorldToScreenPoint(location.position);

        positionDamagePopup.x += 25;
        instance.transform.SetParent(canvasDamage.transform, false);
        instance.transform.position = positionDamagePopup;
        instance.SetText(text);
    }
Esempio n. 30
0
    public static DamagePopup Create(Transform pf_Popup, Vector3 pos, string text)
    {
        Transform damagePopupTransform = Instantiate(pf_Popup, pos, Quaternion.identity);

        DamagePopup damagePopup = damagePopupTransform.GetComponent <DamagePopup>();

        damagePopup.Setup(text);

        return(damagePopup);
    }