示例#1
0
    public FixedDiceNG() : base()
    {
        currIndividualDiceValues = new List <int>();

        //init dictionary
        seriesForDices6 = new Dictionary <Player, Dictionary <GameProperties.Instrument, Dictionary <int, int[]> > >();
        for (int i = 0; i < GameGlobals.players.Count; i++)
        {
            Player currPlayer = GameGlobals.players[i];
            seriesForDices6[currPlayer] = new Dictionary <GameProperties.Instrument, Dictionary <int, int[]> >();
            foreach (GameProperties.Instrument instrument in System.Enum.GetValues(typeof(GameProperties.Instrument)))
            {
                seriesForDices6[currPlayer][instrument] = new Dictionary <int, int[]>();
                for (int j = 0; j < GameProperties.configurableProperties.numberOfAlbumsPerGame; j++)
                {
                    seriesForDices6[currPlayer][instrument][j] = new int[GameProperties.configurableProperties.numberOfAlbumsPerGame];
                }
            }
        }


        for (int i = 0; i < GameGlobals.players.Count; i++)
        {
            Player currPlayer = GameGlobals.players[i];
            PlayerParameterization currPlayerParam = GameProperties.currGameParameterization.playerParameterizations[i];

            int lastVisitedIndex = 0;

            for (int j = 0; j < GameProperties.configurableProperties.numberOfAlbumsPerGame; j++)
            {
                foreach (GameProperties.Instrument instrument in System.Enum.GetValues(typeof(GameProperties.Instrument)))
                {
                    int[] currPossibleResults = new int[j + 1];
                    for (int k = 0; k <= j; k++)
                    {
                        if (currPlayerParam.fixedMarketingDiceResults == null || currPlayerParam.fixedInstrumentDiceResults == null) //failsafe
                        {
                            currPossibleResults[k] = 0;
                            continue;
                        }

                        if (instrument == GameProperties.Instrument.MARKETING)
                        {
                            currPossibleResults[k] = currPlayerParam.fixedMarketingDiceResults[lastVisitedIndex + k];
                        }
                        else
                        {
                            currPossibleResults[k] = currPlayerParam.fixedInstrumentDiceResults[lastVisitedIndex + k];
                        }
                    }

                    seriesForDices6[currPlayer][instrument][j] = currPossibleResults;
                }
                lastVisitedIndex += (j + 1);
            }
        }
    }
    void SetUpParameterization(GameParameterization parameterization)
    {
        GameGlobals.players.Clear();
        int currPlayerId = 0;

        for (int i = 0; i < parameterization.playerParameterizations.Count; i++)
        {
            PlayerParameterization currParam = parameterization.playerParameterizations[i];

            GameProperties.Instrument currLikedInstrument = GameProperties.Instrument.NONE;

            switch (currParam.likedInstrument)
            {
            case "GUITAR":
                currLikedInstrument = GameProperties.Instrument.GUITAR;
                break;

            case "DRUMS":
                currLikedInstrument = GameProperties.Instrument.DRUMS;
                break;

            case "VOCALS":
                currLikedInstrument = GameProperties.Instrument.VOCALS;
                break;

            case "KEYBOARD":
                currLikedInstrument = GameProperties.Instrument.KEYBOARD;
                break;

            case "BASS":
                currLikedInstrument = GameProperties.Instrument.BASS;
                break;

            default:
                currLikedInstrument = GameProperties.Instrument.GUITAR;
                //isErrorEncountered = true;
                //setupWarningPoppupRef.DisplayPoppup("did not parse the liked instrument of player. Guitar assumed..." + currParam.name);
                break;
            }

            switch (currParam.playerType)
            {
            case "HUMAN":
                GameGlobals.players.Add(new UIPlayer(playerUIPrefab, playerCanvas, GameGlobals.monoBehaviourFunctionalities, playerWarningPoppupRef, currPlayerId++, currParam.name));
                break;

            case "SIMPLE":
                GameGlobals.players.Add(new AIPlayerSimpleStrategy(playerUIPrefab, playerCanvas, GameGlobals.monoBehaviourFunctionalities, playerWarningPoppupRef, currPlayerId++, currParam.name, currParam.isSpeechAllowed, currLikedInstrument));
                break;

            case "RANDOM":
                GameGlobals.players.Add(new AIPlayerRandomStrategy(playerUIPrefab, playerCanvas, GameGlobals.monoBehaviourFunctionalities, playerWarningPoppupRef, currPlayerId++, currParam.name, currParam.isSpeechAllowed, currLikedInstrument));
                break;

            case "COOPERATIVE":
                GameGlobals.players.Add(new AIPlayerCoopStrategy(playerUIPrefab, playerCanvas, GameGlobals.monoBehaviourFunctionalities, playerWarningPoppupRef, currPlayerId++, currParam.name, currParam.isSpeechAllowed, currLikedInstrument));
                break;

            case "GREEDY":
                GameGlobals.players.Add(new AIPlayerGreedyStrategy(playerUIPrefab, playerCanvas, GameGlobals.monoBehaviourFunctionalities, playerWarningPoppupRef, currPlayerId++, currParam.name, currParam.isSpeechAllowed, currLikedInstrument));
                break;

            case "BALANCED":
                GameGlobals.players.Add(new AIPlayerBalancedStrategy(playerUIPrefab, playerCanvas, GameGlobals.monoBehaviourFunctionalities, playerWarningPoppupRef, currPlayerId++, currParam.name, currParam.isSpeechAllowed, currLikedInstrument));
                break;

            case "UNBALANCED":
                GameGlobals.players.Add(new AIPlayerUnbalancedStrategy(playerUIPrefab, playerCanvas, GameGlobals.monoBehaviourFunctionalities, playerWarningPoppupRef, currPlayerId++, currParam.name, currParam.isSpeechAllowed, currLikedInstrument));
                break;

            case "TITFORTAT":
                GameGlobals.players.Add(new AIPlayerTitForTatStrategy(playerUIPrefab, playerCanvas, GameGlobals.monoBehaviourFunctionalities, playerWarningPoppupRef, currPlayerId++, currParam.name, currParam.isSpeechAllowed, currLikedInstrument));
                break;

            default:
                isErrorEncountered = true;
                setupWarningPoppupRef.DisplayPoppup("Error on parsing the player type of " + currParam.name);
                Debug.Log("[ERROR]: Error on parsing the player type of " + currParam.name);
                break;
            }
        }

        string pattern = "FIXED:[WL]+";
        Match  m       = Regex.Match(parameterization.ngType, pattern, RegexOptions.IgnoreCase);

        if (m.Success)
        {
            int    index       = parameterization.ngType.IndexOf(":");
            string gameResults = parameterization.ngType.Substring(index + 1);
            GameGlobals.gameDiceNG = new PredefinedDiceNG(gameResults);
        }
        else
        {
            switch (parameterization.ngType)
            {
            case "RANDOM":
                GameGlobals.gameDiceNG = new RandomDiceNG();
                break;

            case "FIXED:LOSS":
                GameGlobals.gameDiceNG = new LossDiceNG();
                break;

            case "FIXED:VICTORY":
                GameGlobals.gameDiceNG = new VictoryDiceNG();
                break;

            default:
                isErrorEncountered = true;
                setupWarningPoppupRef.DisplayPoppup("Error on parsing the NG Type of parameterization " + parameterization.ngType);
                Debug.Log("[ERROR]: Error on parsing the NG Type of parameterization " + parameterization.ngType);
                break;
            }
        }


        //Game.gameParameterizations.Add(parameterization);
        //string json = JsonUtility.ToJson(GameProperties.configurableProperties);
    }