Ejemplo n.º 1
0
    //add health to player
    void AddHealthToPlayer(GameObject player)
    {
        HealthSystem hs = player.GetComponent <HealthSystem>();

        if (hs != null)
        {
            //restore hp to unit
            hs.AddHealth(RestoreHP);
        }
        else
        {
            Debug.Log("no health system found on GameObject '" + player.gameObject.name + "'.");
        }

        //show pickup effect
        if (pickupEffect != null)
        {
            GameObject effect = GameObject.Instantiate(pickupEffect);
            effect.transform.position = transform.position;
        }

        //play sfx
        if (pickupSFX != "")
        {
            GlobalAudioPlayer.PlaySFXAtPosition(pickupSFX, transform.position);
        }

        Destroy(gameObject);
    }
    public void GiveHealthToPlayer()
    {
        HealthSystem ph = target.GetComponent <HealthSystem>();

        if (ph != null && item != null)
        {
            ph.AddHealth(item.data);
        }
    }
Ejemplo n.º 3
0
        void DoTheMethod()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go == null)
            {
                return;
            }

            theScript.AddHealth(amount.Value);
        }
Ejemplo n.º 4
0
    /// <summary>
    /// 玩家增加血量
    /// </summary>
    /// <param name="player"></param>
    private void AddHealthToPlayer(GameObject player)
    {
        HealthSystem hs = player.GetComponent <HealthSystem>();

        //调用HealthSystem添加血量方法
        if (hs != null)
        {
            hs.AddHealth(RestoreHP);
        }
        else
        {
            Debug.Log(player.gameObject.name + "找不到HealthSystem组件!");
        }

        //播放音效
        if (pickupSFX != "")
        {
            GlobalAudioPlayer.PlaySFXAtPosition(pickupSFX, transform.position);
        }

        Destroy(gameObject);
    }
    private IEnumerator IHealAfterSeconds()
    {
        yield return(new WaitForSeconds(waitTime));

        healthSystem.AddHealth(healAmount);
    }
    /// <summary>
    /// Responsible for adding the health to the player.
    /// </summary>
    /// <param name="amount">Amount of experience to add</param>

    public void Heal(int amount)
    {
        healthSystem.AddHealth(amount);
        playerWindow.SetHP();
    }