

using System;
using FairyGUI;
using BingoBrain.Core;
using UnityEngine;

namespace BingoBrain
{
    public class RewardedVal
    {
        private static Jcna<RewardedVal> _pool = new Jcna<RewardedVal>();
        public static RewardedVal Get(int id, double sum)
        {
            return Get(id,sum,null);
        }
        public static RewardedVal Get(int id, double sum,Action<bool> finish)
        {        
            return Get(id,sum, GRoot.inst.size / 2,finish);
        }
 
        public static RewardedVal Get(int id, double sum,Vector2 pot,Action<bool> finish=null)
        {
            RewardedVal val = _pool.Get();
            val.Id = id;
            val.Sum = sum;
            val.StartPot = pot;
            val.IsPlayAudio = true;
            val.IsAddReadSum = true;
            val.onfinish = finish;
            return val;
        }

    
        public void Release()
        {
            Id = 0;
            Sum = 0;
            onfinish = null;
            IsMulti = false;
            cont_index = -1;
            IsPlayAudio = true;
            StartPot = GRoot.inst.size / 2;
            _pool.Release(this);
        }

        public RewardedVal()
        {

        }

        public Action<bool> onfinish;
        public Action<bool> onResult;

        public int Id { get; set; }
        public double Sum { get; set; }

        /// <summary>
        /// 是否翻倍
        /// </summary>
        public bool IsMulti { get; set; }
        /// <summary>
        /// 索引index
        /// </summary>
        public int cont_index { get; set; }

        public Vector2 StartPot;

        public bool IsPlayAudio=true;

        public bool IsAddReadSum = true;

    }
}