少年修仙传客户端代码仓库
client_linchunjie
2019-04-24 43ee67257bf7d93be63956dc89fc0d7ce9c4b074
6584 【2.0】【前端】定海神针认主
2个文件已修改
69 ■■■■■ 已修改文件
System/Treasure/ClientTreasureDungeonStage.cs 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Treasure/NormalDialogueWin.cs 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Treasure/ClientTreasureDungeonStage.cs
@@ -7,7 +7,7 @@
public class ClientTreasureDungeonStage : DungeonStage
{
    static readonly Vector3 PlayerBornPosition = new Vector3(24.496f, 0.048f, 8.258f);
    static readonly Vector3 NpcBornPosition = new Vector3(9.45f, 0.04f, 8.258f);
    static readonly Vector3 NpcBornPosition = new Vector3(7.5f, 0.04f, 8.02239f);
    bool initialized = false;
@@ -18,6 +18,8 @@
    static GA_NpcClientFunc m_Npc;
    Clock fightEndClock = null;
    bool npcClick = false;
    static bool IsCompleteDialogue = false;
@@ -45,9 +47,12 @@
        }
        IsCompleteDialogue = false;
        npcClick = true;
        NormalDialogueWin.onDialogueComplete -= OnDialogueComplete;
        NormalDialogueWin.onDialogueComplete += OnDialogueComplete;
        GlobalTimeEvent.Instance.secondEvent -= PerSecond;
        GlobalTimeEvent.Instance.secondEvent += PerSecond;
    }
    protected override void OnStageLoadFinish()
@@ -85,6 +90,7 @@
        NormalDialogueWin.dialogues = dialogues;
        NormalDialogueWin.speakTypes = speakTypes;
        NormalDialogueWin.npcId = dialogueNpcId;
        NormalDialogueWin.autoSeconds = 10;
        WindowCenter.Instance.Open<NormalDialogueWin>();
    }
@@ -101,6 +107,35 @@
        if (!IsCompleteDialogue)
        {
            ClientTreasureDungeon.RequestExit();
        }
    }
    private void PerSecond()
    {
        var hero = PlayerDatas.Instance.hero;
        if (hero == null || m_Npc == null)
        {
            return;
        }
        bool isAuto = hero.aiHandler != null && hero.aiHandler.IsAuto();
        if (!hero.IsIdle())
        {
            return;
        }
        var dis = MathUtility.DistanceSqrtXZ(m_Npc.Pos, hero.Pos);
        if (isAuto && dis <= 15f && !IsCompleteDialogue)
        {
            npcClick = false;
            hero.Behaviour.StopHandupAI(true);
            if (!WindowCenter.Instance.IsOpen<NormalDialogueWin>())
            {
                m_Npc.OnClick();
            }
        }
        if (dis <= 2f && !npcClick)
        {
            npcClick = true;
            m_Npc.OnClick();
        }
    }
@@ -127,6 +162,7 @@
        UnInitializedNpc();
        NPCInteractProcessor.s_NpcInteractEvent -= OnNpcTalkEvent;
        NormalDialogueWin.onDialogueComplete -= OnDialogueComplete;
        NormalDialogueWin.onDialogueComplete -= OnDialogueComplete;
        GlobalTimeEvent.Instance.secondEvent -= PerSecond;
    }
}
System/Treasure/NormalDialogueWin.cs
@@ -27,11 +27,17 @@
        [SerializeField] Text m_PlayerName;
        [SerializeField] Text m_PlayerDialogue;
        [SerializeField] Text m_Time;
        int dialogueIndex = 0;
        public static int npcId = 0;
        public static int[] speakTypes = null;
        public static string[] dialogues = null;
        public static int autoSeconds = 0;
        float timer = 0f;
        float displayTimer = 0f;
        public static event Action onDialogueComplete;
@@ -50,7 +56,10 @@
        {
            dialogueIndex = 0;
            timer = 0f;
            DisplayDialogue();
            DisplayTime();
        }
        protected override void OnAfterOpen()
@@ -72,6 +81,20 @@
        protected override void LateUpdate()
        {
            timer += Time.deltaTime;
            if (timer >= autoSeconds)
            {
                timer = 0f;
                OnClickEmpty();
            }
            displayTimer += Time.deltaTime;
            if (displayTimer >= 0.5f)
            {
                displayTimer = 0f;
                DisplayTime();
            }
            GA_Hero _hero = PlayerDatas.Instance.hero;
            if (_hero == null)
            {
@@ -136,6 +159,12 @@
            }
        }
        private void DisplayTime()
        {
            var seconds = (int)(autoSeconds - timer);
            m_Time.text = Language.Get("TaskContinueCount", seconds);
        }
        private void OnClickEmpty()
        {
            if (dialogues != null && dialogueIndex < dialogues.Length - 1)