using vnxbqy.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
public class ClientHazyDemonKingStage : DungeonStage
|
{
|
static readonly Vector3 playerBornPosition = new Vector3(10, 6.38f, 6.67f);
|
static readonly Vector3 bossBornPosition = new Vector3(8.35f, 6.37f, 9.7f);
|
|
static GA_NpcClientFightBoss s_ClientBoss = null;
|
|
float stepTimer = 0f;
|
float exitTime = 10f;
|
|
Step m_Step = Step.Fight;
|
public Step step
|
{
|
get { return m_Step; }
|
set
|
{
|
m_Step = value;
|
}
|
}
|
|
HazyDemonKingModel model { get { return ModelCenter.Instance.GetModel<HazyDemonKingModel>(); } }
|
HazyRegionModel hazyRegionModel { get { return ModelCenter.Instance.GetModel<HazyRegionModel>(); } }
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
|
public override void Initialize()
|
{
|
base.Initialize();
|
|
m_Step = Step.None;
|
|
dungeonModel.onDungeonResultEvent += OnDungeonResultEvent;
|
PersonalEnemy.OnNpcAppear += OnNpcAppear;
|
}
|
|
protected override void OnStageLoadFinish()
|
{
|
base.OnStageLoadFinish();
|
|
InitializePlayer();
|
InitializeBoss();
|
|
step = Step.Fight;
|
|
DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += PlayerLoginOkEvent;
|
}
|
|
public static uint GetClientBossSid()
|
{
|
if (s_ClientBoss != null)
|
{
|
return s_ClientBoss.ServerInstID;
|
}
|
return 0;
|
}
|
|
void InitializePlayer()
|
{
|
var hero = PlayerDatas.Instance.hero;
|
hero.Pos = playerBornPosition;
|
if (hero.Behaviour != null)
|
{
|
hero.Behaviour.StartHandupAI();
|
}
|
CameraController.Instance.Apply();
|
}
|
|
|
void InitializeBoss()
|
{
|
uint hp = 0;
|
uint hpEx = 0;
|
var position = bossBornPosition;
|
if (s_ClientBoss != null)
|
{
|
hp = (uint)(s_ClientBoss.ActorInfo.Hp % Constants.ExpPointValue);
|
hpEx = (uint)(s_ClientBoss.ActorInfo.Hp / Constants.ExpPointValue);
|
position = s_ClientBoss.Pos;
|
PersonalEnemy.Release(s_ClientBoss);
|
}
|
|
var incidentId = hazyRegionModel.GetIncidentId(ClientDungeonStageUtility.dungeonInfo.mapId, ClientDungeonStageUtility.dungeonInfo.lineId);
|
var config = HazyRegionConfig.Get(incidentId);
|
PersonalEnemy.Create((uint)config.npcId, E_ActorGroup.Enemy, position, hp, hpEx);
|
}
|
|
private void OnDungeonResultEvent()
|
{
|
step = Step.Settle;
|
dungeonModel.UpdateCoolDown(DungeonCoolDownType.LeaveMap, 10 * 1000);
|
}
|
|
private void OnNpcAppear(GA_NpcClientFightNorm _npc)
|
{
|
var incidentId = hazyRegionModel.GetIncidentId(ClientDungeonStageUtility.dungeonInfo.mapId, ClientDungeonStageUtility.dungeonInfo.lineId);
|
var config = HazyRegionConfig.Get(incidentId);
|
if (_npc.NpcConfig.NPCID == config.npcId)
|
{
|
s_ClientBoss = _npc as GA_NpcClientFightBoss;
|
}
|
}
|
|
|
private void PlayerLoginOkEvent()
|
{
|
if (step <= Step.Fight)
|
{
|
InitializeBoss();
|
}
|
}
|
|
public override void UnInitialize()
|
{
|
base.UnInitialize();
|
|
if (s_ClientBoss != null)
|
{
|
s_ClientBoss = null;
|
}
|
|
dungeonModel.onDungeonResultEvent -= OnDungeonResultEvent;
|
PersonalEnemy.OnNpcAppear -= OnNpcAppear;
|
DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= PlayerLoginOkEvent;
|
}
|
|
#if UNITY_EDITOR
|
private void OnGUI()
|
{
|
if (GUILayout.Button("Exit"))
|
{
|
ClientDungeonStageUtility.ExitNormalClientDungeon();
|
}
|
}
|
#endif
|
|
public enum Step
|
{
|
None,
|
Fight,
|
Settle,
|
}
|
}
|