少年修仙传客户端代码仓库
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
using System.Collections.Generic;
using UnityEngine;
 
public class BattleEffectPlayRule : Singleton<BattleEffectPlayRule>
{
    public List<uint> sortPlayerList = new List<uint>();
 
    private int limit
    {
        get
        {
            if (SystemSetting.Instance.GetCurrentQualityLevel() == GameQuality.High)
            {
                return 7;
            }
            else if (SystemSetting.Instance.GetCurrentQualityLevel() == GameQuality.Medium)
            {
                return 3;
            }
            else
            {
                return 0;
            }
        }
    }
 
    public float timeEscape;
 
    public void Update()
    {
        if (Time.realtimeSinceStartup - timeEscape > .5f)
        {
            GA_Hero _hero = PlayerDatas.Instance.hero;
            if (_hero == null)
            {
                return;
            }
 
            sortPlayerList.Sort((id1, id2) =>
            {
                GActor _actor1 = GAMgr.Instance.GetBySID(id1);
                GActor _actor2 = GAMgr.Instance.GetBySID(id2);
 
                float _dis1 = MathUtility.DistanceSqrtXZ(_hero.Pos, _actor1.Pos);
                float _dis2 = MathUtility.DistanceSqrtXZ(_hero.Pos, _actor2.Pos);
 
                return _dis2 > _dis1 ? -1 : 1;
            });
 
            timeEscape = Time.realtimeSinceStartup;
        }
    }
 
    public bool CanPlay(uint sid)
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        if (_hero == null)
        {
            return false;
        }
 
        // 选中英雄必显示
        if (_hero.SelectTarget != null)
        {
            if (_hero.SelectTarget.ServerInstID == sid
             || _hero.LockTarget.ServerInstID == sid)
            {
                return true;
            }
        }
 
        // 获取传入的玩家在排序后的队列中的索引
        int _index = sortPlayerList.IndexOf(sid);
 
        // 不存在可能是异常,不播放
        if (_index < 0)
        {
            return false;
        }
 
        // 在限定的数量内,允许播放
        if (_index < limit)
        {
            return true;
        }
 
        return false;
    }
}