少年修仙传客户端代码仓库
client_Wu Xijin
2019-04-16 fc714208ff3a320c3bb52bddd5ea3d91f647a206
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
using Snxxz.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
 
[XLua.LuaCallCSharp]
public class BuyItemPopModel : Singleton<BuyItemPopModel>
 
{
    public StoreConfig storeConfig { get; private set; }
 
    public void SetModel(int shopId)
    {
        storeConfig = StoreConfig.Get(shopId);
    }
 
    public Dictionary<int, int> vipBuyCntDict = new Dictionary<int, int>();
    public bool CheckIsVipBuy(StoreConfig model,out int curVipIndex,out int nextVipIndex)
    {
        vipBuyCntDict.Clear();
        curVipIndex = -1;
        nextVipIndex = -1;
        bool isVipBuy = false;
        if (model == null) return isVipBuy;
 
        if (model.VIPLV.Length < 2)
        {
            if (model.VIPLV[0] != 0)
            {
                isVipBuy = true;
            }
            else
            {
                isVipBuy = false;
            }
        }
        else
        {
            isVipBuy = true;
        }
 
        if(isVipBuy)
        {
            for (int i = model.VIPLV.Length-1; i > -1; i--)
            {
                vipBuyCntDict.Add(model.VIPLV[i], model.PurchaseNumber[i]);
            }
            int playerVip = PlayerDatas.Instance.baseData.VIPLv;
            for (int i = model.VIPLV.Length - 1; i > -1; i--)
            {
                if (model.VIPLV[i] > playerVip)
                {
                    nextVipIndex = i;
                }
                else if(model.VIPLV[i] <= playerVip)
                {
                    curVipIndex = i;
                    break;
                }
            }
 
        }
 
        return isVipBuy;
    }
 
    public bool CheckIsLimitBuyCnt(StoreConfig model,out int canBuyCnt,out int addBuyCnt)
    {
        canBuyCnt = 0;
        addBuyCnt = 0;
        if (model == null) return false;
 
        int[] canBuyNums = model.PurchaseNumber;
        int curVipIndex = -1;
        int nexVipIndex = -1;
        bool isVipBuy = CheckIsVipBuy(model, out curVipIndex, out nexVipIndex);
        if (isVipBuy)
        {
            if (curVipIndex != -1)
            {
                canBuyCnt = canBuyNums[curVipIndex];
            }
 
            if (nexVipIndex != -1)
            {
                addBuyCnt = canBuyNums[nexVipIndex] - canBuyCnt;
            }
            return true;
        }
        else
        {
            if (canBuyNums[0] != 0)
            {
                canBuyCnt = canBuyNums[0];
                return true;
            }
            else
            {
                return false;
            }
        }
    }
 
    public int GetCurBuyCnt(int buyCnt,int remainBuyCnt,out bool IsReachUpper)
    {
        int count = 0;
        IsReachUpper = false;
        if(remainBuyCnt == 0)
        {
            IsReachUpper = true;
            count = 0;
        }
        else
        {
            if(buyCnt <= remainBuyCnt)
            {
                count = buyCnt;
            }
            else
            {
                count = remainBuyCnt;
                IsReachUpper = true;
            }
        }
 
        if(count < 0)
        {
            count = 0;
        }
        return count;
    }
 
    public int GetRemainBuyCnt(int canBuyCnt,BuyShopItemLimit shopItemLimit,bool isVipBuy)
    {
        int haveBuyCnt = 0;
        if (shopItemLimit != null)
        {
            haveBuyCnt = shopItemLimit.BuyCnt;
        }
 
        if (canBuyCnt <= 0 && !isVipBuy)
        {
            canBuyCnt = 9999;
        }
        int remainCnt = canBuyCnt - haveBuyCnt;
        if (remainCnt >= 0)
        {
            return remainCnt;
        }
        else
        {
            return 0;
        }
    }
    public int GetBuyPrice(StoreConfig model,int buyCnt)
    {
        if (model == null) return 0;
 
        int buyItemPrice = model.MoneyNumber * buyCnt;
        return buyItemPrice;
    }
}