River Jiang
2020-10-28 4fe7a27d965c1433c940d5b3eaa13930fa999621
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
using Core.Utilities;
using KTGMGemClient;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class TowerPrice : Singleton<TowerPrice>
{
    /// <summary>
    /// 场景内的基础Tower价格.
    /// </summary>
    public int baseTowerPrice = 10;
    /// <summary>
    /// 每购买成功一个Tower,需要增加的TowerPrice.
    /// </summary>
    public int addPriceTower = 0;
 
    /// <summary>
    /// 当前场景内动态TowerPrice.
    /// </summary>
    protected int currentTP = 0;
    protected int selfTpIdx = 0;
 
    /// <summary>
    /// 对手塔防的动态TowerPrice.
    /// </summary>
    protected int opponentTP = 0;
    protected int oppoTpIdx = 0;
 
    // Start is called before the first frame update
    void Start()
    {
        this.currentTP = this.baseTowerPrice;
        this.opponentTP = this.baseTowerPrice;
    }
 
    public int currentTowerPrice
    { 
        get { 
            return this.currentTP; 
        } 
    }
 
    public int opponentTowerPrice
    {
        get
        {
            return this.opponentTP;
        }
    }
 
    public void resetTowerPrice()
    {
        this.currentTP = this.baseTowerPrice;
        this.opponentTP = this.baseTowerPrice;
    }
 
    /// <summary>
    /// 场景内每购买成功一个Tower,基础购买价格需要增加的数据。
    /// </summary>
    public void onTowerBuySuccess( bool opponent = false )
    {
        if(opponent)
        {
            this.oppoTpIdx++;
            this.opponentTP = JsonDataCenter.GetGemCostFromIdx(oppoTpIdx) ;
        }
        else
        {
            this.selfTpIdx++;
            this.currentTP = JsonDataCenter.GetGemCostFromIdx(selfTpIdx);
        }
            
    }
 
}