Esempio n. 1
0
    void Update()
    {
        if (life > 0)
        {
            seconds = seconds + Time.deltaTime;

            if (seconds >= 60)
            {
                minuts++;
                seconds = 0;
            }

            Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(PortalActivationArea.position, PortalActivationRange, enemyLayers);

            foreach (Collider2D enemyCollided in hitEnemies)
            {
                var enemy = enemyCollided.GetComponent <Enemy>();
                enemy.TakeDamage(enemy.maxHealth, new Vector2(transform.position.x, transform.position.y));
                life--;
                Transform   damagePopupTransform = Instantiate(pfDamagePopup, transform.position, Quaternion.identity);
                DamagePopup damagePopup          = damagePopupTransform.GetComponent <DamagePopup>();
                damagePopup.Setup(life);
            }
        }

        timeCount.text = minuts.ToString("00") + ":" + ((int)seconds).ToString("00");

        if (life == 0)
        {
            formatedTime = minuts.ToString("00") + ":" + ((int)seconds).ToString("00");
            SceneManager.LoadScene("end");
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Shows a floating damageText
    /// </summary>
    /// <param name="damageAmount">Damage you want to show</param>
    void ShowDamage(int damageAmount)
    {
        Vector3     textPosition = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y + 2);
        DamagePopup dmgtxt       = Instantiate(DamagePopup, textPosition, Quaternion.identity);

        dmgtxt.Setup(damageAmount);
    }
Esempio n. 3
0
    public void TakeDamage(int damage, bool shake = true, bool burn = false)
    {
        if (burn || !invincibility)
        {
            invincibility      = true;
            invincibilityTimer = invincibilityMaxTimer;
            health            -= damage;

            if (shake)
            {
                screenShake.Shake(0.05f);
            }

            GameObject  damagePopup    = Instantiate(damagePopupComponent, transform.position + new Vector3(0.5f, 0.5f, 0), Quaternion.identity);
            DamagePopup damagePopupObj = damagePopup.GetComponent <DamagePopup>();
            damagePopupObj.Setup(damage, true, false);

            if (health < 0)
            {
                if (!died)
                {
                    died = true;
                    Instantiate(deathParticle, transform.position, Quaternion.identity);
                    Die();
                }
            }
            else
            {
                HandleHealthBar();
            }
        }
    }
    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. 5
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. 6
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. 7
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);
    }
Esempio n. 8
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. 9
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. 11
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. 12
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. 13
0
    public static DamagePopup Create(Transform followTransform, Vector3 position, Damage damage)
    {
        Transform popupTransform = Instantiate(GameAssets.i.damagePopupText, position, Quaternion.identity);

        popupTransform.SetParent(followTransform);
        DamagePopup popup = popupTransform.GetComponent <DamagePopup>();

        popup.Setup(damage);
        return(popup);
    }
    // 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. 15
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);
    }
Esempio n. 16
0
    public static DamagePopup Create(Vector3 position, int value, Color color)
    {
        GameObject damagePopupObj = Instantiate(GameSession.instance.damagePopupPrefab, position, Quaternion.identity);
        float      angle          = Random.Range(-5f, 5f);

        damagePopupObj.transform.eulerAngles = new Vector3(0, 0, angle);
        DamagePopup damagePopup = damagePopupObj.GetComponent <DamagePopup>();

        damagePopup.moveVector = Vector3.up;
        damagePopup.Setup(value, color);
        return(damagePopup);
    }
    private void DisplayPopupText()
    {
        if (popupCanvas == null)
        {
            return;
        }

        GameObject  newText     = Instantiate(popupCanvas, transform.position, Quaternion.identity);
        DamagePopup damagePopup = newText.GetComponent <DamagePopup>();

        damagePopup.Setup("-1");
    }
Esempio n. 18
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     hold = collision.gameObject.GetComponent <bulletMove>().Damage;
     damagePopupTransform = Instantiate(pfDamagePopup, this.transform.position, Quaternion.identity);
     damagePopup          = damagePopupTransform.GetComponent <DamagePopup>();
     damagePopup.Setup(hold.ToString());
     health -= hold;
     if (health <= 0)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 19
0
    public static DamagePopup Create(Vector3 position, int damage, bool isCritical)
    {
        GameObject damagePopupObj = Instantiate(GameSession.instance.damagePopupPrefab, position, Quaternion.identity);
        float      angle          = Random.Range(-5f, 5f);

        damagePopupObj.transform.eulerAngles = new Vector3(0, 0, angle);
        DamagePopup damagePopup = damagePopupObj.GetComponent <DamagePopup>();
        Vector3     dirToMe     = position - GameSession.instance.Player.transform.position;

        damagePopup.moveVector = dirToMe.normalized;
        damagePopup.Setup(damage, isCritical);
        return(damagePopup);
    }
Esempio n. 20
0
    // Create a Damage Popup
    public static DamagePopup Create(Transform target, int damageAmount, bool isCriticalHit)
    {
        Vector3    worldToScreenPos     = Camera.main.WorldToScreenPoint(target.position);
        GameObject canvas               = GameObject.FindWithTag("MainCanvas");
        Transform  damagePopupTransform = Instantiate(GameAssets.i.pfDamagePopup, worldToScreenPos, Quaternion.identity);

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

        damagePopup.Setup(target, damageAmount, isCriticalHit);

        damagePopupTransform.transform.SetParent(canvas.transform);
        return(damagePopup);
    }
Esempio n. 21
0
    public void TakeDamage(int damage)
    {
        if (currentHealth > 0)
        {
            // Hien thi so damage
            Transform   damgagePopupTransform = Instantiate(DamagePopup, transform.position, Quaternion.identity);
            DamagePopup damagePopup           = damgagePopupTransform.GetComponent <DamagePopup>();
            damagePopup.Setup(damage);

            currentHealth = Mathf.Max(0, currentHealth - damage);
            isDamaged     = true;
        }
    }
Esempio n. 22
0
    //Create a Damage Popup
    public static DamagePopup Create(Vector3 position, int damageAmount, bool isCrit)
    {
        Vector3 newPOS = new Vector3(position.x + .4f, position.y + .5f);

        Transform damagePopupTransform = Instantiate(GameAssets.i.pfDamagePopup,
                                                     newPOS,
                                                     Quaternion.identity);

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

        damagePopup.Setup(damageAmount, isCrit);
        return(damagePopup);
    }
Esempio n. 23
0
    public static DamagePopup Create(Vector3 position, float damage, bool isCriticalHit, Color?color)
    {
        Window_Pointer pointerUI            = TagResolver.i.gameManager.pointerUI;
        Transform      damagePopupTransform = Instantiate(GameAssets.i.pfDamagePopup, position, Quaternion.identity);
        DamagePopup    damagePopup          = damagePopupTransform.GetComponent <DamagePopup>();

        damagePopup.Setup((int)damage, isCriticalHit, color);
        damagePopup.transform.SetParent(pointerUI.transform);
        damagePopup.transform.LookAt(CameraSettings.CurrentCamera.transform);
        damagePopup.transform.Rotate(0, 180, 0);
        damagePopup.transform.position = position + (CameraSettings.CurrentCamera.transform.position - position).normalized * 0.73f;
        damagePopup.isCritical         = isCriticalHit;
        return(damagePopup);
    }
Esempio n. 24
0
    // Create a Damage Popup
    public static DamagePopup Create(Vector3 position, int damageAmount, bool isCriticalHit)
    {
        var randomSpawnRadius = .2f;
        var itemOffset        = position += Random.insideUnitSphere * randomSpawnRadius;

        itemOffset.y += 3f;
        Transform damagePopupTransform = Instantiate(GameAssets.i.pfDamagePopup, itemOffset, Quaternion.Euler(0.0f, 0.0f, Random.Range(-5f, 5f)));

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

        damagePopup.Setup(damageAmount, isCriticalHit);
        if (isCriticalHit)
        {
            AuraBubbleInitializer.Create(damagePopupTransform.position);
        }

        return(damagePopup);
    }
Esempio n. 25
0
        private void damageTarget()
        {
            // base dmg
            int dmg = (Random.Range(0, 10) * Strength) / 3;

            bool hasBlocked = false;

            if (!vsAI)
            {
                if (entityTarget.isBlocking)
                {
                    dmg = ((Random.Range(0, 10) * Strength) / 3) / 3;
                    entityTarget.isBlocking  = false;
                    entityTarget.specialUsed = false;
                    hasBlocked = true;
                }

                if (specialUsed)
                {
                    if (isSpecialAttack && !entityTarget.isBlocking)
                    {
                        dmg             = ((Random.Range(0, 10) * Strength) / 3) + 7 * 3;
                        isSpecialAttack = false;
                    }

                    specialUsed = false;
                }
                dmg -= entityTarget.Defence / 3;

                if (dmg < 0)
                {
                    dmg = 0;
                }

                // Damage entity
                entityTarget.AIDamagedYou(dmg);
            }
            else
            {
                // Facing AI
                if (aiEntity.isBlocking)
                {
                    dmg = ((Random.Range(0, 10) * Strength) / 3) / 3;
                    aiEntity.isBlocking  = false;
                    aiEntity.specialUsed = false;
                    hasBlocked           = true;
                }

                if (specialUsed)
                {
                    if (isSpecialAttack && !aiEntity.isBlocking)
                    {
                        dmg             = ((Random.Range(0, 10) * Strength) / 3) + 7 * 3;
                        isSpecialAttack = false;
                    }

                    specialUsed = false;
                }
                dmg -= aiEntity.Defence / 3;

                if (dmg < 0)
                {
                    dmg = 0;
                }

                // Damage entity
                aiEntity.TakeDamage(dmg);
            }

            // happens vs both AI and player

            float posY = aiEntity.transform.position.y;
            // will break once player gets involved pvp
            Transform   damagePopupTransform = Instantiate(DamagePopupPrefab, new Vector3(aiEntity.transform.position.x, posY += 1.5f, 0), Quaternion.identity);
            DamagePopup damagePopup          = damagePopupTransform.GetComponent <DamagePopup>();

            if (hasBlocked == true)
            {
                damagePopup.Setup(dmg, false, true);
            }
            else if (dmg >= 31)
            {
                damagePopup.Setup(dmg, true, false);
            }
            else
            {
                damagePopup.Setup(dmg, false, false);
            }
        }
Esempio n. 26
0
        private void DamageTarget()
        {
            // base dmg
            int dmg = (Random.Range(0, 10) * Strength) / 3;

            // AI STUFFZ
            if (energy >= 55 && HP > 30)
            {
                // high health and enough energy to use special attack
                dmg     = ((Random.Range(0, 10) * Strength) / 3) + 7 * 3;
                energy -= 45;
            }
            else if (energy >= 35)
            {
                isBlocking  = true;
                specialUsed = true;
                energy     -= 35;
            }

            // END AI STUFFZ

            bool hasBlocked = false;

            if (entityTarget.isBlocking)
            {
                dmg = ((Random.Range(0, 10) * Strength) / 3) / 3;
                entityTarget.isBlocking  = false;
                entityTarget.specialUsed = false;
                hasBlocked = true;
            }

            if (specialUsed)
            {
                if (isSpecialAttack && !entityTarget.isBlocking)
                {
                    dmg             = ((Random.Range(0, 10) * Strength) / 3) + 7 * 3;
                    isSpecialAttack = false;
                }

                specialUsed = false;
            }
            dmg -= entityTarget.Defence / 3;

            if (dmg < 0)
            {
                dmg = 0;
            }

            // send the damage to the player
            entityTarget.AIDamagedYou(dmg);

            float       posY = entityTarget.transform.position.y;
            Transform   damagePopupTransform = Instantiate(DamagePopupPrefab, new Vector3(entityTarget.transform.position.x, posY += 1.5f, 0), Quaternion.identity);
            DamagePopup damagePopup          = damagePopupTransform.GetComponent <DamagePopup>();

            if (hasBlocked == true)
            {
                damagePopup.Setup(dmg, false, true);
            }
            else if (dmg >= 31)
            {
                damagePopup.Setup(dmg, true, false);
            }
            else
            {
                damagePopup.Setup(dmg, false, false);
            }
        }