예제 #1
0
        protected override TimeSpan[] TimesToProcess() => new[] { new TimeSpan(12, 0, 0) }; //run right at 10 AM why not

        public override async Task Run(DateTime startDate, DateTime endDate)
        {
            Logger.Debug("Running Game Odds Import");

            List <GameOdds> gameOdds = new List <GameOdds>();


            //Get Data From API
            using (HttpClient client = new HttpClient())
            {
                //client.DefaultRequestHeaders.Add("Authorization", "Basic ZGV2OmRldg==");
                //client.DefaultRequestHeaders.Add("x-api-key", ApiKey);
                HttpResponseMessage response = await client.GetAsync("https://jsonodds.com/api/test/odds");

                if (!response.IsSuccessStatusCode)
                {
                    return;
                }
                var jsonString = response.Content.ReadAsStringAsync().Result;
                gameOdds.AddRange(GameOdds.FromJson(jsonString));
            }


            _writeDb.UpdateGameOdds(gameOdds);
        }
예제 #2
0
    /// <summary>
    ///  一子弹获得分值
    /// </summary>
    /// <returns>获得分值</returns>
    int _OneBulletGetScore(int bulletScore, FishSim fishFirst, List <FishSim> allFish)
    {
        List <FishSim> fishDieList = new List <FishSim>();
        //鱼死亡
        //排除第一条鱼外的鱼数目
        //bool hitOnlyOne = allFish.Count == 1;//只击中一条鱼

        int oddsTotal = 0;

        foreach (FishSim f in allFish)
        {
            oddsTotal += f.Odds;
        }
        //第一条死亡几率
        //float firstDieRatio = (1F - GameOdds.GainRatio) * fishFirst.Odds / oddsTotal  / fishFirst.Odds;
        float firstDieRatio = (1F - GameOdds.GainRatio) * (fishFirst.Odds + oddsTotal) / (2F * oddsTotal * fishFirst.Odds);

        //Debug.Log("firstDieRatio = " + firstDieRatio + "    odds =" + fishFirst.Odds);
        if (GameOdds.IsHitInOne(firstDieRatio))//第一条鱼命中
        {
            fishDieList.Add(fishFirst);
            //Debug.Log("firstDieRatio = " + firstDieRatio+"    odds ="+fishFirst.Odds);
            //求其他鱼死是否死亡
            //先排除第一条鱼
            List <FishSim> fishOthers = new List <FishSim>();
            for (int i = 0; i != allFish.Count; ++i)
            {
                FishSim fo = allFish[i];
                if (fishFirst != fo)
                {
                    fishOthers.Add(fo);
                }
            }

            //逐条计算几率
            foreach (FishSim f in fishOthers)
            {
                //float dieRatio = (1F  - GameOdds.GainRatio - firstDieRatio * fishFirst.Odds) / (firstDieRatio * f.Odds * fishOthers.Count);
                //float dieRatio = (1F - GameOdds.GainRatio - firstDieRatio * fishFirst.Odds) / (firstDieRatio * oddsTotal);
                float dieRatio = (1F - GameOdds.GainRatio - firstDieRatio * fishFirst.Odds) / (firstDieRatio * /* f.Odds **/ (oddsTotal - fishFirst.Odds));
                //Debug.Log("otherDieRatio = " + dieRatio + "    odds =" + f.Odds);
                if (GameOdds.IsHitInOne(dieRatio))
                {
                    fishDieList.Add(f);
                }
            }
        }

        int scoreTotalGetted = 0;

        foreach (FishSim fDie in fishDieList)
        {
            int numGetted = fDie.Odds * bulletScore;
            scoreTotalGetted += numGetted;
        }
        return(scoreTotalGetted);
    }
예제 #3
0
    /// <summary>
    /// 测试鱼死亡几率 是否符合目标赔率
    /// </summary>
    void Test_FishDieRatio()
    {
        ulong scoreUsed   = 0;
        ulong scoreGetted = 0;
        ulong oneShootUse = 100;

        long ScoreInit   = 50000000;
        long ScoreHaving = ScoreInit;

        uint NumScoreInitX2 = 0;
        uint NumScoreZero   = 0;

        //for (int numScoreTest = 0; numScoreTest != 100; ++numScoreTest)
        //{
        for (int i = 0; i != 10000000; ++i)    //发射数目
        {
            //生成鱼
            FishOddsData        fishFirst = new FishOddsData(0, 2); //Random.Range(2, 3) );
            List <FishOddsData> otherFish = new List <FishOddsData>();
            int numRndHitFish             = 1;                      // Random.Range(0, 3);
            for (int j = 0; j != numRndHitFish; ++j)
            {
                otherFish.Add(new FishOddsData(0, 50));    // Random.Range(2, 3) ));
            }
            //allFishList.Add(new FishOddsData(2));
            //allFishList.Add(new FishOddsData(300));

            scoreUsed   += oneShootUse;
            ScoreHaving -= (long)oneShootUse;
            List <FishOddsData> fishKilled = GameOdds.OneBulletKillFish((int)oneShootUse, fishFirst, otherFish);
            ulong curGainTotal             = 0;
            foreach (FishOddsData fod in fishKilled)
            {
                curGainTotal += oneShootUse * (ulong)fod.Odds;
            }

            scoreGetted += curGainTotal;
            ScoreHaving += (long)curGainTotal;

            //if (ScoreHaving >= ScoreInit * 2)
            //{
            //    //Debug.Log("ScoreHave >= 600000");
            //    ++NumScoreInitX2;
            //    break;
            //}
            //if (ScoreHaving <= 0)
            //{
            //    ++NumScoreZero;
            //    break;
            //}
        }
        //    ScoreHaving = ScoreInit;
        //}

        Debug.Log(string.Format("x2 = {0:d} zero = {1:d}", NumScoreInitX2, NumScoreZero));
        Debug.Log(string.Format("scoreUsed = {0:d}  scoreGetted =  {1:d}  SceneWin =  {2:d}  ScoreHaving = {3:d}", scoreUsed, scoreGetted, (long)(scoreUsed - scoreGetted), ScoreHaving));
    }
예제 #4
0
    /// <summary>
    ///  一子弹获得分值
    /// </summary>
    /// <returns>获得分值</returns>
    public static List <FishOddsData> OneBulletKillFish(int bulletScore, FishOddsData fishFirst, List <FishOddsData> otherFish)
    {
        List <FishOddsData> fishDieList = new List <FishOddsData>();
        //鱼死亡
        int oddsTotal = fishFirst.Odds;

        if (fishFirst.Odds <= 1)
        {
            Debug.LogWarning("第一条鱼的odd小于等于一的话就怪了,暂时不可能存在这样的鱼!!,(全屏或者类型炸弹同事出两个可能会出现这种情况)");
            return(fishDieList);
        }
        foreach (FishOddsData f in otherFish)
        {
            if (f.Odds <= 1)
            {
                Debug.LogWarning("otherFish的odd小于等于一的话就怪了,暂时不可能存在这样的鱼!!");
                //return fishDieList;
            }

            oddsTotal += f.Odds;
        }
        //Debug.Log("oddsTotal = " + oddsTotal);

        float gainRatio = GameOdds.GainRatio;

        if (gainRatio > 0F && oddsTotal >= mReduceGainOddLine)
        {
            gainRatio *= GainRatioConditFactor;
        }

        //第一条死亡几率
        float firstDieRatio = (1F - gainRatio) * (fishFirst.Odds + oddsTotal) / (2F * oddsTotal * fishFirst.Odds);

        //Debug.Log("2F * oddsTotal * fishFirst.Odds = " + firstDieRatio);
        //Debug.Log("firstDieRatio = " + firstDieRatio + "    odds =" + fishFirst.Odds);
        if (GameOdds.IsHitInOne(firstDieRatio))//第一条鱼命中
        {
            fishDieList.Add(fishFirst);
            //Debug.Log("firstDieRatio = " + firstDieRatio+"    odds ="+fishFirst.Odds);
            //求其他鱼死是否死亡 ,逐条计算几率
            foreach (FishOddsData f in otherFish)
            {
                float dieRatio = (1F - gainRatio - firstDieRatio * fishFirst.Odds) / (firstDieRatio * (oddsTotal - fishFirst.Odds));
                //Debug.Log("otherDieRatio = " + dieRatio + "    odds =" + f.Odds);
                if (GameOdds.IsHitInOne(dieRatio))
                {
                    fishDieList.Add(f);
                }
            }
        }

        return(fishDieList);
    }
예제 #5
0
 public static ColumnValuePair[] CreateColumnValuePairs(this GameOdds odd, int gameId)
 {
     return(new[]
     {
         ColumnValuePair.Create(new ForegnKeyTableColumn(DbRepository.GameOddsTable, DbRepository.GamesTable, "Id").ColumnName, gameId),
         ColumnValuePair.Create(new ForegnKeyTableColumn(DbRepository.GameOddsTable, DbRepository.BookersTable, "Id").ColumnName, odd.Bookkeeper.Id),
         ColumnValuePair.Create(nameof(GameOdds.HomeOdd), odd.HomeOdd),
         ColumnValuePair.Create(nameof(GameOdds.DrawOdd), odd.DrawOdd),
         ColumnValuePair.Create(nameof(GameOdds.AwayOdd), odd.AwayOdd),
         ColumnValuePair.Create(nameof(GameOdds.IsValid), odd.IsValid)
     });
 }
예제 #6
0
    /// <summary>
    /// 测试频率和概率关系
    /// </summary>
    void Test_PropAndFreque()
    {
        const int NumTest        = 1000;
        int       numTestCurrent = 0;
        int       numHitted      = 0;

        while (numTestCurrent++ < NumTest)
        {
            if (GameOdds.IsHitInOne2(0.1F))
            {
                ++numHitted;
            }
        }
        Debug.Log("hit rate = " + ((float)numHitted / NumTest));
    }
예제 #7
0
 public static GameEvent GetEvent(GameOdds gameOdds) => new GameEvent
 {
     Id            = gameOdds.Id,
     HomeTeam      = gameOdds.HomeTeam ?? string.Empty,
     AwayTeam      = gameOdds.AwayTeam ?? string.Empty,
     Sport         = gameOdds.Sport,
     MatchTime     = gameOdds.MatchTime.ToString(),
     Details       = gameOdds.Details ?? string.Empty,
     HomePitcher   = gameOdds.HomePitcher ?? string.Empty,
     AwayPitcher   = gameOdds.AwayPitcher ?? string.Empty,
     HomeRot       = gameOdds.HomeRot ?? string.Empty,
     AwayRot       = gameOdds.AwayRot ?? string.Empty,
     League        = gameOdds.League?.Name ?? string.Empty,
     DisplayLeague = gameOdds.DisplayLeague ?? string.Empty
 };
예제 #8
0
    /// <summary>
    /// 测试gameOdds内的函数ishitInone
    /// </summary>
    void Test_GameOddsFunction_IsHitInOne()
    {
        float tarHitRate = 0.0002061856f;
        ulong numTar     = 10000000;
        ulong numHitted  = 0;

        for (ulong i = 0; i != numTar; ++i)
        {
            if (GameOdds.IsHitInOne(tarHitRate))
            {
                ++numHitted;
            }
        }

        Debug.Log("tarHItRate = " + tarHitRate + "   realHitRate = " + numHitted);
    }
예제 #9
0
    //测试起伏几率
    void Test_WinProperation()
    {
        const int numTestOri = 10000;
        int       numTest    = numTestOri; //测试次数\
        const int scoreOri   = 100;
        const int fishOdd    = 100;

        int numPassTest = 0;

        while (numTest-- > 0)
        {
            //一次测试
            int score    = scoreOri;
            int numTest2 = scoreOri;
            while (numTest2-- > 0 && score-- > 0)
            {
                if (GameOdds.IsHitInOne2(1F / fishOdd))//打死一百倍鱼
                {
                    score += fishOdd;
                    //Debug.Log("hitted");
                }


                //if (score >= scoreOri + fishOdd * 10)
                //{
                //    ++numPassTest;
                //    break;
                //}
            }
            if (score >= scoreOri + 100)
            {
                ++numPassTest;
            }
        }


        Debug.Log("p = " + ((float)numPassTest / numTestOri));
    }
예제 #10
0
        public void MailNewBet(GameOdds game, Register bet)
        {
            _composer.AppendText("p", $"New bet from: <b>{bet.Username}</b>");
            _composer.AppendText("p", $"<b>{game.Player1} vs {game.Player2}</b> - {game.Start.ToString("dd-MM-yyyy hh:mm")}");
            if (bet.BetPlayer == 1)
            {
                _composer.AppendText("p", $"Bet on: <b>{game.Player1}</b>");
            }
            else
            {
                _composer.AppendText("p", $"Bet on: <b>{game.Player2}</b>");
            }
            _composer.AppendText("p", $"Bet amount: <b>{bet.BetAmt.ToString("#,##0")}</b>");
            _composer.AppendText("p", "With:");
            _composer.AppendText("p", $"Handicap: <b>{Math.Round(bet.RefOdds1, 3)} | {Math.Round(bet.RefOdds2, 3)}</b>");
            _composer.AppendText("p", $"H/A: <b>{Math.Round(bet.RefWin1, 3)} | {Math.Round(bet.RefWin2, 3)}</b>");
            _composer.AppendText("br", string.Empty);
            _composer.AppendText("p", $"Bet more at: {_options.Ad}");
            _composer.AppendText("p", "Thanks for playing :D");

            var mail = new MailMessage()
            {
                From       = CreateMailAddress(_options.Username),
                IsBodyHtml = true,
                Body       = _composer.ToString(),
                Subject    = "Bet confirmed"
            };

            //Add receivers
            foreach (var address in _options.Receivers.Select(r => CreateMailAddress(r)))
            {
                mail.To.Add(address);
            }
            //CC bet owner
            mail.CC.Add(CreateMailAddress(bet.Username));
            _queue.Enqueue(mail);
        }
예제 #11
0
    static void Process_FreezeBomb(Bullet b, Fish fishFirst)
    {
        //Debug.Log("Process_FreezeBomb");
        if (!fishFirst.Attackable)
        {
            return;
        }
        //GameMain gm = GameMain.Singleton;
        //Transform bulletTs = b.transform;
        Player bulletOwner      = b.Owner;
        bool   IsLockFishBullet = b.IsLockingFish;


        //计算击中炸弹是否爆炸
        int          oddForDieRatio = GetFishOddForDieRatio(bulletOwner, b, fishFirst, fishFirst);
        FishOddsData freezeBomb     = new FishOddsData(0, oddForDieRatio);//fishFirst.Odds + GetFishOddForDieRatio(bulletOwner, b, fishFirst,fishFirst));//用于赔率计算

        List <FishOddsData> lstBombDie = GameOdds.OneBulletKillFish(b.Score, freezeBomb, new List <FishOddsData>());

        if (Evt_Hit != null)
        {
            Evt_Hit(oddForDieRatio == 0 ? true : false, bulletOwner, b, fishFirst);
        }

        if (lstBombDie.Count == 0)//不爆炸
        {
            return;
        }

        fishFirst.Kill(bulletOwner, b, 0F);//0.5秒间隔


        //BackStageSetting bss = gm.BSSetting;
        fishFirst.OddBonus = GetFishOddBonus(bulletOwner, b, fishFirst, fishFirst);
        int scoreTotalGetted = b.Score * fishFirst.OddBonus;



        if (scoreTotalGetted != 0)
        {
            bulletOwner.GainScore(scoreTotalGetted);
            if (GameMain.Evt_PlayerGainScoreFromFish != null)
            {
                GameMain.Evt_PlayerGainScoreFromFish(bulletOwner, scoreTotalGetted, fishFirst, b);
            }

            //触发杀死锁定鱼事件
            if (IsLockFishBullet && GameMain.EvtKillLockingFish != null)
            {
                GameMain.EvtKillLockingFish(bulletOwner);
            }
        }


        GameMain.IsMainProcessPause = true;

        if (GameMain.EvtFreezeBombActive != null)
        {
            GameMain.EvtFreezeBombActive();
        }

        GameObject go = new GameObject("Delay_FreezeBombRecover");

        go.AddComponent <FreezeBombRecover>();

        if (Evt_HitResult != null)
        {
            Evt_HitResult(!fishFirst.Attackable, bulletOwner, b, fishFirst);
        }
    }
예제 #12
0
    static void Process_FishTypeBombEx(Bullet b, Fish sameTypeBombEx)
    {
        if (!sameTypeBombEx.Attackable)
        {
            return;
        }

        //Transform bulletTs = b.transform;
        Player bulletOwner      = b.Owner;
        bool   IsLockFishBullet = b.IsLockingFish;



        //找出屏幕上所有同类炸弹
        List <Fish> fishMayDie = new List <Fish>();

        fishMayDie.Add(sameTypeBombEx);
        //计算总的倍数
        sameTypeBombEx.OddBonus = GetFishOddBonus(bulletOwner, b, sameTypeBombEx, sameTypeBombEx);
        int oddTotalAll = sameTypeBombEx.OddBonus;                                                          //sameTypeBombEx.Odds;

        int oddTotalAllForDieratio = GetFishOddForDieRatio(bulletOwner, b, sameTypeBombEx, sameTypeBombEx); //sameTypeBombEx.Odds + GetFishOddForDieRatio(bulletOwner, b, sameTypeBombEx, sameTypeBombEx);//用于赔率计算

        Dictionary <int, object> mAllAffectFishDict = new Dictionary <int, object>();                       //由同类炸弹杀死鱼的字典,(加入后代表'已处理',每次处理前都查询 ,可防止重复杀同一种鱼现象出现)

        //List<FishAndOddsMulti> fishNeedOddMulti = new List<FishAndOddsMulti>();
        //遍历同类炸弹
        foreach (Fish sameTypeBomb in GameMain.Singleton.FishGenerator.SameTypeBombs.Values)
        {
            List <Dictionary <int, Fish> > fishDicts = new List <Dictionary <int, Fish> >();
            foreach (Fish affectFish in sameTypeBomb.Prefab_SameTypeBombAffect)
            {
                if (!mAllAffectFishDict.ContainsKey(affectFish.TypeIndex))
                {
                    fishDicts.Add(GameMain.Singleton.FishGenerator.FishTypeIndexMap[affectFish.TypeIndex]);
                    mAllAffectFishDict.Add(affectFish.TypeIndex, null);
                }
            }

            //FishEx_OddsMulti oddsMultiComponent = sameTypeBomb.GetComponent<FishEx_OddsMulti>();
            //int oddTotalSameTypeBombMulti = oddsMultiComponent == null ? 1 : oddsMultiComponent.OddsMulti;
            sameTypeBomb.OddBonus = GetFishOddBonus(bulletOwner, b, sameTypeBomb, sameTypeBombEx);
            int oddTotalSameTypeBomb = sameTypeBomb.OddBonus;                                                              //sameTypeBomb.Odds * oddTotalSameTypeBombMulti;
            int oddTotalSameTypeBombForCaclDieratio = GetFishOddForDieRatio(bulletOwner, b, sameTypeBomb, sameTypeBombEx); //sameTypeBomb.Odds * oddTotalSameTypeBombMulti + GetFishOddForDieRatio(bulletOwner, b, sameTypeBomb, sameTypeBombEx);//用于赔率计算

            fishMayDie.Add(sameTypeBomb);
            //遍历同类炸弹影响到的鱼
            foreach (Dictionary <int, Fish> fishDict in fishDicts)
            {
                if (fishDict != null)
                {
                    foreach (Fish f in fishDict.Values)
                    {
                        if (f.Attackable &&
                            f.HittableTypeS == "Normal")   //自己是HittableType.SameTypeBomb,不包含在内
                        {
                            f.OddBonus            = GetFishOddBonus(bulletOwner, b, f, sameTypeBomb);
                            oddTotalSameTypeBomb += f.OddBonus;                                                            // f.Odds* oddTotalSameTypeBombMulti;
                            oddTotalSameTypeBombForCaclDieratio += GetFishOddForDieRatio(bulletOwner, b, f, sameTypeBomb); // f.Odds * oddTotalSameTypeBombMulti + GetFishOddForDieRatio(bulletOwner, b, f, sameTypeBomb);//用于赔率计算

                            fishMayDie.Add(f);

                            //if (oddTotalSameTypeBombMulti > 1)
                            //{
                            //    fishNeedOddMulti.Add(new FishAndOddsMulti(f, oddTotalSameTypeBombMulti));
                            //}
                        }
                    }
                }
            }
            oddTotalAll            += oddTotalSameTypeBomb;
            oddTotalAllForDieratio += oddTotalSameTypeBombForCaclDieratio;
        }


        FishOddsData dataBomb = new FishOddsData(0, oddTotalAllForDieratio);

        List <FishOddsData> lstBombDie = GameOdds.OneBulletKillFish(b.Score, dataBomb, new List <FishOddsData>());

        if (Evt_Hit != null)
        {
            Evt_Hit(oddTotalAllForDieratio == 0 ? true : false, bulletOwner, b, sameTypeBombEx);
        }

        if (lstBombDie.Count == 0)//不爆炸
        {
            return;
        }

        ////确定鱼会死亡后将倍率改变加入到Fish上,让效果显示该鱼正确倍率
        //foreach (FishAndOddsMulti fo in fishNeedOddMulti)
        //{
        //    FishEx_OddsMulti fodm = fo.F.gameObject.AddComponent<FishEx_OddsMulti>();
        //    fodm.OddsMulti = fo.OddMulti;
        //}

        int scoreTotalGetted = oddTotalAll * b.Score;

        //飞币效果(其他鱼死亡)
        foreach (Fish fDie in fishMayDie)
        {
            fDie.Kill(bulletOwner, b, 0F);//0.5秒间隔
        }

        if (GameMain.EvtSameTypeBombExKiled != null)
        {
            GameMain.EvtSameTypeBombExKiled(bulletOwner, scoreTotalGetted);
        }

        //BackStageSetting bss = GameMain.Singleton.BSSetting;

        if (scoreTotalGetted != 0)
        {
            bulletOwner.GainScore(scoreTotalGetted);

            if (GameMain.Evt_PlayerGainScoreFromFish != null)
            {
                GameMain.Evt_PlayerGainScoreFromFish(bulletOwner, scoreTotalGetted, sameTypeBombEx, b);
            }

            //触发杀死锁定鱼事件
            if (IsLockFishBullet && GameMain.EvtKillLockingFish != null)
            {
                GameMain.EvtKillLockingFish(bulletOwner);
            }
        }

        if (Evt_HitResult != null)
        {
            Evt_HitResult(!sameTypeBombEx.Attackable, bulletOwner, b, sameTypeBombEx);
        }
    }
예제 #13
0
    static void Process_FishTypeBomb2(Bullet b, Fish fishFirst)
    {
        if (!fishFirst.Attackable)
        {
            return;
        }

        //Transform bulletTs = b.transform;
        Player bulletOwner      = b.Owner;
        bool   IsLockFishBullet = b.IsLockingFish;


        int numTypeToBomb = fishFirst.Prefab_SameTypeBombAffect.Length;

        Dictionary <int, Fish>[] fishDicts = new Dictionary <int, Fish> [numTypeToBomb];
        for (int i = 0; i != numTypeToBomb; ++i)
        {
            fishDicts[i] = GameMain.Singleton.FishGenerator.FishTypeIndexMap[fishFirst.Prefab_SameTypeBombAffect[i].TypeIndex];
        }


        //计算是否爆炸
        List <Fish> fishAffect = new List <Fish>();

        fishAffect.Add(fishFirst);


        Fish tmpFish = null;

        //FishEx_OddsMulti sameTypeBombOddsMultiComponent = fishFirst.GetComponent<FishEx_OddsMulti>();
        //int oddMulti = sameTypeBombOddsMultiComponent == null ? 1 : sameTypeBombOddsMultiComponent.OddsMulti;
        //List<Fish> fishNeedOddMulti = new List<Fish>();

        fishFirst.OddBonus = GetFishOddBonus(bulletOwner, b, fishFirst, fishFirst);
        int oddTotal = fishFirst.OddBonus;                                                         //fishFirst.Odds * oddMulti;//用于奖励计算的倍率

        int oddTotalForCaclDieratio = GetFishOddForDieRatio(bulletOwner, b, fishFirst, fishFirst); //fishFirst.Odds * oddMulti + GetFishOddForDieRatio(bulletOwner, b, fishFirst);//用于赔率计算

        foreach (Dictionary <int, Fish> fishDict in fishDicts)
        {
            if (fishDict != null)
            {
                foreach (KeyValuePair <int, Fish> fKV in fishDict)
                {
                    tmpFish = fKV.Value;
                    if (tmpFish.Attackable &&
                        tmpFish.HittableTypeS == "Normal")   //自己是HittableType.SameTypeBomb,不包含在内
                    {
                        fishAffect.Add(tmpFish);

                        tmpFish.OddBonus         = GetFishOddBonus(bulletOwner, b, tmpFish, fishFirst);
                        oddTotal                += tmpFish.OddBonus;                                          //tmpFish.Odds * oddMulti;//可以统一相乘,不过在这里牺牲一些效率,让代码更直观
                        oddTotalForCaclDieratio += GetFishOddForDieRatio(bulletOwner, b, tmpFish, fishFirst); //tmpFish.Odds * oddMulti + GetFishOddForDieRatio(bulletOwner, b, tmpFish);//用于赔率计算

                        //if (oddMulti > 1)
                        //{
                        //    fishNeedOddMulti.Add(tmpFish);
                        //}
                    }
                }
            }
        }


        FishOddsData dataBomb = new FishOddsData(0, oddTotalForCaclDieratio);
        //Debug.Log("oddTotalForCaclDieratio = " + oddTotalForCaclDieratio);
        List <FishOddsData> lstBombDie = GameOdds.OneBulletKillFish(b.Score, dataBomb, new List <FishOddsData>());

        if (Evt_Hit != null)
        {
            Evt_Hit(oddTotalForCaclDieratio == 0? true:false, bulletOwner, b, fishFirst);
        }

        if (lstBombDie.Count == 0)
        {
            return;
        }

        //将鱼倍率相乘加入到鱼中,让效果处理正确显示
        //foreach (Fish f in fishNeedOddMulti)
        //{
        //    FishEx_OddsMulti odm = f.gameObject.AddComponent<FishEx_OddsMulti>();//在死的鱼上加入组件,确定死亡倍数,(主要用于显示)
        //    odm.OddsMulti = oddMulti;
        //}

        //炸弹爆炸
        //计算获得分数
        int scoreTotalGetted = oddTotal * b.Score;

        //飞币效果(其他鱼死亡)
        foreach (Fish fDie in fishAffect)
        {
            fDie.Kill(bulletOwner, b, 0F);//0.5秒间隔
        }
        //触发事件
        if (GameMain.EvtSameTypeBombKiled != null)
        {
            GameMain.EvtSameTypeBombKiled(bulletOwner, scoreTotalGetted);
        }

        //BackStageSetting bss = GameMain.Singleton.BSSetting;

        if (scoreTotalGetted != 0)
        {
            bulletOwner.GainScore(scoreTotalGetted);

            if (GameMain.Evt_PlayerGainScoreFromFish != null)
            {
                GameMain.Evt_PlayerGainScoreFromFish(bulletOwner, scoreTotalGetted, fishFirst, b);
            }

            //触发杀死锁定鱼事件
            if (IsLockFishBullet && GameMain.EvtKillLockingFish != null)
            {
                GameMain.EvtKillLockingFish(bulletOwner);
            }
        }

        if (Evt_HitResult != null)
        {
            Evt_HitResult(!fishFirst.Attackable, bulletOwner, b, fishFirst);
        }
    }
예제 #14
0
    static void Process_AreaBomb(Bullet b, Fish fishFirst)
    {
        if (!fishFirst.Attackable)
        {
            return;
        }

        Transform bulletTs         = b.transform;
        Player    bulletOwner      = b.Owner;
        bool      IsLockFishBullet = b.IsLockingFish;



        //生成碰撞范围
        RaycastHit[] results = Physics.SphereCastAll(bulletTs.position - Bullet.ColliderOffsetZ, fishFirst.AreaBombRadius, Vector3.forward);


        //计算是否爆炸
        List <Fish> fishAffect = new List <Fish>();
        int         oddTotal   = 0;              //用于奖励的倍率
        int         oddTotalForCaclDieratio = 0; //计算死亡几率的倍率

        Fish tmpFish = null;


        foreach (RaycastHit hitObj in results)
        {
            tmpFish = hitObj.transform.GetComponent <Fish>();
            if (tmpFish != null &&
                tmpFish.Attackable &&
                tmpFish.HittableTypeS == "Normal")
            {
                fishAffect.Add(tmpFish);

                oddTotalForCaclDieratio += GetFishOddForDieRatio(bulletOwner, b, tmpFish, fishFirst);//用于赔率计算;
                tmpFish.OddBonus         = GetFishOddBonus(bulletOwner, b, tmpFish, fishFirst);
                oddTotal += tmpFish.OddBonus;
            }

            if (oddTotal > fishFirst.AreaBombOddLimit)
            {
                break;
            }
        }



        FishOddsData        dataBomb   = new FishOddsData(0, oddTotalForCaclDieratio);
        List <FishOddsData> lstBombDie = GameOdds.OneBulletKillFish(b.Score, dataBomb, new List <FishOddsData>());

        if (Evt_Hit != null)
        {
            Evt_Hit(oddTotalForCaclDieratio == 0 ? true : false, bulletOwner, b, fishFirst);
        }

        if (lstBombDie.Count == 0)//不爆炸
        {
            return;
        }

        fishFirst.Kill(bulletOwner, b, 0);
        //炸弹爆炸,杀范围内鱼
        int scoreTotalGetted = oddTotal * b.Score;

        //触发事件
        if (GameMain.EvtFishBombKilled != null)
        {
            GameMain.EvtFishBombKilled(bulletOwner, scoreTotalGetted);
        }

        //飞币效果(其他鱼死亡)
        foreach (Fish fDie in fishAffect)
        {
            fDie.Kill(bulletOwner, b, 0F);//0.5秒间隔
        }

        //BackStageSetting bss = GameMain.Singleton.BSSetting;

        if (scoreTotalGetted != 0)
        {
            bulletOwner.GainScore(scoreTotalGetted);

            if (GameMain.Evt_PlayerGainScoreFromFish != null)
            {
                GameMain.Evt_PlayerGainScoreFromFish(bulletOwner, scoreTotalGetted, fishFirst, b);
            }

            //触发杀死锁定鱼事件
            if (IsLockFishBullet && GameMain.EvtKillLockingFish != null)
            {
                GameMain.EvtKillLockingFish(bulletOwner);
            }
        }

        if (Evt_HitResult != null)
        {
            Evt_HitResult(!fishFirst.Attackable, bulletOwner, b, fishFirst);
        }
    }
예제 #15
0
    static void Process_NormalFish(Bullet b, Fish fishFirst)
    {
        if (!fishFirst.Attackable)
        {
            return;
        }

        Transform bulletTs         = b.transform;
        Player    bulletOwner      = b.Owner;
        bool      IsLockFishBullet = b.IsLockingFish;//是否锁鱼的子弹


        //生成碰撞范围
        RaycastHit[] results = Physics.SphereCastAll(bulletTs.position - Bullet.ColliderOffsetZ, b.RadiusStandardBoom * 0.6F /** useWebScaleRatio.ScaleCollider //将要修正,不同子弹不同大小 */, Vector3.forward);


        List <Fish> fishAll     = new List <Fish>();
        List <Fish> fishOthers  = new List <Fish>();
        List <Fish> fishDieList = new List <Fish>();

        fishAll.Add(fishFirst);
        Fish fishTmp = null;

        for (int i = 0; i != results.Length; ++i)
        {
            fishTmp = results[i].transform.GetComponent <Fish>();

            if (fishTmp != null &&
                fishFirst != fishTmp &&
                fishTmp.Attackable &&
                fishTmp.HittableTypeS == "Normal" &&
                !fishTmp.HitByBulletOnly)
            {
                fishOthers.Add(fishTmp);
                fishAll.Add(fishTmp);
            }
        }

        List <FishOddsData> dataFishOtherList = new List <FishOddsData>();

        foreach (Fish f in fishOthers)
        {
            dataFishOtherList.Add(new FishOddsData(f.ID, GetFishOddForDieRatio(bulletOwner, b, f, fishFirst)));                   //用于赔率计算
        }
        FishOddsData dataFishFirst = new FishOddsData(fishFirst.ID, GetFishOddForDieRatio(bulletOwner, b, fishFirst, fishFirst)); //用于赔率计算


        List <FishOddsData> dataFishDieLst = GameOdds.OneBulletKillFish(b.Score, dataFishFirst, dataFishOtherList);

        foreach (FishOddsData fishDie in dataFishDieLst)
        {
            foreach (Fish f in fishAll)
            {
                if (fishDie.ID == f.ID)
                {
                    fishDieList.Add(f);
                    break;
                }
            }
        }

        int numKilled        = 0;
        int scoreTotalGetted = 0;

        foreach (Fish fDie in fishDieList)
        {
            fDie.OddBonus     = GetFishOddBonus(bulletOwner, b, fDie, fishFirst);//显示赔率
            scoreTotalGetted += fDie.OddBonus * b.Score;

            fDie.Kill(bulletOwner, b, 0.5F * numKilled);//0.5秒间隔
            ++numKilled;
        }

        if (Evt_Hit != null)
        {
            Evt_Hit(dataFishFirst.Odds == 0?true:false, bulletOwner, b, fishFirst);
        }

        //BackStageSetting bss = GameMain.Singleton.BSSetting;

        if (scoreTotalGetted != 0)
        {
            bulletOwner.GainScore(scoreTotalGetted);

            if (GameMain.Evt_PlayerGainScoreFromFish != null)
            {
                GameMain.Evt_PlayerGainScoreFromFish(bulletOwner, scoreTotalGetted, fishFirst, b);
            }

            //触发杀死锁定鱼事件
            if (IsLockFishBullet && GameMain.EvtKillLockingFish != null)
            {
                GameMain.EvtKillLockingFish(bulletOwner);
            }
        }

        if (Evt_HitResult != null)
        {
            Evt_HitResult(!fishFirst.Attackable, bulletOwner, b, fishFirst);
        }
    }