Example #1
0
 private void IncreaseLevel()
 {
     lvl++;
     SetParametersAccordingToTheLvl();
     healthManager.AddHealth((int)(healthManager.GetMaxHealth() * 0.4f));
     needExp = listLevelOfDevelopment.GetParammeterOfLevel(lvl).GetNeedExp();
     // shoe some VFX;
 }
Example #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }

        if (other.tag == "3Dbullet")
        {
            return;
        }

        if (other.tag == "Player" && gameObject.tag == "HealthOrb")
        {
            Instantiate(explosion, transform.position, transform.rotation);
            playerStat.AddHealth(healthValue);
            //audio.Play();
        }

        if (other.tag == "Player" && gameObject.tag == "ShieldOrb")
        {
            Instantiate(explosion, transform.position, transform.rotation);
            playerStat.ShieldSwitch();
            //audio.Play();
        }
        Destroy(gameObject);         //destroy object the script attached to
    }
    public void CmdEatFood(GameObject food, string fromSlot, bool isDrink)
    {
        if (Inventory[fromSlot].Item == null)
        {
            //Already been eaten or the food is no longer in hand
            return;
        }

        FoodBehaviour baseFood = food.GetComponent <FoodBehaviour>();

        if (isDrink)
        {
            soundNetworkActions.CmdPlaySoundAtPlayerPos("Slurp");
        }
        else
        {
            soundNetworkActions.CmdPlaySoundAtPlayerPos("EatFood");
        }
        PlayerHealth playerHealth = GetComponent <PlayerHealth>();

        //FIXME: remove health and blood changes after TDM
        //and use this Cmd for healing hunger and applying
        //food related attributes instead:
        playerHealth.AddHealth(baseFood.healAmount);
        playerHealth.BloodLevel += baseFood.healAmount;
        playerHealth.StopBleeding();

        InventoryManager.UpdateInvSlot(true, "", null, Inventory[fromSlot].UUID);
        equipment.ClearItemSprite(fromSlot);
        PoolManager.Instance.PoolNetworkDestroy(food);
    }
Example #4
0
 //玩家加血
 public void PlayerAddHealth(int value)
 {
     if (playerHealth != null)
     {
         playerHealth.AddHealth(value);
     }
 }
    public void InventoryButtonClick(Button button) //Function triggered when the player clicks an inventory slot button
    {
        string itemClicked = "";                    //temp string to hold item thats in slot that was clicked

        if (!playerHealthRef)
        {
            Debug.LogError("Error! Could not find reference to player health.");
            return;
        }

        for (int i = 0; i < inventorySize; i++)          //cycle through all slots to check which button was clicked (in terms of 1-8)
        {
            if (button.name == inventoryButtons[i].name) //check names to find match
            {
                if (playerItems.Count > i)               //check if item even exists
                {
                    itemClicked       = playerItems[i];  //set temp string to hold item selected
                    playerItems[i]    = "";
                    inventorySlotTemp = i;
                    Invoke("ClearInventorySlot", 0.8f); //wait 1 second before changing button back to nothing so it doesnt show in game
                }
                break;
            }
        }
        switch (itemClicked) //Do whatever function that item would do
        {
        case "Seed":         //for example if item was seed, it would then do its function here.
            Debug.Log("seed clicked");
            playerHealthRef.AddHealth(healAmount);
            //GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerHealth>().AddHealth(healAmount);
            FindObjectOfType <SoundManager>().Play("EatSeed");
            break;

        case "SuperSeed":      //Super seed gives double health as normal seed
            Debug.Log("Super seed clicked");
            playerHealthRef.AddHealth(healAmount * 2);
            //GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerHealth>().AddHealth(healAmount * 2);
            FindObjectOfType <SoundManager>().Play("EatSeed");
            break;

        default:
            Debug.Log("No item in that slot");         //error message/tells user slot is empty
            FindObjectOfType <SoundManager>().Play("InventoryClick");
            break;
        }
        CloseInvetory(false); //Close inventory when an item slot is clicked
    }
Example #6
0
 // Body contact when hp > 0 go game over
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.name.Contains("Enemy"))
     {
         PlayerHealth healthScript = GetComponent <PlayerHealth>();
         healthScript.AddHealth(-1f);
     }
 }
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         playerHealth.AddHealth();
         Destroy(gameObject);
     }
 }
Example #8
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         player.AddHealth(25f);
         Destroy(this.gameObject);
     }
 }
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player") && healthScript.health != healthScript.maxHealth) // If the player touches this
     {
         healthScript.StartCoroutine(healthScript.AddHealth(health));
         Destroy(this.gameObject); // Destroy this
     }
 }
Example #10
0
 private void Respawn() {
     transform.position = startPosition;
     if (!isFacingRight) Flip();
     isDead = false;
     deathTime = initialDeathTime;
     playerHealth.enabled = true;
     playerHealth.AddHealth(50);
 }
Example #11
0
 void Heal()
 {
     if (playerHealth.PlayerAlive())
     {
         playerHealth.AddHealth();
     }
     Destroy(gameObject);
 }
 private void OnTriggerEnter(Collider collider)
 {
     if (collider.CompareTag("Player"))
     {
         PlayerHealth playerHealth = collider.gameObject.GetComponent <PlayerHealth>();
         playerHealth.AddHealth(addHealth);
         Destroy(transform.parent.gameObject);
     }
 }
Example #13
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.GetComponent <PlayerController>() == null)
     {
         return;
     }
     PlayerHealth.AddHealth(life);
     Destroy(gameObject);
 }
Example #14
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "HealthItem")
     {
         PlayerHealth player = this.transform.GetComponent <PlayerHealth> ();
         player.AddHealth(1f);
         Destroy(col.gameObject);
     }
 }
Example #15
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         PlayerHealth.AddHealth(healthToAdd);
         StartCoroutine(Respawn());
         gameObject.transform.position = Vector3.up * 1000;
     }
 }
 void Health(Collider col)
 {
     playerHealth = col.gameObject.GetComponent<PlayerHealth>();
     if(playerHealth._health <=99)
     {
         playerHealth.AddHealth(20);
         Destroy(gameObject);
     }
 }
Example #17
0
 void OnTriggerEnter2D(Collider2D hitInfo)
 {
     //player = GameObject.FindGameObjectWithTag("Player");
     if (hitInfo.gameObject.tag == "Player")
     {
         SoundSource.Play();
         barLife.AddHealth(healthAmount);
         Destroy(gameObject);
     }
 }
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            Debug.Log("Collided!");
            playerHealth.AddHealth(amtToIncreaseBy);

            gameObject.SetActive(false);
        }
    }
Example #19
0
    // Update is called once per frame
    void Update()
    {
        if (myPlayer != null)
        {
            if (isDelivering)
            {
                transform.LookAt(myPlayer.transform.position);

                if (Vector3.Distance(transform.position, myPlayer.transform.position) < 1)
                {
                    isDelivering = false;
                    resourceType = Random.Range(1, 100);
                    if (resourceType % 2 == 0)
                    {
                        mPlayerCollector.inventory += 3;
                        mPlayerCollector.onInventoryUpdate.Invoke(mPlayerCollector.inventory);
                    }
                    else if (resourceType % 2 != 0)
                    {
                        if (mPlayerHealth.health < 100)
                        {
                            mPlayerHealth.AddHealth();
                        }
                        else
                        {
                            mPlayerCollector.inventory += 3;
                            mPlayerCollector.onInventoryUpdate.Invoke(mPlayerCollector.inventory);
                            mPlayerCollector.onInventoryAddedAtPosition.Invoke(mPlayerCollector.transform.position);
                        }
                    }
                }
            }
            if (!isDelivering)
            {
                transform.LookAt(Vector3.zero);
                if (Vector3.Distance(transform.position, Vector3.zero) < 1)
                {
                    mSkin.enabled = false;
                    homeTimer    -= Time.deltaTime;

                    if (homeTimer <= 0)
                    {
                        isDelivering  = true;
                        homeTimer     = Random.Range(1f, 3f);
                        mSkin.enabled = true;
                    }
                }
            }


            rbody.velocity = transform.forward * movespeed;

            transform.position = new Vector3(transform.position.x, spawnHeight, transform.position.z);
        }
    }
Example #20
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player" && isCollected == false)
     {
         playerHealth.AddHealth(healthUp);
         gameManager.HealthHUD();
         gameManager.AddPoints(5);
         isCollected = true;
         Destroy(this.gameObject, 0.25f);
     }
 }
Example #21
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag != "Player")
     {
         return;
     }
     if (playerHealth.AddHealth(healthAmmount))
     {
         pickupManager.UnpopulateSpawnPoint(pickupSpawnPoint);
         Destroy(gameObject);
     }
 }
Example #22
0
 public void Enable()
 {
     if (Functions.DeltaMax(player.position.x, theTransform.position.x, 4f) && Functions.DeltaMax(player.position.y, theTransform.position.y, 2f))
     {
         if (!used)
         {
             SpriteChange();
             custom.PlayClipAt(activateClip, theTransform.position);
             playerH.AddHealth();
         }
     }
 }
Example #23
0
    void OnTriggerEnter(Collider other)
    {
        // If the colliding gameobject is the player...
        if (other.gameObject == player)
        {
            // ... play the clip at the position of the key...
            AudioSource.PlayClipAtPoint(keyGrab, transform.position);

            playerHealth.AddHealth(25);

            // ... and destroy this gameobject.
            Destroy(gameObject);
        }
    }
Example #24
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            PlayerHealth playerHealth = PlayerController.CurrentPlayer.GetComponent <PlayerHealth>();

            if (playerHealth.CurrentHealth < playerHealth.maxHealth)
            {
                SoundsManager.CurrentManager.PlaySound(SoundsManager.HEART_SOUND);
                playerHealth.AddHealth(2);
                Destroy(gameObject);
            }
        }
    }
Example #25
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject == player)
        {
            audioSource.PlayOneShot(audioSource.clip);
            playerHealth.AddHealth(healthToAdd);

            spriteRenderer.enabled = false;

            GameManager.instance.DeregisterPowerUp();

            StartCoroutine(DestroyPowerUp());
        }
    }
Example #26
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         //Instantiate (explosion, transform.position, transform.rotation);
         print("Health");
         Destroy(gameObject);
         gameController.AddHealth();
     }
     else
     {
         return;
     }
 }
Example #27
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("HealthItem") && PlayerHealth.currentHealth < 100)
        {
            other.gameObject.SetActive(false);
            playerHealth.AddHealth(10);
        }

        else if (other.CompareTag("AmmoItem"))
        {
            weapon.GetComponent <Shoot>().AddAmmo(10);
            other.gameObject.SetActive(false);
        }
    }
Example #28
0
    //If the player is in range, start healing//
    public void OnTriggerEnter(Collider other)
    {
        //If the player is in range and health is less than full, and the stone can be used
        if (other.gameObject.CompareTag("Player") && playerHealth.currentHealth < playerHealth.maxHealth && recharging == false)
        {
            //Work out the difference
            float difference;
            difference = playerHealth.maxHealth - playerHealth.currentHealth;

            //Heal the player to full health, or +40
            if (difference >= 40)
            {
                playerHealth.AddHealth(40);
            }
            else if (difference < 40)
            {
                playerHealth.AddHealth(difference);
            }
            else if (difference == 0)
            {
                //Do nothing
            }

            //Update health slider
            healthSlider.value = playerHealth.currentHealth;

            //Dim the light
            light.intensity = 1f;

            //Coroutine for the notification
            StartCoroutine(DelayUI());

            //Coroutine for recharging
            StartCoroutine(Recharge());
        }
    }
Example #29
0
    private void OnTriggerEnter(Collider other)
    {
        PlayerHealth pHealth = other.gameObject.GetComponent <PlayerHealth>();

        if (!pHealth)
        {
            return;
        }
        if (pHealth.currentHealth >= pHealth.maxHealth)
        {
            return;
        }

        pHealth.AddHealth(Random.Range(minHealthToAdd, maxHealthToAdd));
        Destroy(gameObject);
    }
Example #30
0
    void CheckEaten(GameObject other)
    {
        var edible = other.GetComponent <Edible>();

        if (edible != null)
        {
            health.AddHealth(edible.healthValue);
            scoreManager.AddScore(edible.pointValue);
            scoreManager.AddMultiplier(edible.multiplierValue);

            if (managers != null)
            {
                managers.BroadcastMessage("OnEdibleEaten", edible.edibleType, SendMessageOptions.DontRequireReceiver);
            }
        }
    }
    private void LevelUp()
    {
        playerExp = playerExp - (playerLevel * 150);
        if (playerExp < 0)
        {
            playerExp = 0;
        }
        playerLevel++;
        playerExpRequired = playerLevel * 150;
        playerHealth.AddHealth(35);

        UpdatePlayerExperience();
        StartCoroutine(PlayerLevelUpText());
        playerLevelingUp = true;
        Invoke("StopLevelUpText", 6);
    }