少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using UnityEngine;
using vnxbqy.UI;
using System.Collections.Generic;
 
 
/// <summary>
/// 跑跑跑副本AI行为
/// 当追逐到终点的时候默认会回到起点从新开始选怪的逻辑
/// </summary>
public class HeroAI_D3_BackToStartPos : HeroAI_Auto
{
    private DungeonModel m_DungeonModel;
    private DungeonModel DgModel
    {
        get { return m_DungeonModel ?? (m_DungeonModel = ModelCenter.Instance.GetModel<DungeonModel>()); }
    }
 
    private Vector3 m_StartPos;
    private Vector3 m_EndPos;
    private bool m_DoingMovingToStart;
 
    #region 配置相关
    #endregion
 
    public sealed override bool Condition()
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        if (_hero == null)
        {
            return false;
        }
 
        if (_hero.aiHandler.currentType == E_HeroAIType.D3_BackToStartPos)
        {
            return true;
        }
 
        return base.Condition();
    }
 
    protected override void OnEnter()
    {
        m_LockTargetSID = 0;
        m_DoingMovingToStart = false;
 
        FuncConfigConfig func = FuncConfigConfig.Get("AI197Point");
        LitJson.JsonData _data = LitJson.JsonMapper.ToObject(func.Numerical1);
        foreach (var _key in _data.Keys)
        {
            if (_key.Equals(PlayerDatas.Instance.baseData.MapID.ToString()))
            {
                m_StartPos = new Vector3(((int)_data[_key][0][0] - GA_Hero.MapOffset.x) * .5f, 0, ((int)_data[_key][0][1] - GA_Hero.MapOffset.z) * .5f);
                m_EndPos = new Vector3(((int)_data[_key][1][0] - GA_Hero.MapOffset.x) * .5f, 0, ((int)_data[_key][1][1] - GA_Hero.MapOffset.z) * .5f);
            }
        }
 
        m_HandupRange = 10;
    }
 
    protected override bool OnUpdate()
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
 
        if (_hero == null)
        {
            return false;
        }
 
        float _chkDistSqrt;
        if (m_DoingMovingToStart)
        {
            _chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, m_StartPos);
            if (_chkDistSqrt > 1)
            {
                if (_hero.State != E_ActorState.AutoRun)
                {
                    m_StartPos.y = _hero.Pos.y;
                    _hero.MoveToPosition(m_StartPos);
                }
                return true;
            }
            m_DoingMovingToStart = false;
        }
        else
        {
            if (m_EndPos != Vector3.zero)
            {
                _chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, m_EndPos);
                if (_chkDistSqrt < 9)
                {
                    m_DoingMovingToStart = true;
                }
            }
        }
 
        return false;
    }
 
    protected sealed override void OnExit()
    {
    }
 
    public sealed override bool IsOver()
    {
        if (base.IsOver())
        {
            return true;
        }
 
        return PlayerDatas.Instance.hero.aiHandler.currentType
            != E_HeroAIType.D3_BackToStartPos;
    }
 
    protected sealed override GActorFight SelectTarget()
    {
        return DecideAttackTarget(PlayerDatas.Instance.hero.Pos,
                                  m_HandupRange);
    }
 
}