using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CoinNumControl
{
    private int mCoinNum =111110;//金币数量
    private int mWaterBottleNum = 0;//加速剂数量
    private int subAcceleratorsVideoNum = 0;//加速剂看视频次数
    private int acceleratorsVideoBottleNum = 0;//看视频给的加速剂数量
    private int subSeedVideoNum = 0;//种子不足看视频次数
    private int openRedPackNum = 5;//收获拆红包次数
    private int mAllFruitNum = 0;


    private static CoinNumControl instance;
    public static CoinNumControl GetIns()
    {
        if (instance == null)
        {
            instance = new CoinNumControl();
        }
        return instance;
    }
    //金币数量监听
    public delegate void OnCoinNumChangeDelegate(int newCoinNum);//也可以改成int等等
    public event OnCoinNumChangeDelegate OnVariableChange; //事件


    //增加金币===========================================================================================================================
    public int addMyCoin(int coinNum)
    {
        mCoinNum = mCoinNum + coinNum;
        OnVariableChange?.Invoke(mCoinNum);
        return mCoinNum;
    }
    //花费金币
    public int payMyCoin(int coinNum)
    {
        mCoinNum = mCoinNum - coinNum;
        OnVariableChange?.Invoke(mCoinNum);
        return mCoinNum;
    }
    //查看金币
    public int getMyCoin
    {
        get { return mCoinNum; }
        set
        {
            //if (mCoinNum == value) return;
            OnVariableChange?.Invoke(mCoinNum);
            mCoinNum = value;
        }
    }

    //增加加速剂===========================================================================================================================
    //public int addMyWaterBottle(int woterNum)
    //{
    //    mWaterBottleNum = mWaterBottleNum + woterNum;
    //    Debug.Log("addMyWaterBottle++" + woterNum + "mWaterBottleNum" + mWaterBottleNum);
    //    return mWaterBottleNum;
    //}
    //使用加速剂
    public int useMyWaterBottle()
    {
        mWaterBottleNum = mWaterBottleNum - 1;
        return mWaterBottleNum;
    }
    //查看加速剂数量
    public int getMyWaterBottle
    {
        set { mWaterBottleNum = value; }
        get { return mWaterBottleNum; }

    }
    //种子不足看视频数量===========================================================================================================================
    public int lookSeedsVideoNUm()
    {//看种子不足激励视频一次
        subSeedVideoNum = subSeedVideoNum - 1;
        return subSeedVideoNum;
    }
    //查看种子不足激励视频次数
    public int getSubSeedVideoNum
    {
        set { subSeedVideoNum = value; }
        get { return subSeedVideoNum; }
    }
    //加速剂不足看视频数量===========================================================================================================================
    public int lookAcceleratorsVideoNum()
    { //看加速剂不足激励视频一次
        subAcceleratorsVideoNum = subAcceleratorsVideoNum - 1;
        return subAcceleratorsVideoNum;
    }
    //查看加速剂不足激励视频次数
    public int getSubAcceleratorsVideoNum
    {
        set { subAcceleratorsVideoNum = value; }
        get { return subAcceleratorsVideoNum; }
    }
    //看视频给的加速剂数量用于显示弹窗===========================================================================================================================
    public int getAcceleratorsVideoBottleNum
    {
        set { acceleratorsVideoBottleNum = value; }
        get { return acceleratorsVideoBottleNum; }
    }

    //剩余收获次数===========================================================================================================================
    public int rewardRedPackReduce()
    { //收获一次减少一次
        openRedPackNum = openRedPackNum - 1;
        if (openRedPackNum < 0)
        {
            openRedPackNum = 0;
        }
        return openRedPackNum;
    }
    //还需几次收获
    public int getRemainRewardNum
    {
        set { openRedPackNum = value; }
        get { return openRedPackNum; }
    }
    //增加果实数===========================================================================================================================
    public int addMyAllFruit()
    {
        mAllFruitNum = mAllFruitNum + 1;
        return mAllFruitNum;
    }
    //查看总果实数
    public int getMyAllFruit
    {
        get { return mAllFruitNum; }
        set { mAllFruitNum = value; }
    }
}
