예제 #1
0
    //void ifTime()
    //{
    //    // print("In the t if statment");
    //    string minutes = ((int)t / 60).ToString();
    //    string seconds = (t % 60).ToString("f0");

    //    timerText.text = minutes + ":" + seconds;
    //}

    //void elseTime()
    //{
    //    // print("I am in the t else statment");
    //    checkingHealth();
    //}



    //void TakeDamage(int damage)
    //{
    //    currentHealth -= damage;

    //    healthBar.SetHealth(currentHealth);
    //}



    void OnCollisionEnter(Collision collision)
    {
        // Collision with Tomato
        if (collision.gameObject.tag == "tomato")
        {
            currentHealth -= damageFromTomato;

            // Debug.Log("Current Health after tomato is: " + currentHealth);

            healthBar.SetHealth(currentHealth);
            // print("Tomato collided with player. YAY!");

            if (currentHealth < 0)
            {
                Application.LoadLevel("cheesyJokeBook_looseState");
            }
        }


        // Collision with Bomb
        if (collision.gameObject.tag == "Bomb")
        {
            currentHealth += damageFromBomb;

            // Debug.Log("Current Health after bomb is: " + currentHealth);

            healthBar.SetHealth(currentHealth);
        }
    }
예제 #2
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "enemyWeapon")
     {
         whoCollide    = col.gameObject.tag;
         healthPoints -= col.gameObject.GetComponent <weaponCollider>().damage;
         //print("remaining health: " + healthPoints);
         anim.SetTrigger("gotHit"); //ANIMATION
         healthBar.SetHealth(healthPoints);
     }
 }
예제 #3
0
 public void TakeDamage()
 {
     // death animation
     if (damageTaken)
     {
         return;
     }
     damageTaken = true;
     damageTimer = 0.5f;
     Health     -= 1;
     healthBar.SetHealth(Health);
 }
예제 #4
0
 private void PengaturNyawa()
 {
     health        -= 1;
     currentHealth -= 1;
     healthBar.SetHealth(currentHealth);
     nyawaText.text = health.ToString();
     if (health <= 0)
     {
         status = Status.mati;
         LevelComplete.instance.ShowLevelDialog("Level Fail", sehatText.text);
         // mati();
         // SceneManager.LoadScene(SceneManager.GetActiveScene().name);
     }
 }
예제 #5
0
 private void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "enemy")
     {
         score.scoreValue -= 10;
         sr.color          = new Color(2, 0, 0);
         rb2d.AddForce(transform.up * 2, ForceMode2D.Impulse);
         currentHealth = currentHealth - 10;
         healthBar.SetHealth(currentHealth);
     }
     if (col.gameObject.tag != "enemy")
     {
         sr.color = Color.white;
     }
 }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        healthbar.SetHealth(currentHealth);

        if (isLocalPlayer)
        {
            if (Time.time >= freeTime)
            {
                if (!playerMove.enabled)
                {
                    playerMove.enabled = true;
                }
            }
            if (Input.GetButtonDown("Down"))
            {
                combatMode = true;
                CmdsetCombat();
                //CombatMode();
            }
            if (Input.GetButtonUp("Down"))
            {
                combatMode = false;

                CmdfsetCombat();
                //UnCombatMode();
            }
            if (Input.GetKeyDown(KeyCode.Space))
            {
                if (nextAttackTime <= Time.time)
                {
                    nextAttackTime = Time.time + 1 / attackRate;
                    CmdSeverAttack();
                }
            }
        }
        animator.SetBool("combat", combatMode);
    }
예제 #7
0
    // Update is called once per frame
    void Update()
    {
        healthBar.SetHealth(player.GetComponent <PlayerMovement2>().playerHealth);

        /*if (player.GetComponent<PlayerMovement2>().playerHealth <= 0)
         * {
         *  //playerIsDead = true;
         *  Debug.Log("player is dead");
         * }*/

        /*if (Input.GetKeyDown(KeyCode.K))
         * {
         *  TakeDamge(20);
         * }*/
        /*if (EnemyController.playerInRange == true)
         * {
         *  if (Time.time >= EnemyController.nextAttackTime)
         *  {
         *      TakeDamge(enemyAttackDamage);
         *      EnemyController.playerInRange = false;
         *      EnemyController.nextAttackTime = Time.time + 2f / EnemyController.attackRate;
         *  }
         * }*/
    }
예제 #8
0
 // Start is called before the first frame update
 void Start()
 {
     currentHealth = maxHealth;
     hb.SetMaxHealth(maxHealth);
     hb.SetHealth(currentHealth);
 }
예제 #9
0
 public void TakeDamage(int damage)
 {
     maxPlayerHealth -= damage;
     heathbar.SetHealth(maxPlayerHealth);
 }
예제 #10
0
 public void TakeDamage(int damage)
 {
     currentBossHealth -= damage;
     HealthBarBoss.SetHealth(currentBossHealth);
 }
예제 #11
0
 public void TakeDamage()
 {
     Health -= 1;
     healthBar.SetHealth(Health);
 }
예제 #12
0
    public void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "SpikeDamage")
        {
            currentHealth -= damage;
            healthBar.SetHealth(currentHealth);
            Blood.SetActive(true);
            StartCoroutine(coroutineBlood());
        }
        else
        {
            // playerAnimator.SetBool("Damage", false);
        }
        if (other.gameObject.tag == "Lever")
        {
            gateOpen.SetBool("GateOpen", true);
            lever.SetBool("leverPull", true);
        }

        if (other.gameObject.tag == "Fall")
        {
            Debug.Log("Falling");

            // currentHealth = 10;
            // healthBar.SetHealth(currentHealth);
        }
        if (other.gameObject.tag == "Enemy")
        {
            currentHealth -= damage;
            healthBar.SetHealth(currentHealth);
            StartCoroutine(coroutineBlood());
        }

        if (other.gameObject.tag == "GreenKey")
        {
            GreenKeys++;
            GreenKey.SetActive(true);
            Destroy(other.gameObject);
        }
        if (other.gameObject.tag == "RedKey")
        {
            RedKeys++;
            RedKey.SetActive(true);
            Destroy(other.gameObject);
        }
        if (other.gameObject.tag == "BlueKey")
        {
            BlueKeys++;
            BlueKey.SetActive(true);
            Destroy(other.gameObject);
        }


        if (other.gameObject.tag == "GreenDoor" && GreenKeys >= 1)
        {
            Debug.Log("open");
            GreenKey.SetActive(false);
            DoorOpen.SetBool("Open", true);
            GreenDoor.Play();
        }
        else if (other.gameObject.tag == "GreenDoor" && GreenKeys >= 0)
        {
            Text.SetActive(true);
        }

        if (other.gameObject.tag == "BlueDoor" && BlueKeys >= 1)
        {
            //Debug.Log("open1");
            BlueDoorOpen.SetBool("BlueOpen", true);
            BlueKey.SetActive(false);
            BlueDoor.Play();

            // Destroy(other.gameObject);
        }
        else if (other.gameObject.tag == "BlueDoor" && BlueKeys >= 0)
        {
            Text.SetActive(true);
        }

        if (other.gameObject.tag == "RedDoor" && RedKeys >= 1)
        {
            Debug.Log("open2");
            RedDoorOpen.SetBool("RedOpen", true);
            RedKey.SetActive(false);
            RedDoor.Play();


            //Destroy(other.gameObject);
        }
        else if (other.gameObject.tag == "RedDoor" && RedKeys >= 0)
        {
            Text.SetActive(true);
        }

        if (other.gameObject.tag == "heart" && currentHealth <= 10)
        {
            currentHealth++;
            healthBar.SetHealth(currentHealth);
        }

        if (other.gameObject.tag == "Cat")
        {
            SceneManager.LoadScene("EndScene");
        }
    }
예제 #13
0
    public void TakeDamage(int damage)
    {
        currentHealth -= damage;

        healthBar.SetHealth(currentHealth);
    }
예제 #14
0
 void TakeDamage(int damage)
 {
     currentHealth -= damage;
     points--;
     HealthBar.SetHealth(currentHealth);
 }