Example #1
0
    public void UpdateRations(int rations, int changeAmt)
    {
        rationTxt.text = "" + rations;

        if (changeAmt > 0)
        {
            floatingTextController.color = positiveColor;
            floatingTextController.CreateFloatingText("+" + changeAmt, rationTxt.rectTransform);
        }
        else if (changeAmt < 0)
        {
            floatingTextController.color = negativeColor;
            floatingTextController.CreateFloatingText("" + changeAmt, rationTxt.rectTransform);
        }

        if (rations <= 0)//LState
        {
            LoseStateRations.SetActive(true);
            //Reinit4();
        }
        //void Reinit4()
        //{
        // SceneManager.LoadScene("WorkingRecapScreen");
        //}
    }
Example #2
0
 public void IncreaseHealth(int value)
 {
     if ((health + value) > maxHealth)
     {
         health = maxHealth;
     }
     else
     {
         health += value;
     }
     floatingTextController.CreateFloatingText("+" + value, transform, Color.green);
 }
Example #3
0
    public void takeDamage(float damage, bool crit)
    {
        if (crit)
        {
            damage = damage * 2;
            CritFloatingTextController.CreateFloatingText(damage.ToString(), MyTransform, distance, crit);
        }
        else
        {
            FloatingTextController.CreateFloatingText(damage.ToString(), MyTransform, distance, crit);
        }
        health = health - damage;
        if (health <= 0)
        {
            ai.SetDestination(MyTransform.position);
            animator.SetBool("Die", true);
            body.enabled = false;
            head.enabled = false;

            if (body1 != null)
            {
                body1.enabled = false;
            }
            if (head1 != null)
            {
                head1.enabled = false;
            }
            Dead();
        }
    }
Example #4
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.tag == "Monster" || collision.tag == "Boss")
        {
            if (collision.GetComponent <enemyHealth>().currentHealth < 0)
            {
                return;
            }
            this.GetComponent <Rigidbody2D>().velocity = new Vector3(0, 0, 0);

            this.GetComponent <Animator>().SetTrigger("Hit");
            SfxManager.PlaySound("FireBallHit");

            float damage = (float)SaveManager.Instance.gestureDMG[4];
            if (!damageShown)
            {
                FloatingTextController.CreateFloatingText(damage.ToString(), transform);
                damageShown = true;
            }
            FightManager.currEnemy.gameObject.GetComponent <enemyHealth>().addDamage(damage);

            //duration of animation
            StartCoroutine(destroyAfterTime(0.77f));
        }
    }
Example #5
0
 public void LoseHealth(int loss)
 {
     FloatingTextController.CreateFloatingText(loss.ToString(), transform);
     //healthPoints -= loss;
     healthPoints -= 0;
     CheckIfGameOver();
 }
Example #6
0
    public void addDamage(float damage)
    {
        if (damage <= 0)
        {
            return;
        }

        healthSlider.gameObject.SetActive(true);
        currentHealth -= damage;
        FloatingTextController.CreateFloatingText(damage.ToString(), FightManager.currPlayer.transform);
        healthSlider.value = currentHealth;
        damaged            = true;


        // player damaged animation
        gameObject.GetComponent <Animator>().SetTrigger("isPushed");

        if (AutoMove.playerContact == true)
        {
            gameObject.GetComponent <Animator>().SetInteger("State", 0);
        }

        //playerAS.clip = playerHurt;
        //playerAS.Play();

        //       playerAS.PlayOneShot(playerHurt); //same

        if (currentHealth <= 0)
        {
            makeDead();
        }
    }
Example #7
0
    public override void TakeDamage(Damage damage)
    {
        int random = Random.Range(0, 101);

        /*print(random)*/
        ;
        //print(damage.HitChance);
        print("hit chance: " + damage.HitChance);
        print("dodge: " + Stats.Dodge);
        if (((damage.HitChance - Stats.Dodge) < random))
        {
            FloatingText floatingText = FloatingTextController.CreateFloatingText("MISS", gameObject.transform);
            floatingText.transform.localScale = new Vector3(1.25f, 1.25f);
        }
        else // DID HIT
        {
            FloatingText floatingText = FloatingTextController.CreateFloatingText(damage.DamageAmount.ToString(), gameObject.transform);
            if (damage.DidCrit)
            {
                floatingText.transform.localScale = new Vector3(1.4f, 1.4f);
                floatingText.SetCritColor();
            }
            EnemyMovement.knockable.AddXKnockback(damage.Knockback);
            EnemyMovement.stun.AddStun(damage.Stun);
            HealthDamaged(damage.DamageAmount);
        }
        if (Stats.CurrentHealth <= 0)
        {
            PlayDeathAnim();
        }
    }
Example #8
0
    private void MakeDamage(Unit enemy)
    {
        this.InitTeamHealthIfNotInitialized();
        enemy.InitTeamHealthIfNotInitialized();

        CalcDamageResult(enemy);
        teamDamage = (int)(damageResult * countOfWarrior);

        FloatingTextController.CreateFloatingText(teamDamage.ToString(), enemy.worldPosition);

        enemy.teamHealth -= teamDamage;

        enemy.RecountWarriors(enemy);

        if (enemy.countOfWarrior < 1)
        {
            if (enemy.isBotUnit)
            {
                BoardManager.Instance.enemyUnits.Remove(enemy);
                Bot.botTeam.Remove(enemy); //todo: refactor
            }
            else
            {
                BoardManager.Instance.playerUnits.Remove(enemy);
                Human.humanTeam.Remove(enemy); //todo: refactor
            }
            Destroy(enemy.gameObject);
        }
    }
Example #9
0
    public override IEnumerator ExecuteEffect(GameObject target, Vector3 startPosition, float characterSpeed, BaseBattleStateMachine characterStateMachine)
    {
                #pragma warning disable 0219
        GameObject attackAnimEffect = null;
        if (animationPrefab != null)
        {
            attackAnimEffect = Instantiate(animationPrefab, target.transform, false);
        }
                #pragma warning restore 0219

        yield return(new WaitForSeconds(WaitUntilFinished(characterStateMachine, target)));

        BaseBattleStateMachine targetStateMachine = target.GetComponent <BaseBattleStateMachine>();
        if (targetStateMachine != null)
        {
            FloatingTextController.CreateFloatingText(item.value.ToString(), target.transform, textColor);
            item.UseItem(targetStateMachine.character);
            if (targetStateMachine is CharacterStateMachine)
            {
                targetStateMachine.UpdateHeroPanel();
            }
        }
        #if UNITY_EDITOR
        Debug.Log("Used in battle");
        #endif
        yield return(null);
    }
Example #10
0
 public void SetMass(int mass, bool popup)
 {
     if ((int)(mass - this.mass) > 0)
     {
         if (popup)
         {
             FloatingTextController.CreateFloatingText(printInteger((int)(mass - this.mass)), this.transform, Color.green);
         }
     }
     else if ((int)(mass - this.mass) < 0)
     {
         if (popup)
         {
             FloatingTextController.CreateFloatingText(printInteger((int)(mass - this.mass)), this.transform, Color.red);
         }
     }
     else
     {
         if (popup)
         {
             FloatingTextController.CreateFloatingText(printInteger((int)(mass - this.mass)), this.transform, Color.black);
         }
     }
     this.mass = mass;
     changeScaleSlime();
 }
Example #11
0
        void FixedUpdate()
        {
            if (CurrentGameObject == null)
            {
                CurrentGameObject = FloatingTextController.CreateFloatingText(EnterString, transform);
                CurrentGameObject.SetOpacity(0);
            }

            var shiftVector = new Vector3(TextOffSetAmount, TextOffSetAmount);

            shiftVector.Scale(transform.up);
            Vector2 screenPosition = UnityEngine.Camera.main.WorldToScreenPoint(transform.position + shiftVector);

            CurrentGameObject.transform.position = screenPosition;
            CurrentGameObject.transform.rotation = transform.rotation;

            if (_canGoThrough && Input.GetButtonDown("Selective Button") && AvailableForKeyPress)
            {
                CurrentGameObject.SetOpacity(0);
                DontDestroyOnLoad(GameHandler.Game.Player);
                GameHandler.Game.NewLevel = true;
                GameHandler.Game.IncreaseLevel();
                GameHandler.Game.GotoNextLevel();
            }
        }
Example #12
0
    public void Heal()
    {
        if (!thisTurn.myTurn)
        {
            return;
        }
        if (mAction == 1)
        {
            if (pAction == 1)
            {
                return;
            }
            SpendPAction();
        }
        SpendMAction();
        int damageToHeal = player.WISmod;

        if (player.currentHP + damageToHeal >= player.maxHP)
        {
            FloatingTextController.CreateFloatingText((player.maxHP - player.currentHP).ToString(), transform, false);
            player.currentHP = player.maxHP;
            return;
        }
        else
        {
            player.currentHP += damageToHeal;
            FloatingTextController.CreateFloatingText(damageToHeal.ToString(), transform, false);
        }
    }
Example #13
0
    public virtual void TakeDamage(float amount)
    {
        if (canBeDamaged)
        {
            healthBar.fillAmount = health / startingHealth;
            FloatingTextController.CreateFloatingText(amount.ToString(), transform);

            //healthBar.color = Color.Lerp(red, green, health / startingHealth);
            if (healthBar.fillAmount > 0.5f)
            {
                healthBar.color = Color.Lerp(yellow, green, health / startingHealth);
                tempColor       = healthBar.color;
            }
            else if (healthBar.fillAmount <= 0.5f)
            {
                healthBar.color = Color.Lerp(red, tempColor, health / startingHealth);
            }

            if (((health -= amount) <= 0) && !isDead)
            {
                healthBar.fillAmount = 0;
                healthBar.color      = green;
                SelectState(state.Dead);
                //Die();
            }
        }
    }
Example #14
0
 public void SetDie()
 {
     m_ChaseParticleSystem.SetActive(false);
     // Play Sound
     if (m_Teeth)
     {
         SoundController.Instance.PlayOneShootAudio("event:/Teeth/TeethDie", m_EnemyTransform);
     }
     else
     {
         SoundController.Instance.PlayOneShootAudio("event:/Robot/RobotDie", m_EnemyTransform);
     }
     m_Collider.enabled = false;
     // Create floating text
     FloatingTextController.CreateFloatingText(m_EnemyBlackboard.m_CoinsToDrop.ToString(), m_EnemyTransform);
     // Stop last audio
     SoundController.Instance.StopEvent(m_CurrentAudioEvent);
     // Set state  to Die and stop NavMesh
     m_CurrentState           = TEnemyStates.Die;
     m_ElapsedTime            = 0.0f;
     m_NavMeshAgent.isStopped = true;
     m_Animation.clip         = m_DieAnimationClip;
     m_Animation.Play();
     DesactivateAnimations();
     SetDieAnimation(true);
     StartCoroutine(Die());
 }
Example #15
0
        private void FixedUpdate()
        {
            if (CurrentGameObject == null)
            {
                CurrentGameObject = FloatingTextController.CreateFloatingText(EnterString, transform);
                CurrentGameObject.SetOpacity(0);
            }

            var shiftVector = new Vector3(OffSetAmount, OffSetAmount);

            shiftVector.Scale(transform.up);
            Vector2 screenPosition = UnityEngine.Camera.main.WorldToScreenPoint(transform.position + shiftVector);

            CurrentGameObject.transform.position = screenPosition;
            CurrentGameObject.transform.rotation = transform.rotation;

            if (_availableForKeyPress && Input.GetButtonDown("Selective Button"))
            {
                CurrentGameObject.SetOpacity(0);
                Destroy(this.gameObject);
                var player     = GameObject.FindGameObjectWithTag("Player");
                var playerItem = player.GetComponent <SimpleItem>();
                playerItem.AddItem(this.gameObject);
            }
        }
Example #16
0
    public void ItemCollected(ItemType item)
    {
        if (itemPickUpSound != null)
        {
            itemPickUpSound.Play();
        }

        switch (item)
        {
        case ItemType.Sword:
            hasSword  = true;
            atkSpeed  = 0.6f;
            atkDamage = 10;
            break;

        case ItemType.Armor:
            defenseReduction = 2f;
            spriteAnimator.SetBool("bHasArmor", true);
            spriteAnimator.SetTrigger("GoToIdle");
            break;

        case ItemType.Soul:
            health += 70;
            UpdateHealthBar();
            spriteAnimator.SetBool("bIsGhost", false);
            spriteAnimator.SetTrigger("GoToIdle");
            break;

        case ItemType.Potion:
            health += 10;
            UpdateHealthBar();
            FloatingTextController.CreateFloatingText("+10", transform);
            break;
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Extra"))
        {
            GameControlScript.puntos += puntos;
            if (HealthBarScript.agarrado)
            {
                HealthBarScript.health += aumento;
            }
            FloatingTextController.CreateFloatingText("+25", transform);
            anim.Play("Move");
        }

        if (other.CompareTag("Enemy"))
        {
            GameControlScript.health -= 1;
            GameControlScript.puntos -= damage;

            GameControlScript.visibilidad = false;
            HealthBarScript.resetBar      = true;
            HealthBarScript.agarrado      = false;
            FloatingTextController.CreateFloatingText("-25", transform);
            CorazonInstanceCont.CreateCorazon(transform);
            anim.Play("Obstaculo");
        }

        if (other.CompareTag("Special"))
        {
            HealthBarScript.agarrado  = true;
            GameControlScript.puntos += aumentoSpe;
            FloatingTextController.CreateFloatingText("+50", transform);
            GameControlScript.visibilidad = true;
            anim.Play("Special");
        }
    }
    // Update is called once per frame
    void Update()
    {
        getChargeTimer();           //find the amount of charge

        if (currentChargeTimer > 0) //if there is any charge whatsoever
        {
            if (!chargeStarted)     //this flag is in place to ensure the sound only starts once
            {
                AudioHelper.PlayClip2D(chargeSFX, 0.6f);
                chargeStarted = true;
            }

            if (currentChargeTimer >= 0.33f && firstFlash == false) //the bool ensures this only triggers once
            {
                StartCoroutine(flashCoroutine());
                firstFlash = true;
                AudioHelper.PlayClip2D(chargeTickSFX, 0.7f);
            }
            if (currentChargeTimer >= 0.66f && secondFlash == false) //similar to previous, though louder and adds the pop up text
            {
                StartCoroutine(flashCoroutine());
                secondFlash = true;
                AudioHelper.PlayClip2D(chargeTickSFX, 0.9f);
                FloatingTextController.CreateFloatingText("Max!", transform);
            }
        }
        else   //when no longer charging, resets everything to zero
        {
            firstFlash    = false;
            secondFlash   = false;
            chargeStarted = false;
            sfxClip       = GameObject.Find("2D Audio ChargingSoundEffect (UnityEngine.AudioClip)");
            Destroy(sfxClip);
        }
    }
Example #19
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Food")
        {
            food         += pointsPerFood;
            foodText.text = "+" + pointsPerFood + "Food: " + food;
            col.gameObject.SetActive(false);
        }

        if (col.tag == "Soda")
        {
            food += pointsPerSoda;
            //foodText.text = "+" + pointsPerSoda + "Oxygen: " + food;
            foodText.text = food.ToString();
            col.gameObject.SetActive(false);

            // Floating Combat Text
            FloatingTextController.CreateFloatingText("+" + pointsPerSoda, transform);

            audio.PlayOneShot(takeOxySound);
        }

        if (col.tag == "Exit")
        {
            Invoke("LevelSucceed", GameManager.instance.startLevelDelay);
            enabled = false;
        }
    }
Example #20
0
    public virtual void TakeDamage(int amount)
    {
        if (canBeDamaged)
        {
            FloatingTextController.CreateFloatingText(amount.ToString(), transform);
            healthBar.fillAmount = health / startingHealth;

            if (healthBar.fillAmount > 0.6f)
            {
                healthBar.color = Color.Lerp(yellow, green, health / startingHealth);
            }
            else if (healthBar.fillAmount <= 0.6f)
            {
                healthBar.color = Color.Lerp(red, yellow, health / startingHealth);
            }

            if (((health -= amount) <= 0) && !isDead)
            {
                healthBar.fillAmount = 0;
                healthBar.color      = green;

                Die();
            }
        }
    }
Example #21
0
    private void updateScore(int score)
    {
        Color c          = gameObject.GetComponent <SpriteRenderer>().color;
        int   multiplier = getMultiplier();

        LevelManager.AddToScore(score * multiplier);
        FloatingTextController.CreateFloatingText(multiplier.ToString() + "X", c, transform);
    }
    public void CalcDamage(float dmg)
    {
        float PhysicHurt = (1 - defenace) * dmg;
        int   display    = Mathf.RoundToInt(PhysicHurt);

        FloatingTextController.CreateFloatingText(display.ToString(), transform);
        TakeDamage(PhysicHurt);
    }
Example #23
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         FloatingTextController.CreateFloatingText(cantidad.ToString(), transform);
         //TakeDamage(Random.Range(0, 100));
     }
 }
Example #24
0
 public void TakeDamage(double damage)
 {
     if (data.settings["Show floating damage text"])
     {
         FloatingTextController.CreateFloatingText(damage.ToString(), transform);
     }
     hp -= damage;
 }
Example #25
0
 public virtual void TakeDamage(int amount)
 {
     FloatingTextController.CreateFloatingText(amount.ToString(), transform);
     Debug.LogFormat("{0} was dealt {1} damage", gameObject.name, amount);
     if ((health -= amount) <= 0)
     {
         Die();
     }
 }
Example #26
0
 private void OnTriggerStay2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         FloatingTextController.CreateFloatingText("Hold X!");
         //holdKey.text = "Hold X!";
         triggerStay = true;
     }
 }
Example #27
0
    private void ClickAttempt()
    {
        Vector3 mousePos = Input.mousePosition;

        mousePos.z = 5f;

        Vector2 v = Camera.main.ScreenToWorldPoint(mousePos);

        Collider2D[] col = Physics2D.OverlapPointAll(v);

        GameObject goTargetHit = null;

        if (col.Length > 0)
        {
            foreach (Collider2D c in col)
            {
                goTargetHit = c.gameObject;
                if (c.gameObject.tag == "Enemy")
                {
                    break;
                }
            }
        }

        if (goTargetHit != null)
        {
            if (goTargetHit != null && goTargetHit.tag == "Enemy")
            {
                if (attackEffect != null)
                {
                    Instantiate(attackEffect, goTargetHit.transform.position, Quaternion.identity);
                }

                int  damage = GameState.gameState.GetClickDamage();
                bool isCrit = GameState.gameState.IsHitACrit();

                Color color    = Color.white;
                int   fontSize = 32;

                if (isCrit)
                {
                    color    = Color.red;
                    fontSize = 44;
                    damage   = (int)(damage * GameState.gameState.GetCritRate() / 100f);
                }

                //Debug.Log("ENEMY HIT!");
                goTargetHit.SendMessage("DamageEnemy", damage, SendMessageOptions.DontRequireReceiver);
                FloatingTextController.CreateFloatingText(damage.ToString(), goTargetHit.transform, color, fontSize);
            }
            else if (goTargetHit.tag == "GameBoard")
            {
                //Debug.Log("Board hit! Good Enough!");
            }
        }
    }
Example #28
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Destroy(col.gameObject);

        if (col.gameObject.tag == "Enemy")
        {
            ScoreCounter.score -= ScoreCounter.years * 3;
            FloatingTextController.CreateFloatingText("-3", popupTextParentPrefab.transform);
        }
    }
Example #29
0
 public void Use()
 {
     Target.CurrentHP -= DamageValue;
     FloatingTextController.CreateFloatingText(DamageValue.ToString(), Target.transform);
     if (Target.CurrentHP <= 0)
     {
         Target.Destroy();
         Target.gameObject.SetActive(false);
     }
 }
Example #30
0
    public override void deal_damage(Enemy target)
    {
        base.deal_damage(target);

        if (lifesteal_delta > Time.time)
        {
            FloatingTextController.CreateFloatingText("+ " + lifesteal_amount + " health", transform, Color.green);
            player.PowerUpTaken(PowerUp.Health, lifesteal_amount);
        }
    }