Exemplo n.º 1
0
 public static INemoControlIO Get()
 {
     if (mSingleton == null)
     {
         mSingleton = UnityEngine.Object.FindObjectOfType(typeof(NemoUsbHid_HardScan)) as NemoUsbHid_HardScan;
     }
     return(mSingleton);
 }
Exemplo n.º 2
0
 void Awake()
 {
     mArcIO = GameMain.Singleton.ArcIO;
     GameMain.EvtFishKilled += Handle_FishKilled;
     mFlashLightTag          = new bool[32];
 }
Exemplo n.º 3
0
    /// <summary>
    /// 即时退奖
    /// </summary>
    /// <remarks>Dat_PlayersScoreWon中值,可以退奖则扣下</remarks>
    /// <returns></returns>
    public IEnumerator _Coro_OutBountyImm()
    {
        if (mIsOutingBounty)
        {
            yield break;
        }

        BackStageSetting bss   = GameMain.Singleton.BSSetting;
        INemoControlIO   arcIO = GameMain.Singleton.ArcIO;

        int oneBountyNeedScore = 100000000;//防止出现bug不会退

        if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
        {
            oneBountyNeedScore = bss.InsertCoinScoreRatio.Val;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
        {
            oneBountyNeedScore = (int)(((float)bss.InsertCoinScoreRatio.Val) * bss.CoinTicketRatio_Coin.Val / bss.CoinTicketRatio_Ticket.Val);//投币比例(分/币) * 币票比(币/票) = 出一票需要多少分(分/票)
        }
        if (bss.Dat_PlayersScoreWon[Idx].Val < oneBountyNeedScore)
        {
            yield break;
        }

        mIsOutingBounty = true;

        //请求硬件扣币
        if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
        {
            arcIO.OutCoin(1, CtrllerIdx);
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
        {
            arcIO.OutTicket(1, CtrllerIdx);
        }


        bool  isBoutyOutted = false; //是否已出奖励
        float timeOut       = 10F;   //超时时间
        float elapse        = 0F;
        NemoCtrlIO_EventController outBountyreflect = (int cIdx) =>
        {
            if (CtrllerIdx == cIdx)
            {
                isBoutyOutted = true;
            }
        };

        if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
        {
            arcIO.EvtOutCoinReflect += outBountyreflect;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
        {
            arcIO.EvtOutTicketReflect += outBountyreflect;
        }


        while (!isBoutyOutted)
        {
            if (elapse > timeOut)// 超时
            {
                //显示退奖错误提示
                if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
                {
                    mGOViewingOutBountyHint = Instantiate(Prefab_OutBountyHints[2]) as GameObject;
                }
                else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
                {
                    mGOViewingOutBountyHint = Instantiate(Prefab_OutBountyHints[3]) as GameObject;
                }
                mGOViewingOutBountyHint.transform.parent        = transform;
                mGOViewingOutBountyHint.transform.localPosition = LocalOutBountyHint;
                mGOViewingOutBountyHint.transform.localRotation = Quaternion.identity;

                yield return(new WaitForSeconds(30F));

                mIsOutingBounty = false;
                StartCoroutine(_Coro_OutBountyImm());
                yield break;
            }
            elapse += Time.deltaTime;
            yield return(0);
        }

        //出币已应答
        if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
        {
            arcIO.EvtOutCoinReflect -= outBountyreflect;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
        {
            arcIO.EvtOutTicketReflect -= outBountyreflect;
        }



        //历史记录
        if (bss.OutBountyType_.Val == OutBountyType.OutCoinImmediate)
        {
            bss.His_CoinOut.Val     += 1;
            bss.His_GainCurrent.Val -= 1;
            bss.UpdateGainCurrentAndTotal();
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketImmediate)
        {
            bss.His_TicketOut.Val += 1;

            //所有玩家公用
            bss.TicketOutFragment.Val += 1;
            int outCoinNumBase = bss.TicketOutFragment.Val / bss.CoinTicketRatio_Ticket.Val;//出币基数,乘与CoinTicketRatio_Coin 得出应出多少个整币
            if (outCoinNumBase > 0)
            {
                bss.His_GainCurrent.Val   -= outCoinNumBase * bss.CoinTicketRatio_Coin.Val;
                bss.TicketOutFragment.Val -= bss.CoinTicketRatio_Ticket.Val;
            }
            bss.UpdateGainCurrentAndTotal();
        }
        if (bss.Dat_PlayersScoreWon[Idx].Val < oneBountyNeedScore)
        {
            Debug.LogError("[退奖错误]该扣分数大于玩家已赢分数.");
            yield break;
        }

        bss.Dat_PlayersScoreWon[Idx].Val = bss.Dat_PlayersScoreWon[Idx].Val - oneBountyNeedScore;
        if (GameMain.EvtPlayerWonScoreChanged != null)
        {
            GameMain.EvtPlayerWonScoreChanged(this, bss.Dat_PlayersScoreWon[Idx].Val);
        }
        //Ef_CoinStack.OneStack_SetNum(bss.Dat_PlayersScoreWon[Idx].Val);
        mIsOutingBounty = false;

        //是否可再扣分,可以则迭代
        if (bss.Dat_PlayersScoreWon[Idx].Val >= oneBountyNeedScore)
        {
            StartCoroutine(_Coro_OutBountyImm());
        }

        if (mGOViewingOutBountyHint != null)
        {
            Destroy(mGOViewingOutBountyHint);
            mGOViewingOutBountyHint = null;
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// 按键退币-协同
    /// </summary>
    /// <returns></returns>
    public IEnumerator _Coro_OutBountyButtom()
    {
        if (mIsOutingBounty)
        {
            yield break;
        }

        BackStageSetting bss   = GameMain.Singleton.BSSetting;
        INemoControlIO   arcIO = GameMain.Singleton.ArcIO;
        int oneBountyNeedScore = 100000000;//不会退

        if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
        {
            oneBountyNeedScore = bss.InsertCoinScoreRatio.Val;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
        {
            oneBountyNeedScore = (int)(((float)bss.InsertCoinScoreRatio.Val) * bss.CoinTicketRatio_Coin.Val / bss.CoinTicketRatio_Ticket.Val);  //投币比例(分/币) * 币票比(币/票) = 出一票需要多少分(分/票)
        }
        //检查是否够退一币
        if (bss.Dat_PlayersScore[Idx].Val < oneBountyNeedScore)
        {
            yield break;
        }

        //显示退奖中提示
        if (mGOViewingOutBountyHint == null)
        {
            if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
            {
                mGOViewingOutBountyHint = Instantiate(Prefab_OutBountyHints[0]) as GameObject;
            }
            else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
            {
                mGOViewingOutBountyHint = Instantiate(Prefab_OutBountyHints[1]) as GameObject;
            }
            mGOViewingOutBountyHint.transform.parent        = transform;
            mGOViewingOutBountyHint.transform.localPosition = LocalOutBountyHint;
            mGOViewingOutBountyHint.transform.localRotation = Quaternion.identity;
        }



        mScoreChangeLowest = (uint)oneBountyNeedScore;//设置分数改变下限,防止控制板返回消息时不能扣除
        mIsOutingBounty    = true;

        if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
        {
            arcIO.OutCoin(1, CtrllerIdx);
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
        {
            arcIO.OutTicket(1, CtrllerIdx);
        }

        bool  isBoutyOutted = false; //是否已出奖励
        float timeOut       = 10F;   //超时时间
        float elapse        = 0F;
        NemoCtrlIO_EventController outBountyreflect = (int cIdx) =>
        {
            if (CtrllerIdx == cIdx)
            {
                isBoutyOutted = true;
            }
        };

        if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
        {
            arcIO.EvtOutCoinReflect += outBountyreflect;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
        {
            arcIO.EvtOutTicketReflect += outBountyreflect;
        }
        while (!isBoutyOutted)
        {
            if (elapse > timeOut)
            {
                StartCoroutine(_Coro_OutBountyErrorView()); //显示故障
                mIsOutingBounty    = false;
                mScoreChangeLowest = 0;                     //恢复改变分数下限
                yield break;
            }
            elapse += Time.deltaTime;
            yield return(0);
        }

        //出币已应答
        if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
        {
            arcIO.EvtOutCoinReflect -= outBountyreflect;
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
        {
            arcIO.EvtOutTicketReflect -= outBountyreflect;
        }
        mIsOutingBounty    = false;
        mScoreChangeLowest = 0;//恢复改变分数下限

        //历史记录
        if (bss.OutBountyType_.Val == OutBountyType.OutCoinButtom)
        {
            bss.His_CoinOut.Val     += 1;
            bss.His_GainCurrent.Val -= 1;
            bss.UpdateGainCurrentAndTotal();
        }
        else if (bss.OutBountyType_.Val == OutBountyType.OutTicketButtom)
        {
            bss.His_TicketOut.Val += 1;

            //所有玩家公用
            bss.TicketOutFragment.Val += 1;
            int outCoinNumBase = bss.TicketOutFragment.Val / bss.CoinTicketRatio_Ticket.Val;//出币基数,乘与CoinTicketRatio_Coin 得出应出多少个整币
            if (outCoinNumBase > 0)
            {
                bss.His_GainCurrent.Val   -= outCoinNumBase * bss.CoinTicketRatio_Coin.Val;
                bss.TicketOutFragment.Val -= bss.CoinTicketRatio_Ticket.Val;
            }
            bss.UpdateGainCurrentAndTotal();
        }

        ChangeScore(-oneBountyNeedScore);

        //是否可再扣分,可以则迭代
        if (bss.Dat_PlayersScore[Idx].Val >= oneBountyNeedScore)
        {
            StartCoroutine(_Coro_OutBountyButtom());
        }
        else//退出迭代
        {
            if (mGOViewingOutBountyHint != null)
            {
                Destroy(mGOViewingOutBountyHint);
                mGOViewingOutBountyHint = null;
            }
        }
    }
Exemplo n.º 5
0
    public HotFileDbFRAMIO(string key, string filePath)
    {
        if (GameMain.Singleton != null)
        {
            mMCU = GameMain.Singleton.ArcIO;
        }
        if (mMCU == null)
        {
            mMCU = INemoControlIOSinglton.Get();
        }
        //?????????????
        if (mConn == null)
        {
            if (DataBaseName == "")
            {
                DataBaseName = "GameDB.db";
            }

            string dataPath = System.Environment.CurrentDirectory + "/DataFiles";
            if (!Directory.Exists(dataPath))
            {
                Directory.CreateDirectory(dataPath);
            }


            mConn = new SqliteConnection("Data Source = DataFiles/" + DataBaseName + ";");
            mConn.Open();

            if (mCMD == null)
            {
                mCMD = mConn.CreateCommand();
                mCMD.Parameters.Add(new SqliteParameter());
            }

            mCMD.CommandText = "PRAGMA journal_mode =wal;";//wal??
            mCMD.ExecuteNonQuery();
        }



        mKey    = key;
        mDBType = GetDBType();
        //bool isInitFRAMByDB = false;
        //?????DB_FARM_ID
        if (mMCU.IsOpen() && DB_ID == System.Guid.Empty)
        {
            using (SqliteCommand cmd = mConn.CreateCommand())
            {
                cmd.CommandText = "CREATE TABLE IF NOT EXISTS _DB_GUID(Val BLOB);";
                //cmd.Parameters.Add("@data", System.Data.DbType.Binary).Value = System.Guid.Empty.ToByteArray();
                cmd.ExecuteNonQuery();
                cmd.CommandText = string.Format(" SELECT * FROM _DB_GUID;");
                SqliteDataReader r = cmd.ExecuteReader();
                r.Read();

                if (r.HasRows)//????????????????
                {
                    //???????????guid?
                    DB_ID = new System.Guid(r.GetValue(0) as byte[]);
                    //???FRAM??guid?
                    byte[] guidFRAMByte = null;
                    if (mMCU.Read_Block(0, 16, out guidFRAMByte))//??FRAM???guid???
                    {
                        System.Guid FRAMEGUID = new System.Guid(guidFRAMByte);
                        if (FRAMEGUID != DB_ID)                                      //FRAM??db??guid?????
                        {
                            mMCU.RequestReadWrite(true, 0, 16, DB_ID.ToByteArray()); //??dbid§Õ??FRAM
                            IsInitFRAMByDB = true;
                        }
                    }
                    r.Close();
                }
                else//?????????guid
                {
                    r.Close();
                    //??????dbGUID
                    DB_ID = System.Guid.NewGuid();
                    byte[] guidByteNew = DB_ID.ToByteArray();
                    //????db
                    cmd.CommandText = "INSERT INTO _DB_GUID VALUES (@data)";
                    cmd.Parameters.Add("@data", System.Data.DbType.Binary).Value = guidByteNew;
                    cmd.ExecuteNonQuery();

                    //?????????guid ????FRAM
                    mMCU.RequestReadWrite(true, 0, 16, guidByteNew);
                    IsInitFRAMByDB = true;
                }
            }
        }


        //??????(4294967295 == 0xffffffff)
        mCMD.CommandText = string.Format("CREATE TABLE IF NOT EXISTS {0:s}(Val {1:s} KEY DEFAULT {2:s},Address INTEGER DEFAULT 4294967295,Length INTEGER DEFAULT {3:d});", mKey, GetDBTypeString(), GetDefaultDBValString(), GetValLength());
        mCMD.ExecuteNonQuery();


        //???????????????
        mCMD.CommandText = string.Format(" SELECT * FROM {0:s};", mKey);
        SqliteDataReader reader = mCMD.ExecuteReader();

        reader.Read();

        //
        //System.Guid.NewGuid();

        if (reader.HasRows)//????????????????
        {
            //????????????????????????
            mAddress    = (uint)reader.GetInt64(1);
            mDataLength = (byte)reader.GetInt32(2);
            if (IsInitFRAMByDB)
            {
                WriteToFRAM(ObjectToVal(reader.GetValue(0)));
            }
            reader.Close();
        }
        else//????????????????,????????
        {
            mAddress    = CurrentUseAddress;
            mDataLength = (byte)GetValLength();
            reader.Close();

            //???????????
            mCMD.CommandText   = string.Format("INSERT INTO {0:s} VALUES({1:s},{2:d},{3:d})", mKey, GetDefaultDBValString(), mAddress, mDataLength);
            CurrentUseAddress += GetValLength();//???????
            mCMD.ExecuteNonQuery();

            //?????farm
            WriteToFRAM(GetDefaultVal());
        }

        mUpdateSQLText = "UPDATE " + mKey + " SET Val = ?;";

        ++SqliteConnRefCount;
        HotFileDBIOReleaser.HotFileDBReg(this);
        HotFileDBFRAM_Updater.Reg(this);
    }
Exemplo n.º 6
0
 public static INemoControlIO Get()
 {
     if (mSingleton == null)
         mSingleton = UnityEngine.Object.FindObjectOfType(typeof(NemoUsbHid_HardScan)) as NemoUsbHid_HardScan;
     return mSingleton;
 }
Exemplo n.º 7
0
 void Awake()
 {
     mArcIO = GameMain.Singleton.ArcIO;
     GameMain.EvtFishKilled += Handle_FishKilled;
     mFlashLightTag = new bool[32];
 }