/// ----------------------------------------------------------------------------------------------- /// <summary> /// 死亡 /// </summary> /// ----------------------------------------------------------------------------------------------- protected virtual void OnDied() { m_IsDead = true; //entityAnimator.SetTrigger("Dead"); enemyAudio.clip = deathClip; enemyAudio.Play(); hudPlayer.gameObject.SetActive(false); hudPlayer = null; SpawnManager.s_Instance.DestoryEnemy(gameObject); }
/// ----------------------------------------------------------------------------------------------------- /// <summary> /// 创建血条对象 /// </summary> /// ----------------------------------------------------------------------------------------------------- public HUDPlayer CreateHUDPlayerPrefab(Transform entity) { UnityEngine.Object obj = AssetManager.Get().GetResources("HUDPlayer"); GameObject hudgameobj = GameObject.Instantiate(obj) as GameObject; if (obj == null) { Debug.LogError("obj = null"); } hudgameobj.transform.parent = GetUICamera().transform; hudgameobj.transform.localScale = Vector3.one; HUDPlayer hud = hudgameobj.GetComponent <HUDPlayer>(); if (hud != null) { hud.Init(entity); } return(hud); }
/// ------------------------------------------------------------------------------------------------------------------------------ /// <summary> /// 刷新怪物 /// </summary> /// ------------------------------------------------------------------------------------------------------------------------------ void Spawn() { Npc pNpc = null; int i = Random.Range(0, spawnPoints.Count); GameObject pEnemy = Instantiate(enemy, spawnPoints[i].transform.position, spawnPoints[i].transform.rotation); HUDPlayer hud = HUDPlayerManager.Get().CreateHUDPlayerPrefab(pEnemy.transform); if (hud != null) { pNpc = pEnemy.GetComponent <Npc>(); if (pNpc != null) { pNpc.hudPlayer = hud; pNpc.SetPlayerWeapon(0); } } mapObjectList.Add(pEnemy); AIToolkit.AIEntity pAIEntity = pEnemy.AddComponent <AIToolkit.AIEntity> ().Init(null); AIToolkit.AIEnityManager.instance.AddEntity(pAIEntity); if (pNpc != null) { pNpc.SetAIEntity(pAIEntity); } }
protected override void OnDespawned() { mControl.CancelActions(); mControl.CancelRecall(); mControl.followAction.StopAction(); if(mHUD != null) { mHUD.DeInit(); mHUD = null; } base.OnDespawned(); }
protected override void SpawnStart() { mPlayerStats.InitResource(); state = EntityState.normal; mControl.SpawnStart(); if(summonDisplay != null) summonDisplay.SetActive(false); if(unsummonDisplay != null) unsummonDisplay.SetActive(false); mHUD = HUDInterface.instance.GetHUDPlayer(this); if(mHUD != null) { mHUD.Init(this); } }