Пример #1
0
 // Use this for initialization
 void Start()
 {
     mHPProgressBar = BloodProgress.CreateBloodProgress(this.gameObject, new Vector3(0, 4, 0));
     if (mHPProgressBar != null)
     {
         mHPProgressBar.SetValue(mHP / mMaxHP);
         mHPProgressBar.SetText(mHP + "/" + mMaxHP);
     }
     mCharacter = gameObject.GetComponent <CharacterController>();
     mAnimation = gameObject.GetComponent <Animation>();
     mAnimation.Play("ZhanLi_TY");
 }
Пример #2
0
    /// <summary>
    /// 主角受到攻击
    /// </summary>
    /// <param name="hurt"></param>
    public void GetHit(float hurt)
    {
        mHP -= hurt;
        if (mHPProgressBar != null)
        {
            mHPProgressBar.SetValue(mHP / mMaxHP);
            mHPProgressBar.SetText(Mathf.Max(mHP, 0) + "/" + mMaxHP);
        }

        if (mHP <= 0)
        {
            BloodProgress.DestoryBloodProgress(mHPProgressBar);
            mDeath = true;
            mAnimation.Play("SiWang_JJ");
            GameManager.sGameManager.DestoryPlayer(mAnimation["SiWang_JJ"].length);
            GameManager.sGameManager.PlayerPosition = transform.position;
        }
    }
Пример #3
0
    /// <summary>
    /// 受到攻击
    /// </summary>
    /// <param name="hurt"></param>
    public void GetHit(float hurt)
    {
        mHP -= hurt;
        if (mHPProgressBar != null)
        {
            mHPProgressBar.SetValue(mHP / mMaxHP);
            mHPProgressBar.SetText(Mathf.Max(mHP, 0) + "/" + mMaxHP);
        }

        if (mHP <= 0)
        {
            BloodProgress.DestoryBloodProgress(mHPProgressBar);
            NPCUIList.sNPCUIList.DestoryChildByRef(this.gameObject);
            mDeath = true;
            mAnimation.Play("SiWang");
            MonsterManager.sMonsterManager.DestoryMonster(mAnimation["SiWang"].length, gameObject);
        }
    }
Пример #4
0
    /// <summary>
    /// 全局创建一个血条
    /// </summary>
    /// <returns></returns>
    public static BloodProgress CreateBloodProgress(GameObject target, Vector3 offset)
    {
        GameObject obj = UIManager.sUIManager.GetUiInstance("UI/Prefab/ProgressBar", target.transform.position + offset, Quaternion.identity);

        if (obj == null)
        {
            return(null);
        }

        BloodProgress bar = obj.GetComponent <BloodProgress>();

        if (bar == null)
        {
            return(null);
        }

        bar.SetTarget(target);
        bar.SetFollowOffset(offset);
        return(bar);
    }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        mAnimation     = gameObject.GetComponent <Animation>();
        mCharacter     = gameObject.GetComponent <CharacterController>();
        mStartPosition = transform.position;
        mHPProgressBar = BloodProgress.CreateBloodProgress(this.gameObject, new Vector3(0, 5, 0));
        if (mHPProgressBar != null)
        {
            mHPProgressBar.SetValue(mHP / mMaxHP);
            mHPProgressBar.SetText(Mathf.Max(mHP, 0) + "/" + mMaxHP);
        }
        mWanderRadius = 15f;
        mChaseRadius  = 20f;
        mAttackRadius = 7f;
        mMaxDistance  = 30f;
        mResetTime    = 2f;

        mMoveSpeed = 300f;
        mState     = MonsterState.WALK;
        NPCInfoController.CreateInfoItem("大龙怪物", "whiteper", mMaxHP, this.gameObject);
    }
Пример #6
0
 /// <summary>
 /// 销毁一个血条
 /// </summary>
 /// <param name="progress"></param>
 public static void DestoryBloodProgress(BloodProgress progress)
 {
     Destroy(progress.gameObject);
 }