hch
2025-08-28 16a90aa94d8579cc120c9962d389b59bda5e7398
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
121
122
123
124
125
126
127
128
129
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
using System.Collections.Generic;
using System;
 
//用于记录主界面的一些信息
 
public class PlayerMainDate : GameSystemManager<PlayerMainDate>
{
    public event Action AddPowerEvent;
 
 
    //-------用于每分钟经验的获取
    public delegate void OnExperience(int _source, int _ExpPoint, int _Exp);//(1.单位经验亿点,2.经验单位点)
    public static event OnExperience Event_Experience;
 
    //--------------------用于战斗力滚动
 
    public long prowNum = 0;
    public long prowNumChange = 0;
    public bool isAdd = true;//为true增加 为false减少
    private bool prowBool = true;
 
    public event Func<bool> customDisplayPower;
 
    public override void Init()
    {
        DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
    }
 
 
    public override void Release()
    {
        DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
    }
 
 
 
    public void OnBeforePlayerDataInitialize()
    {
        prowNum = 0;
        prowNumChange = 0;
        prowBool = true;
        
    }
 
 
    public void PowerAdd(long power)
    {
        if (prowBool)
        {
            prowNum = power;
            prowBool = false;
        }
        else
        {
            if (power != prowNum)
            {
                prowNumChange = power - prowNum;
                prowNum = power;
                isAdd = prowNumChange > 0;
                prowNumChange = Math.Abs(prowNumChange);
                if (customDisplayPower != null && customDisplayPower())
                {
                    return;
                }
                if (UIManager.Instance.IsOpened<PowerAddWin>())
                {
                    AddPowerEvent?.Invoke();
                    return;
                }
                UIManager.Instance.OpenWindow<PowerAddWin>();
            }
            else
            {
                prowNum = power;
            }
        }
    }
 
    // public void CustomPowerUp(ulong nowPower ,ulong addPower)
    // {
    //     prowNum = (long)nowPower;
    //     prowNumChange = (long)addPower;
    //     isAdd = true;
    //     if (UIManager.Instance.IsOpened<PowerAddWin>())
    //     {
    //         AddPowerEvent?.Invoke();
    //         return;
    //     }
    //     UIManager.Instance.OpenWindow<PowerAddWin>();
    // }
 
    /// <summary>
    /// 武将自身的战力变化
    /// </summary>
    /// <param name="hero"></param>
    public void AddPowerNotOnTeam(HeroInfo hero)
    {
        if (HeroUIManager.Instance.lastFightPower.Key != hero.itemHero.guid)
        {
            return;
        }
 
        if (hero.IsInTeamByTeamType(TeamType.Story))
        { 
            return;
        }
 
        prowNumChange = hero.CalculatePower() - HeroUIManager.Instance.lastFightPower.Value;
        HeroUIManager.Instance.lastFightPower = new KeyValuePair<string, long>();
        isAdd = prowNumChange > 0;
        prowNumChange = Math.Abs(prowNumChange);
        prowNum = hero.CalculatePower();
        if (UIManager.Instance.IsOpened<PowerAddWin>())
        {
            AddPowerEvent?.Invoke();
            return;
        }
        UIManager.Instance.OpenWindow<PowerAddWin>();
    }
}