Ejemplo n.º 1
0
 public bool LoadFromFile(string path)
 {
     BoxProductInfo.Init(new TableLoaderLocalCSV <int, TDataBoxOpenInfo>(), path, "BoxOpenInfo.csv");
     CoopMode.Init(new TableLoaderLocalCSV <int, TDataCoopMode>(), path, "CoopMode.csv");
     CoopModeMinion.Init(new TableLoaderLocalCSV <int, TDataCoopModeMinion>(), path, "CoopModeMinion.csv");
     CoopModeBossInfo.Init(new TableLoaderLocalCSV <int, TDataCoopModeBossInfo>(), path, "CoopModeBossInfo.csv");
     DiceInfo.Init(new TableLoaderLocalCSV <int, TDataDiceInfo>(), path, "DiceInfo.csv");
     DiceUpgrade.Init(new TableLoaderLocalCSV <int, TDataDiceUpgrade>(), path, "DiceUpgrade.csv");
     DiceLevelInfo.Init(new TableLoaderLocalCSV <int, TDataDiceLevelInfo>(), path, "DiceLevelInfo.csv");
     GuardianInfo.Init(new TableLoaderLocalCSV <int, TDataGuardianInfo>(), path, "GuardianInfo.csv");
     Vsmode.Init(new TableLoaderLocalCSV <int, TDataVsmode>(), path, "Vsmode.csv");
     LangEN.Init(new TableLoaderLocalCSV <int, TDataLangEN>(), path, "LangEN.csv");
     LangKO.Init(new TableLoaderLocalCSV <int, TDataLangKO>(), path, "LangKO.csv");
     RankingReward.Init(new TableLoaderLocalCSV <int, TDataRankingReward>(), path, "RankingReward.csv");
     ClassInfo.Init(new TableLoaderLocalCSV <int, TDataClassInfo>(), path, "ClassInfo.csv");
     SeasonpassInfo.Init(new TableLoaderLocalCSV <int, TDataSeasonpassInfo>(), path, "SeasonpassInfo.csv");
     SeasonpassReward.Init(new TableLoaderLocalCSV <int, TDataSeasonpassReward>(), path, "SeasonpassReward.csv");
     ClassReward.Init(new TableLoaderLocalCSV <int, TDataClassReward>(), path, "ClassReward.csv");
     ItemList.Init(new TableLoaderLocalCSV <int, TDataItemList>(), path, "ItemList.csv");
     QuestInfo.Init(new TableLoaderLocalCSV <int, TDataQuestInfo>(), path, "QuestInfo.csv");
     QuestData.Init(new TableLoaderLocalCSV <int, TDataQuestData>(), path, "QuestData.csv");
     QuestDayReward.Init(new TableLoaderLocalCSV <int, TDataQuestDayReward>(), path, "QuestDayReward.csv");
     ShopInfo.Init(new TableLoaderLocalCSV <int, TDataShopInfo>(), path, "ShopInfo.csv");
     ShopProductList.Init(new TableLoaderLocalCSV <int, TDataShopProductList>(), path, "ShopProductList.csv");
     MailInfo.Init(new TableLoaderLocalCSV <int, TDataMailInfo>(), path, "MailInfo.csv");
     loaded = true;
     return(true);
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Roll one or more dice with a specific material from a spawnPoint and give it a specific force.
    /// format dice             :   ({count}){die type}	, exmpl.  d6, 4d4, 12d8 , 1d20
    /// possible die types  :	d4, d6, d8 , d10, d12, d20
    /// </summary>
    public static void SpawnDices(string dice, string mat, Vector3 spawnPoint, GameObject parentObject)
    {
        rolling = true;
        // sotring dice to lowercase for comparing purposes
        dice = dice.ToLower();
        int    count   = 1;
        string dieType = "d6";

        // 'd' must be present for a valid 'dice' specification
        int p = dice.IndexOf("d");

        if (p >= 0)
        {
            // check if dice starts with d, if true a single die is rolled.
            // dice must have a count because dice does not start with 'd'
            if (p > 0)
            {
                // extract count
                string[] a = dice.Split('d');
                count = System.Convert.ToInt32(a[0]);
                // get die type
                if (a.Length > 1)
                {
                    dieType = "d" + a[1];
                }
                else
                {
                    dieType = "d6";
                }
            }
            else
            {
                dieType = dice;
            }

            // instantiate the dice
            for (int d = 0; d < count; d++)
            {
                // create the die prefab/gameObject
                GameObject die = Dice.prefab(dieType, spawnPoint, Vector3.zero, Vector3.one, mat);
                die.GetComponent <Rigidbody> ().collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
                // give it a random rotation
                die.transform.Rotate(new Vector3(Random.value * 360, Random.value * 360, Random.value * 360));
                // inactivate this gameObject because activating it will be handeled using the rollQueue and at the apropriate time
                die.SetActive(true);
                // put dice as child of another object
                if (parentObject != null)
                {
                    die.transform.SetParent(parentObject.transform, false);
                }
                DiceInfo diceInfo = new DiceInfo(die, dieType, mat);
                // add allDices list
                allDice.Add(diceInfo);
            }
        }
    }
Ejemplo n.º 3
0
        public override bool Action(NotifyType notifyType, BaseInfo baseInfo, UserInfo userInfo)
        {
            switch (notifyType)
            {
            case NotifyType.Request_Betting:
            {
                DiceInfo diceInfo = (DiceInfo)_GameTable.GetTableInfo();

                int playerIndex = _GameTable.GetPlayerIndex(userInfo);

                if (playerIndex < 0)
                {
                    return(false);
                }

                BettingInfo bettingInfo = (BettingInfo)baseInfo;

                int nCurUserMoney = userInfo.GetGameMoney();

                // added by usc at 2014/02/03
                int curBettingMoney = 0;
                for (int i = 0; i < 4; i++)
                {
                    curBettingMoney += diceInfo.m_lUserScore[playerIndex, i];
                }

                if (nCurUserMoney < curBettingMoney + bettingInfo._Score)
                {
                    BaseInfo.SetError(ErrorType.Notenough_Cash, "베팅할 금액이 부족합니다");
                    return(false);
                }

                if (curBettingMoney + bettingInfo._Score > GameDefine.MAX_BETTING_MONEY)
                {
                    return(false);
                }

                diceInfo.m_lUserScore[playerIndex, bettingInfo._Area] += bettingInfo._Score;
                diceInfo.m_lPlayerBetAll[bettingInfo._Area]           += bettingInfo._Score;

                // added by usc at 2014/04/09
                diceInfo.m_lUserBetScore[playerIndex] += bettingInfo._Score;

                _GameTable.BroadCastGame(NotifyType.Reply_Betting, baseInfo);
            }
            break;

            default:
                return(base.Action(notifyType, baseInfo, userInfo));

                break;
            }

            return(true);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Check if there all dice have stopped rolling
 /// </summary>
 private bool IsRolling()
 {
     for (int d = 0; d < allDice.Count; d++)
     {
         DiceInfo die = (DiceInfo)allDice[d];
         if (die.rolling)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 5
0
    /// <summary>
    /// Get value of all ( dieType = "" ) dice or dieType specific dice.
    /// </summary>
    public static int Value(string dieType)
    {
        int v = 0;

        // loop all dice
        for (int d = 0; d < allDice.Count; d++)
        {
            DiceInfo die = (DiceInfo)allDice[d];
            v += die.value;
        }
        return(v);
    }
Ejemplo n.º 6
0
        public override bool PlayerOutTable(BaseInfo baseInfo, UserInfo userInfo)
        {
            int seaterIndex = GetPlayerIndex(userInfo);

            if (seaterIndex >= 0)
            {
                if (_Rounds[_TableInfo._RoundIndex] is DiceBettingRound)
                {
                    DiceInfo diceInfo = (DiceInfo)_TableInfo;

                    int lAllScore = 0;

                    for (int i = 0; i < 4; i++)
                    {
                        lAllScore += diceInfo.m_lUserScore[seaterIndex, i];
                    }

                    // added by usc at 2014/02/23
                    for (int i = 0; i < 4; i++)
                    {
                        // deleted by usc at 2014/04/03
                        //diceInfo.m_lPlayerBetAll[i] -= diceInfo.m_lUserScore[seaterIndex, i];
                        diceInfo.m_lUserScore[seaterIndex, i] = 0;
                    }

                    if (lAllScore > 0)
                    {
                        diceInfo.m_lUserWinScore[seaterIndex] = -lAllScore;

                        Cash.GetInstance().ProcessGameCash(seaterIndex, _GameInfo, _TableInfo);
                    }

                    for (int i = seaterIndex; i < _TableInfo._Players.Count; i++)
                    {
                        for (int k = 0; k < 4; k++)
                        {
                            diceInfo.m_lUserScore[i, k] = diceInfo.m_lUserScore[i + 1, k];
                        }

                        // added by usc at 2014/04/09
                        diceInfo.m_lUserBetScore[i] = diceInfo.m_lUserBetScore[i + 1];
                    }
                }
            }

            return(base.PlayerOutTable(baseInfo, userInfo));
        }
Ejemplo n.º 7
0
        public override void InitTableData(TableInfo tableInfo)
        {
            DiceInfo diceInfo = (DiceInfo)tableInfo;

            //变量定义
            Array.Clear(diceInfo.m_lUserScore, 0, diceInfo.m_lUserScore.Length);
            Array.Clear(diceInfo.m_lUserWinScore, 0, diceInfo.m_lUserWinScore.Length);

            // added newly
            Array.Clear(diceInfo.m_lPlayerBetAll, 0, diceInfo.m_lPlayerBetAll.Length);

            Array.Clear(diceInfo.m_enCards, 0, diceInfo.m_enCards.Length);
            Array.Clear(diceInfo.m_bWinner, 0, diceInfo.m_bWinner.Length);

            // added by usc at 2014/04/09
            Array.Clear(diceInfo.m_lUserBetScore, 0, diceInfo.m_lUserBetScore.Length);
        }
Ejemplo n.º 8
0
        public DiceTable(string tableId)
        {
            _TableInfo          = new DiceInfo();
            _TableInfo._TableId = tableId;

            _Rounds.Add(new ReadyRound());
            _Rounds.Add(new DiceBettingRound());
            _Rounds.Add(new DiceEndRound());

            for (int i = 0; i < _Rounds.Count; i++)
            {
                _Rounds[i]._GameTable = this;
            }

            // added by usc at 2014/01/20
            _TableInfo.m_lMinScore = 100;
        }
Ejemplo n.º 9
0
        private void ReadDiceXElement(XElement element)
        {
            if (DiceInfo == null)
            {
                DiceInfo = new DiceInfo();
            }
            ;

            var dice = element.Element("dice");

            if (dice == null)
            {
                return;
            }
            var sides = dice.AttributeValue("side").Split(',').Select(x => Convert.ToInt32(x)).ToList();

            foreach (var side in sides)
            {
                DiceInfo.Dices.Add(new Dice {
                    Side = side
                });
            }
        }
Ejemplo n.º 10
0
        // added by usc at 2014/02/27
        private CurBettingInfo GetCurBettingInfo(DiceInfo diceInfo)
        {
            CurBettingInfo curBettingInfo = new CurBettingInfo();

            int[] aAreaScore = { 0, 0, 0, 0 };

            for (int i = 0; i < 4; i++)
            {
                aAreaScore[i] = diceInfo.m_lPlayerBetAll[i];
            }

            int nMinArea  = 0;
            int nMinScore = aAreaScore[0];
            int nMaxScore = aAreaScore[0];


            for (int i = 1; i < 4; i++)
            {
                if (aAreaScore[i] > nMaxScore)
                {
                    nMaxScore = aAreaScore[i];
                }

                if (aAreaScore[i] < nMinScore)
                {
                    nMinArea  = i;
                    nMinScore = aAreaScore[i];
                }
            }

            curBettingInfo.nMinArea  = nMinArea;
            curBettingInfo.nMinScore = nMinScore;
            curBettingInfo.nMaxScore = nMaxScore;

            return(curBettingInfo);
        }
Ejemplo n.º 11
0
        public override void CheckScore()
        {
            DiceInfo tableInfo = (DiceInfo)_GameTable.GetTableInfo();

            Array.Clear(tableInfo.m_lUserWinScore, 0, tableInfo.m_lUserWinScore.Length);

            //计算金币
            int[] lUserLostScore = new int[GameDefine.GAME_PLAYER];
            //int lBankerWinScore = 0;

            //for (int i = 0; i < tableInfo._Players.Count; i++)
            //{
            //    for (int k = 0; k < 4; k++)
            //    {
            //        lBankerWinScore += tableInfo.m_lUserScore[i, k];
            //    }
            //}

            //计算金币
            int[] cards = tableInfo.m_enCards;

            for (int i = 0; i < tableInfo._Players.Count; ++i)
            {
                //庄家判断
                //if (m_wCurrentBanker==i) continue;

                //获取用户
                for (int j = 0; j < 4; ++j)
                {
                    lUserLostScore[i] += tableInfo.m_lUserScore[i, j];

                    // 该区域是否赢了
                    if (tableInfo.m_bWinner[j] > 0)
                    {
                        int winScore = 0;

                        if (tableInfo.m_lUserScore[i, j] > 0)
                        {
                            int multi = 2;

                            if (cards[0] == cards[1] && cards[1] == cards[2])
                            {
                                multi = cards[0];
                            }

                            winScore = tableInfo.m_lUserScore[i, j] * multi;
                        }

                        tableInfo.m_lUserWinScore[i] += winScore;
                        //lBankerWinScore -= winScore;
                    }
                }

                //计算税收
                //if (tableInfo.m_lUserWinScore[i] > 0)
                //{
                //    tableInfo.m_lUserRevenue[i] = (tableInfo.m_lUserWinScore[i] * gamePercent) / 1000;
                //    tableInfo.m_lUserWinScore[i] -= tableInfo.m_lUserRevenue[i];
                //}

                //总的分数
                tableInfo.m_lUserWinScore[i] -= lUserLostScore[i];
            }
        }
Ejemplo n.º 12
0
        public override void CheckWinner()
        {
            Random random = new Random();

            int miniSum = 1000000;

            int[] miniCards = new int[3];

            for (int i = 0; i < 11; i++)
            {
                DiceInfo tableInfo = (DiceInfo)_GameTable.GetTableInfo();

                // 查看是否需要控制
                int[] cards = tableInfo.m_enCards;


                if (i == 10)
                {
                    cards[0] = miniCards[0];
                    cards[1] = miniCards[1];
                    cards[2] = miniCards[2];
                }
                else
                {
                    cards[0] = (random.Next() % 12 + 1);

                    if (random.Next() % 12 == 0)
                    {
                        cards[1] = cards[0];
                        cards[2] = cards[0];
                    }
                    else
                    {
                        cards[1] = (random.Next() % 12 + 1);
                        cards[2] = (random.Next() % 12 + 1);
                    }
                }

                int sum = cards[0] + cards[1] + cards[2];

                Array.Clear(tableInfo.m_bWinner, 0, tableInfo.m_bWinner.Length);

                if (cards[0] == cards[1] && cards[1] == cards[2])
                {
                    tableInfo.m_bWinner[random.Next() % 4] = 1;
                }
                else
                {
                    if (sum > 10)
                    {
                        tableInfo.m_bWinner[0] = 1;
                    }
                    else
                    {
                        tableInfo.m_bWinner[1] = 1;
                    }

                    if (sum % 2 == 1)
                    {
                        tableInfo.m_bWinner[2] = 1;
                    }
                    else
                    {
                        tableInfo.m_bWinner[3] = 1;
                    }
                }

                CheckScore();

                int totalSum     = 0;
                int lSystemScore = 0;
                int nBuyerCount  = 0;

                for (int k = 0; k < tableInfo._Players.Count; k++)
                {
                    if (tableInfo._Players[k].Auto > 0 || tableInfo._Players[k].Kind != (int)UserKind.Buyer)
                    {
                        continue;
                    }

                    totalSum += tableInfo.m_lUserWinScore[k];

                    nBuyerCount++;
                }

                if (nBuyerCount == 0)
                {
                    break;
                }

                lSystemScore = -totalSum;

                if (tableInfo.m_StorageScore + lSystemScore < 0)
                {
                    if (totalSum < miniSum)
                    {
                        miniSum = totalSum;

                        for (int m = 0; m < 3; m++)
                        {
                            miniCards[m] = cards[m];
                        }
                    }
                }
                else
                {
                    if (tableInfo.m_StorageScore == DiceDefine.FIRST_EVENT_SCORE)
                    {
                        tableInfo.m_StorageScore -= DiceDefine.FIRST_EVENT_SCORE;
                    }

                    tableInfo.m_StorageScore += lSystemScore;
                    tableInfo.m_StorageScore -= (tableInfo.m_StorageScore * tableInfo.m_StorageDeduct / 1000);
                    break;
                }
            }
        }
Ejemplo n.º 13
0
        public override void NotifyGameTimer(GameTimer gameTimer)
        {
            if (gameTimer.timerId != TimerID.Custom || gameTimer.autoInfo == null)
            {
                return;
            }

            int[] bettingScores = new int[] { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
                                              100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
                                              1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
                                              10000, 10000, 10000, 10000, 10000,

                                              /*100000 , 100000,
                                               * 500000*/};

            // added by usc at 2014/02/26
            DiceInfo diceInfo = (DiceInfo)_GameTable.GetTableInfo();

            CurBettingInfo curBettingInfo = GetCurBettingInfo(diceInfo);

            int nBettingArea = curBettingInfo.nMinArea;
            int nMinScore    = curBettingInfo.nMinScore;
            int nMaxScore    = curBettingInfo.nMaxScore;

            int nScore = 0;

            if (nMaxScore <= 1000)
            {
                if (nMaxScore == 0)
                {
                    nScore = (int)(Math.Pow(10, (double)(_random.Next() % 2) + 2));
                }
                else
                {
                    nScore = bettingScores[_random.Next() % bettingScores.Length];
                }

                nBettingArea = _random.Next() % 4;
            }
            else
            {
                int nReaptCnt = 0;

                while (true)
                {
                    nReaptCnt++;

                    nScore = bettingScores[_random.Next() % bettingScores.Length];

                    if (nMinScore + nScore <= nMaxScore + nMaxScore * _random.Next(25, 75) / 100)
                    {
                        break;
                    }

                    if (nReaptCnt > 20)
                    {
                        break;
                    }
                }
            }

            // added by usc at 2014/03/19
            if (nMinScore + nScore > 50000)
            {
                return;
            }

            BettingInfo bettingInfo = new BettingInfo();

            bettingInfo._Area      = nBettingArea;
            bettingInfo._Score     = nScore;
            bettingInfo._UserIndex = _GameTable.GetPlayerIndex(gameTimer.autoInfo);

            Action(NotifyType.Request_Betting, bettingInfo, gameTimer.autoInfo);
        }