Exemplo n.º 1
0
    public static GameRules GetNextRuleSet(GameRules afterThis)
    {
        GameRules matchingRules = savedRules.FirstOrDefault(rule => rule.RuleSetGUID == afterThis.RuleSetGUID);

        // Somehow, this rule isn't in our list. Just hand the first default.
        if (matchingRules == null)
        {
            return(GetDefaultGameRules().First());
        }

        // There aren't any other saved rules, so just hand the first default.
        if (savedRules.Count == 1)
        {
            return(GetDefaultGameRules().First());
        }

        int saveIndex = savedRules.IndexOf(matchingRules);

        if (saveIndex == savedRules.Count - 1)
        {
            return(savedRules[saveIndex - 1]);
        }

        return(savedRules[saveIndex + 1]);
    }
Exemplo n.º 2
0
    public static void UpdateRuleSet(GameRules ruleSet)
    {
        if (string.IsNullOrWhiteSpace(ruleSet.RuleSetGUID) || ruleSet.IsDefaultRule)
        {
            SaveNewRuleSet(ruleSet);
            return;
        }

        GameRules matchingRules = savedRules.FirstOrDefault(rules => rules.RuleSetGUID == ruleSet.RuleSetGUID);

        if (matchingRules == null)
        {
            SaveNewRuleSet(ruleSet);
            return;
        }

        savedRules.Remove(matchingRules);
        savedRules.Add(ruleSet);

        string rulesJson = JsonConvert.SerializeObject(ruleSet);

        PlayerPrefs.SetString(ruleSet.RuleSetGUID.ToString(), rulesJson);

        SetLastUsedGameRule(ruleSet);
    }
Exemplo n.º 3
0
        public override GameRules GetGameRules()
        {
            GameRules rules = new GameRules
            {
                new GameRule <bool>(GameRulesEnum.DrowningDamage, false),
                new GameRule <bool>(GameRulesEnum.CommandblockOutput, false),
                new GameRule <bool>(GameRulesEnum.DoTiledrops, false),
                new GameRule <bool>(GameRulesEnum.DoMobloot, false),
                new GameRule <bool>(GameRulesEnum.KeepInventory, false),
                new GameRule <bool>(GameRulesEnum.DoDaylightcycle, false),
                new GameRule <bool>(GameRulesEnum.DoMobspawning, false),
                new GameRule <bool>(GameRulesEnum.DoEntitydrops, false),
                new GameRule <bool>(GameRulesEnum.DoFiretick, false),
                new GameRule <bool>(GameRulesEnum.DoWeathercycle, false),
                new GameRule <bool>(GameRulesEnum.Pvp, false),
                new GameRule <bool>(GameRulesEnum.Falldamage, false),
                new GameRule <bool>(GameRulesEnum.Firedamage, false),
                new GameRule <bool>(GameRulesEnum.Mobgriefing, false),
                new GameRule <bool>(GameRulesEnum.ShowCoordinates, false),
                new GameRule <bool>(GameRulesEnum.NaturalRegeneration, false),
                new GameRule <bool>(GameRulesEnum.TntExplodes, false),
                new GameRule <bool>(GameRulesEnum.SendCommandfeedback, false)
            };

            return(rules);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            GameRenderer renderer = new GameRenderer();

            GivenWordsModel givenWords = new GivenWordsModel();

            PlayerModel player = new PlayerModel();

            GameRules gameRules = new GameRules(player, givenWords);

            ClockModel clock = new ClockModel();

            renderer.RenderGameStart();
            clock.StartClock();
            while (!gameRules.GetGameStatus())
            {
                renderer.RenderClearConsole();
                renderer.RenderCurrentWords(givenWords);
                renderer.RenderPlayerInput(player);

                ConsoleKeyInfo userKey = Console.ReadKey();
                gameRules.CheckPlayerInput(userKey);
                gameRules.CheckGameOver();
            }
            clock.StopClock();

            StatisticsModel statistics = new StatisticsModel(givenWords, player, clock.GetTimeInMinutes());

            renderer.RenderEndGame(statistics, clock.GetTimeInSeconds());
            Console.ReadKey();
        }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        // Local setup stuff
        if (!isLocalPlayer)
        {
            return;
        }

        FindReferences();

        multManager = GameObject.FindGameObjectWithTag("MultiplayerManager").GetComponent <Multiplayer_Manager>();
        team        = GetCurTeam();
        CmdSpawnMyFlagship(team);
        CmdIncrementCurTeam();


        gameManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <Manager_Game>();
        gameRules   = gameManager.GameRules;       // Grab copy of Game Rules
        SetCommander(gameManager.GetCommander(team));
        gameManager.SetController(this);

        selection = new List <Entity>();
        Select(null, false);

        audioSource = GetComponent <AudioSource>();

        lineMouse.SetEffectActive(0);
        lineVert.SetEffectActive(0);

        SetMarqueeActive(false);

        commandWheel.SetController(this);
        SetCommandWheelActive(false);
    }
        public void AddMove_ValidMove_MoveExists()
        {
            //Arrange
            int       maxWins = 3;
            Move      move1   = new Move("Rock");
            Move      move2   = new Move("Scissors");
            Move      move3   = new Move("Paper");
            GameRules rules   = new GameRules(maxWins);

            move1.AddKill(move2.Name);
            move2.AddKill(move3.Name);
            move3.AddKill(move1.Name);

            //Act
            rules.AddMove(move1);
            rules.AddMove(move2);
            rules.AddMove(move3);

            //Assert
            ICollection <string> moves = rules.GetMoves();

            Assert.AreEqual(3, moves.Count);
            Assert.AreEqual(move1.Name, rules.GetMove(move1.Name).Name);
            Assert.AreEqual(move2.Name, rules.GetMove(move2.Name).Name);
            Assert.AreEqual(move3.Name, rules.GetMove(move3.Name).Name);
        }
Exemplo n.º 7
0
        protected CompetitionConfig(string name, League league, int order, int?competitionStartingDay, GameRules gameRules, List <CompetitionConfig> parents, List <CompetitionConfigFinalRankingRule> finalRankingRules, string finalRankingGroupName, int?firstYear, int?lastYear)
        {
            Name      = name;
            League    = league;
            Ordering  = order;
            GameRules = gameRules;
            Parents   = parents;
            FirstYear = firstYear;
            LastYear  = lastYear;
            CompetitionStartingDay = competitionStartingDay;
            FinalRankingGroupName  = finalRankingGroupName;
            if (parents == null)
            {
                Parents = new List <CompetitionConfig>();
            }
            else
            {
                Parents = parents;
            }

            if (finalRankingRules == null)
            {
                FinalRankingRules = new List <CompetitionConfigFinalRankingRule>();
            }
            else
            {
                FinalRankingRules = finalRankingRules;
            }
        }
Exemplo n.º 8
0
        // Ask if the player want to regret last move
        public static void displayRegretMessage()
        {
            // Display the chess board in console
            DisplayBoard.displayChessPanel();

            // Clear the input line
            Console.SetCursorPosition(0, 25);
            clearConsoleLine();
            // Clear the input message line
            Console.SetCursorPosition(0, 24);
            clearConsoleLine();
            // Display the regret confirmation message
            // If the player has no chance for regret anymore, no need to show this message
            if (Board.regretAmount[Board.currentColour % 2] > 0)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                if (Board.regretAmount[Board.currentColour % 2] == 1)
                {
                    Console.Write("This is your last chance to regret, sure? (y/n) ");
                }
                else if (Board.regretAmount[Board.currentColour % 2] > 1)
                {
                    Console.Write(Board.regretAmount[Board.currentColour % 2].ToString() + " chances left - Do you need to regret? (y/n) ");
                }
                Console.ResetColor();
                if (Console.ReadLine() == "y")
                {
                    GameRules.regret();
                }
            }
        }
Exemplo n.º 9
0
        public void HandleAnyPayOuts()
        {
            var dealerHand = GetDealerHand();
            var isLoopingThruPlayerHands = true;
            var i = 0;

            while (isLoopingThruPlayerHands)
            {
                var hand = Hands[i];
                if (hand.IsDealerHand())
                {
                    isLoopingThruPlayerHands = false;
                    break;
                }
                else
                {
                    if (hand.IsActive())
                    {
                        if (GameRules.DidHandBust(dealerHand) || (GameRules.CalcHandValue(hand) > GameRules.CalcHandValue(dealerHand)))
                        {
                            Logger.Write("You won! Congrats!");
                        }
                        else if (GameRules.CalcHandValue(hand) == GameRules.CalcHandValue(dealerHand))
                        {
                            Logger.Write("You drew!");
                        }
                        else
                        {
                            Logger.Write("You lost!");
                        }
                    }
                    i += 1;
                }
            }
        }
Exemplo n.º 10
0
        private void Start()
        {
            _gameEvents = GameEvents.Instance;
            _gameRules  = GameRules.Instance;

            gameObject.SetActive(false);

            _gameEvents.OnGameplayStart.AddListener(() =>
            {
                Cursor.lockState = CursorLockMode.Locked;
                gameObject.SetActive(false);
            });

            _gameEvents.OnGameOver.AddListener(() =>
            {
                gameObject.SetActive(true);
                Cursor.lockState = CursorLockMode.None;
            });

            restartButton.onClick.AddListener(() => { _gameRules.restartLevel(); });

            exitButton.onClick.AddListener(() =>
            {
                Application.Quit();
#if UNITY_EDITOR
                EditorApplication.isPlaying = false;
#endif
            });
        }
Exemplo n.º 11
0
        private int PlaySimulatedGame(GameState gstate)
        {
            GameState state = gstate.Clone();

            while (true)
            {
                //var moves = GameRules.GetMoves(state);
                //if (moves.Count == 0)
                //{
                //    break;
                //}
                var move = simulationStrategy.GetMove(state);
                if (move == null)
                {
                    break;
                }
                state.AddMove(move);
                state.SwapCurrentPlayer();
            }
            var result = (int)GameRules.GetGameResult(state);

            if (state.CurrentPlayerColor != gstate.CurrentPlayerColor)
            {
                result *= -1;
            }
            return(result);
        }
Exemplo n.º 12
0
        public Game(IActionQueue actionQueue, IPieceProvider pieceProvider, string name, int maxPlayers, int maxSpectators, GameRules rule, GameOptions options, string password = null)
        {
            if (actionQueue == null)
                throw new ArgumentNullException("actionQueue");
            if (pieceProvider == null)
                throw new ArgumentNullException("pieceProvider");
            if (name == null)
                throw new ArgumentNullException("name");
            if (maxPlayers <= 0)
                throw new ArgumentOutOfRangeException("maxPlayers", "maxPlayers must be strictly positive");
            if (maxSpectators <= 0)
                throw new ArgumentOutOfRangeException("maxSpectators", "maxSpectators must be strictly positive");
            if (options == null)
                throw new ArgumentNullException("options");

            Id = Guid.NewGuid();
            _actionQueue = actionQueue;
            _pieceProvider = pieceProvider;
            _pieceProvider.Occurancies = () => options.PieceOccurancies;
            Name = name;
            CreationTime = DateTime.Now;
            MaxPlayers = maxPlayers;
            MaxSpectators = maxSpectators;
            Rule = rule;
            Options = options;
            Password = password;
            State = GameStates.Created;

            _specialId = 0;
            _isSuddenDeathActive = false;
            _gameStatistics = new Dictionary<string, GameStatisticsByPlayer>();
            _winList = new List<WinEntry>();
            _suddenDeathTimer = new Timer(SuddenDeathCallback, null, Timeout.Infinite, 0);
            _voteKickTimer = new Timer(VoteKickCallback, null, Timeout.Infinite, 0);
        }
Exemplo n.º 13
0
 public void SetUp()
 {
     rules      = GameRules.Default;
     fieldSize  = rules.FieldSize;
     shipsCount = rules.ShipsCount.ToDictionary(x => x.Key, x => x.Value);
     builder    = new GameFieldBuilder(rules);
 }
Exemplo n.º 14
0
        public void NotBuildField_WhenThereAreTooManyShips()
        {
            shipsCount = new Dictionary <ShipType, int> {
                { ShipType.Submarine, 1 }, { ShipType.Destroyer, 2 }
            };
            rules   = new GameRules(fieldSize, shipsCount);
            builder = new GameFieldBuilder(rules);

            var cells = new[]
            {
                new CellPosition(0, 0),
                new CellPosition(7, 2),
                new CellPosition(9, 7),

                new CellPosition(6, 4),
                new CellPosition(6, 5),

                new CellPosition(2, 1),
                new CellPosition(2, 2)
            };

            foreach (var cell in cells)
            {
                builder.TryAddShipCell(cell);
            }

            foreach (var shipType in Enum.GetValues(typeof(ShipType)).Cast <ShipType>())
            {
                shipsCount[shipType] = 0;
            }

            builder.Build().Should().BeNull();
        }
Exemplo n.º 15
0
        private static void ShowExecutionTimeLog()
        {
            string log = string.Format("\nTemps d'exexution: {0}\n", (DateTime.Now - m_StartingTime).TotalSeconds);

            GameRules.Log(log);
            Console.ReadLine();
        }
Exemplo n.º 16
0
    public static List <GameRules> GetSavedRuleSets()
    {
        if (savedRules.Count == 0)
        {
            string directoryString = PlayerPrefs.GetString(ruleSetDirectoryName);

            if (!string.IsNullOrWhiteSpace(directoryString))
            {
                List <string> directoryJson = JsonConvert.DeserializeObject <List <string> >(directoryString);

                foreach (string ruleGuid in directoryJson)
                {
                    string ruleString = PlayerPrefs.GetString(ruleGuid);

                    if (string.IsNullOrWhiteSpace(ruleString))
                    {
                        Debug.LogError($"Saved rule set at {ruleGuid} was empty, disregarding");
                    }
                    else
                    {
                        GameRules deserializedRules = JsonConvert.DeserializeObject <GameRules>(ruleString);
                        savedRules.Add(deserializedRules);
                    }
                }
            }
        }

        return(savedRules);
    }
Exemplo n.º 17
0
        private static void UNITY_CallCamelUpExe(string aBoard, string aCards)
        {
            Process process = new Process();

            try
            {
                process.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                process.StartInfo.CreateNoWindow         = true;
                process.StartInfo.UseShellExecute        = false;
                process.EnableRaisingEvents              = true;
                process.StartInfo.RedirectStandardOutput = true;

                process.StartInfo.FileName  = Directory.GetCurrentDirectory() + "/CamelUpData.exe";
                process.StartInfo.Arguments = aBoard + " " + aCards;

                process.Start();

                string result = process.StandardOutput.ReadToEnd();

                GameRules.Log(string.Format("CamelEXE Result: {0}", result));
                process.Close();
            }
            catch (Exception ex)
            {
                GameRules.Log(string.Format("CamelEXE Exception: {0}", ex.Message));
                process.Close();
            }
        }
Exemplo n.º 18
0
    public static GameRules GetInitialGameRule()
    {
        string lastUsedRuleSetGuid = PlayerPrefs.GetString(lastUsedRuleSetName, "");

        if (!string.IsNullOrWhiteSpace(lastUsedRuleSetGuid))
        {
            GameRules defaultMatchingRule = GetDefaultGameRules().FirstOrDefault(rules => rules.RuleSetGUID == lastUsedRuleSetGuid);

            if (defaultMatchingRule != null)
            {
                return(defaultMatchingRule);
            }

            GameRules matchingRules = savedRules.FirstOrDefault(rules => rules.RuleSetGUID == lastUsedRuleSetGuid);

            if (matchingRules != null)
            {
                return(matchingRules);
            }
            else
            {
                Debug.LogError($"Saved rule set at {lastUsedRuleSetGuid} was empty, disregarding");
            }
        }

        return(GetDefaultGameRules().First());
    }
Exemplo n.º 19
0
        /// <summary>
        /// Orders the card collection by number.
        /// </summary>
        public void OrderByNumber(GameRules rules)
        {
            ExceptionHelpers.CheckNotNull(rules, "rules");

            CardCollection copy = this.Copy();

            this.Clear();

            int minNum = (int)rules.MinimumCardNumber;
            int maxNum = (int)rules.MaximumCardNumber;
            int minCol = (int)rules.MinimumCardColor;
            int maxCol = (int)rules.MaximumCardColor;

            for (int num = minNum; num <= maxNum; num++)
            {
                for (int col = minCol; col <= maxCol; col++)
                {
                    while (true)
                    {
                        Card c = copy.RemoveCardWithNumberAndColor((CardNumber)num, (CardColor)col);

                        if (c == null)
                        {
                            break;
                        }

                        this.Add(c);
                    }
                }
            }

            this.OnItemsChanged();
        }
Exemplo n.º 20
0
        public void BuildField_WhenDataCorrect()
        {
            shipsCount = new Dictionary <ShipType, int> {
                { ShipType.Submarine, 3 }, { ShipType.Destroyer, 2 }
            };
            rules   = new GameRules(fieldSize, shipsCount);
            builder = new GameFieldBuilder(rules);

            var cells = new[]
            {
                new CellPosition(0, 0),
                new CellPosition(7, 2),
                new CellPosition(9, 7),

                new CellPosition(6, 4),
                new CellPosition(6, 5),

                new CellPosition(2, 1),
                new CellPosition(2, 2)
            };

            foreach (var cell in cells)
            {
                builder.TryAddShipCell(cell);
            }

            builder.Build().Should().NotBeNull();
        }
Exemplo n.º 21
0
        public void PlayDealerHand()
        {
            var dealerHand = GetDealerHand();

            Logger.Write("Dealer has:");
            dealerHand.PrintHand();
            if (IsAPlayerHandActive())
            {
                var continueLoop = true;
                while (continueLoop)
                {
                    if (GameRules.ShouldDealerHit(dealerHand))
                    {
                        DealCardToHand(dealerHand, false);
                        Thread.Sleep(1000); // Pause for effect
                    }
                    else
                    {
                        continueLoop = false;
                        if (GameRules.DidHandBust(dealerHand))
                        {
                            Logger.Write("Dealer busted.");
                        }
                    }
                }
            }
            else
            {
                Logger.Write("Dealer does not play hand since no player hands still in play.");
            }
        }
Exemplo n.º 22
0
        public void ReturnCorrectShipsLeftCounter_WhenAllShipsUsed()
        {
            shipsCount = new Dictionary <ShipType, int> {
                { ShipType.Submarine, 3 }, { ShipType.Destroyer, 2 }
            };
            rules   = new GameRules(fieldSize, shipsCount);
            builder = new GameFieldBuilder(rules);

            var cells = new[]
            {
                new CellPosition(0, 0),
                new CellPosition(7, 2),
                new CellPosition(9, 7),

                new CellPosition(6, 4),
                new CellPosition(6, 5),

                new CellPosition(2, 1),
                new CellPosition(2, 2)
            };

            foreach (var cell in cells)
            {
                builder.TryAddShipCell(cell);
            }

            foreach (var shipType in Enum.GetValues(typeof(ShipType)).Cast <ShipType>())
            {
                shipsCount[shipType] = 0;
            }

            builder.ShipsLeft.Should().BeEquivalentTo(shipsCount);
        }
Exemplo n.º 23
0
        public static PlayoffCompetitionConfig CreateSmallPlayoffConfiguration(League league, List <CompetitionConfig> parents, int order, int?startingDay, int?firstYear, int?lastYear)
        {
            var playoffConfig = new PlayoffCompetitionConfig("My Playoff", league, order, startingDay, null, firstYear, lastYear, null, null, parents, null);

            var gameRules = new GameRules("Playoff Rules", false, 1, 3, 120, true);

            playoffConfig.GameRules = gameRules;

            playoffConfig.Parents = parents;

            var regularSeasonConfig = parents.Where(c => c.Name == "Regular Season").First();

            playoffConfig.RankingRules = new List <PlayoffRankingRule>();

            playoffConfig.SeriesRules = new List <PlayoffSeriesRule>()
            {
                new PlayoffSeriesRule(playoffConfig, "Semi Final A", 1, PlayoffSeriesRule.Type.BestOf, 4, gameRules, "NHL", 1, "NHL", 4, 1, null, new int[]  { 0, 0, 1, 1, 0, 1, 0 }, "FINALISTS", "NHL", null, null),
                new PlayoffSeriesRule(playoffConfig, "Semi Final B", 1, PlayoffSeriesRule.Type.BestOf, 4, gameRules, "NHL", 2, "NHL", 3, 1, null, new int[] { 0, 0, 1, 1, 0, 1, 0 }, "FINALISTS", "NHL", null, null),

                new PlayoffSeriesRule(playoffConfig, "Final", 2, PlayoffSeriesRule.Type.BestOf, 4, gameRules, "FINALISTS", 1, "FINALISTS", 2, 1, null, new int[] { 0, 0, 1, 1, 0, 1, 0 }, null, null, null, null),
            };

            league.CompetitionConfigs.Add(playoffConfig);

            return(playoffConfig);
        }
        public static Designator FindAllowedDesignator <T>() where T : Designator
        {
            List <DesignationCategoryDef> allDefsListForReading = DefDatabase <DesignationCategoryDef> .AllDefsListForReading;
            GameRules rules = Current.Game.Rules;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                List <Designator> allResolvedDesignators = allDefsListForReading[i].AllResolvedDesignators;
                for (int j = 0; j < allResolvedDesignators.Count; j++)
                {
                    if (rules.DesignatorAllowed(allResolvedDesignators[j]))
                    {
                        T t = allResolvedDesignators[j] as T;
                        if (t != null)
                        {
                            return(t);
                        }
                    }
                }
            }
            Designator designator = DesignatorUtility.StandaloneDesignators.TryGetValue(typeof(T), null);

            if (designator == null)
            {
                designator = (Activator.CreateInstance(typeof(T)) as Designator);
                DesignatorUtility.StandaloneDesignators[typeof(T)] = designator;
            }
            return(designator);
        }
Exemplo n.º 25
0
        public override void DoAction(IEventArgs args)
        {
            foreach (PlayerEntity player in args.GameContext.player.GetInitializedPlayerEntities())
            {
                player.playerInfo.Camp    = 3 - player.playerInfo.Camp;
                player.gamePlay.CastState = 6 - player.gamePlay.CastState;

                if (player.playerInfo.CampInfo == null)
                {
                    continue;
                }

                switch (GameRules.ClothesType(args.GameContext.session.commonSession.RoomInfo.ModeId))
                {
                case (int)EGameModeClothes.SingleCamp:
                case (int)EGameModeClothes.DualCamp:
                    if (player.playerInfo.CampInfo.CurrCamp != player.playerInfo.Camp)
                    {
                        player.playerInfo.CampInfo.CurrCamp = player.playerInfo.Camp;
                        foreach (Preset p in player.playerInfo.CampInfo.Preset)
                        {
                            if (p.camp == player.playerInfo.Camp)
                            {
                                player.gamePlay.NewRoleId = p.roleModelId;
                                break;
                            }
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
        public IActionResult Index(Guid?id, GameStateSpecificationViewModel vm)
        {
            ModelState.Clear();

            vm.Id       = id;
            vm.AllShips = CreateShipOptions().ToList();
            RemoveEmptyEntriesAndEnsureLastOptionEmpty(vm);



            foreach (var ship in vm.SelectedShips)
            {
                var isShipSelected = !string.IsNullOrWhiteSpace(ship.Code);
                if (!isShipSelected)
                {
                    continue;
                }

                var spec = GameRules.GetShipByCode(ship.Code);
                if (string.IsNullOrWhiteSpace(ship.Name))
                {
                    ship.Name = spec.Registry
                                + GetNextRegistryNumber(vm.SelectedShips, spec.Registry).ToString().PadLeft(3, '0')
                                + " " + spec.Name;
                }
            }

            return(View(vm));
        }
Exemplo n.º 27
0
        public UpdateDiscardMessage(byte [] b, int [] ids, GameRules rules) : base(b)
        {
            Validate(ids, rules);
            if ((int)msg[1] == 0)
            {
                _card = null;
            }
            else
            {
                int id = (int)msg[5];
                id <<= 8;
                id  += (int)msg[6];

                int col  = (int)msg[2];
                int num  = (int)msg[3];
                int wild = (int)msg[4];

                if (wild == 1)
                {
                    _card        = new Card(CardNumber.Wild, (CardColor)col, id);
                    _card.Number = (CardNumber)num;
                }
                else
                {
                    _card = new Card((CardNumber)num, (CardColor)col, id);
                }
            }
            _discarded = ((int)msg[7] == 1);
            _playerId  = (int)msg[8];
        }
Exemplo n.º 28
0
        void enterIntoDB()
        {
            string filename;
            string path = Server.MapPath("~/rules/");

            filename = "no rules";
            if (GameRules.HasFile)
            {
                filename = "~/rules/" + GameRules.FileName;

                GameRules.SaveAs(path + GameRules.FileName);
            }
            try
            {
                SqlConnection GameCon = new SqlConnection(ConfigurationManager.ConnectionStrings["EventsConnectionString"].ConnectionString);
                SqlCommand    inData  = new SqlCommand("INSERT INTO GAME(GameID,GameCode,GameName,GameDuration,GameDescription,GameRules) VALUES (@ID,@Code,@Name,@Duration,@Description,@Rules)", GameCon);
                inData.Parameters.AddWithValue("@ID", GameID1.Text);
                inData.Parameters.AddWithValue("@Code", GameCode.Text);
                inData.Parameters.AddWithValue("@Name", GameName.Text);
                inData.Parameters.AddWithValue("@Duration", GameDuration.Text);
                inData.Parameters.AddWithValue("@Description", GameDescription.Text);
                inData.Parameters.AddWithValue("@Rules", filename);
                GameCon.Open();
                inData.ExecuteNonQuery();
                GameCon.Close();
                cleartext();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 29
0
        public PlayedCardOnTableMessage(byte [] b, int [] ids, GameRules rules) : base(b)
        {
            Validate(ids, rules);
            _playerId = (int)msg[1];
            int g_id_ptr = 2;
            int type_ptr = 3;
            int cr_ptr   = 4;
            int num_ptr  = 6;
            int col_ptr  = 5;
            int wild_ptr = 7;
            int c_id_ptr = 8; //this will start a 2 byte section

            int type     = (int)msg[type_ptr];
            int id       = (int)msg[g_id_ptr];
            int cardsreq = (int)msg[cr_ptr];

            _group    = Group.Create((GroupType)type, cardsreq);
            _group.Id = id;

            id = (((int)msg[c_id_ptr]) << 8) + ((int)msg[c_id_ptr + 1]);
            if ((int)msg[wild_ptr] == 1)
            {
                _card        = new Card(CardNumber.Wild, (CardColor)msg[col_ptr], id);
                _card.Number = (CardNumber)msg[num_ptr];
            }
            else
            {
                _card = new Card((CardNumber)msg[num_ptr], (CardColor)msg[col_ptr], id);
            }
        }
Exemplo n.º 30
0
        public void ShouldProcessGame()
        {
            var seasonConfig = new SeasonCompetitionConfig("Test", null, 1, null, null, 1, null, null, null, null, null, null);
            var season       = new Season(seasonConfig, seasonConfig.Name, 1, null, null, null, null, true, false, 1, null);
            var teams        = new List <Team>()
            {
                CreateTeam("Team 1", 1), CreateTeam("Team 2", 2), CreateTeam("Team 3", 3), CreateTeam("Team 4", 4)
            };
            var rules = new GameRules(null, true, 1, 3, 10, true);
            var games = new List <ScheduleGame>()
            {
                new ScheduleGame(null, 1, 1, 1, teams[0], null, teams[1], null, 1, 1, true, 1, 0, rules, false),
                new ScheduleGame(null, 1, 1, 1, teams[0], null, teams[2], null, 3, 1, true, 1, 0, rules, false),
                new ScheduleGame(null, 1, 1, 1, teams[0], null, teams[3], null, 1, 4, true, 1, 0, rules, false)
            };

            var team1 = new SeasonTeam(null, teams[0], "Team 1", null, null, 5, null, 1, null, null, null);
            var team2 = new SeasonTeam(null, teams[1], "Team 2", null, null, 5, null, 1, null, null, null);
            var team3 = new SeasonTeam(null, teams[2], "Team 3", null, null, 5, null, 1, null, null, null);
            var team4 = new SeasonTeam(null, teams[3], "Team 4", null, null, 5, null, 1, null, null, null);

            season.Teams = new List <CompetitionTeam>()
            {
                team1, team2, team3, team4
            };

            games.ForEach(g => { season.ProcessGame(g, 1); });

            StrictEqual(3, team1.Stats.Games);
            StrictEqual(3, team1.Stats.Points);
            StrictEqual(1, team1.Stats.Wins);
            StrictEqual(1, team1.Stats.Loses);
            StrictEqual(1, team1.Stats.Ties);
            StrictEqual(5, team1.Stats.GoalsFor);
            StrictEqual(6, team1.Stats.GoalsAgainst);

            StrictEqual(1, team2.Stats.Games);
            StrictEqual(1, team2.Stats.Points);
            StrictEqual(0, team2.Stats.Wins);
            StrictEqual(0, team2.Stats.Loses);
            StrictEqual(1, team2.Stats.Ties);
            StrictEqual(1, team2.Stats.GoalsFor);
            StrictEqual(1, team2.Stats.GoalsAgainst);

            StrictEqual(1, team3.Stats.Games);
            StrictEqual(0, team3.Stats.Points);
            StrictEqual(0, team3.Stats.Wins);
            StrictEqual(1, team3.Stats.Loses);
            StrictEqual(0, team3.Stats.Ties);
            StrictEqual(1, team3.Stats.GoalsFor);
            StrictEqual(3, team3.Stats.GoalsAgainst);

            StrictEqual(1, team4.Stats.Games);
            StrictEqual(2, team4.Stats.Points);
            StrictEqual(1, team4.Stats.Wins);
            StrictEqual(0, team4.Stats.Loses);
            StrictEqual(0, team4.Stats.Ties);
            StrictEqual(4, team4.Stats.GoalsFor);
            StrictEqual(1, team4.Stats.GoalsAgainst);
        }
Exemplo n.º 31
0
        /**
         * Updates the infomation panel descripting the raising details for the selected character
         */
        private void doUpdateRaiseInfo()
        {
            MDRCharacter character = deadCharactersList.Selected;

            raiseCost = GameRules.CostToRaise(character);

            if (character == null)
            {
                raiseInfo.Caption = "";
                costLabel.Visible = false;
                return;
            }

            string notice = "{0} has died.";

            if (raiseCost == 0)
            {
                notice += "\n\nBecause {0} is less than level 10 the temple has agreed to raise him for free.";
            }
            else
            {
                notice += "\n\nThe cost to raise {0} is {1}";
                if (raiseCost > CoM.Party.Gold)
                {
                    notice += "\nHowever you only have {2}.";
                }
            }

            raiseInfo.Caption = string.Format(notice, CoM.Format(character), CoM.CoinsAmount(raiseCost), CoM.CoinsAmount(CoM.Party.Gold));

            costLabel.Visible = true;
            costLabel.Value   = raiseCost;
        }
    // Use this for initialization
    void Start()
    {
        //link to the main controller
        controller = gameRules.GetComponent<GameRules>();

        //sets the starting material
        naturalColor = gameObject.transform.renderer.material.color;
    }
Exemplo n.º 33
0
        private static void Main(string[] args)
        {
            var gameRule = new GameRules();
            var gameOfLife = new Console.Helpers.GameOfLife(gameRule);
            gameOfLife.Start();

            System.Console.ReadLine();
        }
    // Use this for initialization
    void Start()
    {
        //establishes link to game controller script
        controller = gameRules.GetComponent<GameRules>();

        //establishes link to player scripts
        stats = controller.player.GetComponent<PlayerStats>();
        movement = controller.player.GetComponent<PlayerMovement>();
    }
Exemplo n.º 35
0
        public MiniMaxPlayer(string playerName, GridValue playerSide, GameRules rules)
        {
            PlayerName = playerName;
            PlayerSide = playerSide;

            var problem = new TicTacToeAdversarialSearchProblem();
            var stateEvaluator = new TicTacToeStateEvaluator(PlayerSide, rules);
            _search = new AdversarialSearch<TicTacToeState, Move>(problem, stateEvaluator);
        }
Exemplo n.º 36
0
    void Awake()
    {
        motor = GetComponent<CharacterController>();
        hotspot = transform.Find("hotspot");
        ballChargeProgress = transform.Find("charge_progress");
        progressOrigin = ballChargeProgress.localPosition;
        gameRules = FindObjectOfType(typeof(GameRules)) as GameRules;

        lives = maxLives;
    }
Exemplo n.º 37
0
    // Use this for initialization
    void Start()
    {
		
		m_GameRules = GameManager.GetGameRules();

        //Attach camera to each canvas in ui manager
        foreach (Canvas canvas in GetComponentsInChildren<Canvas>())
        {
            canvas.worldCamera = Camera.main;
        }

    }
Exemplo n.º 38
0
 static void Main(string[] args)
 {
     //fetch the dependencies - here we just create them
     var neighbourCalculator = new NeighbourCalculator();
     var gameRules = new GameRules(new LiveCellRule(), new DeadCellRule());
     var evolution = new Evolution(neighbourCalculator, gameRules);
     var gridRowColumnParser = new GridRowColumnParser();
     //typically we would create such an object and inject its dependencies
     //using an IoC container
     IGameOfLife gameOfLife = new GameOfLifeUI.GameOfLife(evolution, gridRowColumnParser);
     gameOfLife.Start();
 }
 public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules, IGameLog log)
 {
   if (GetType().Assembly.Location.Contains("TakeForever"))
   {
     System.Threading.Thread.Sleep(TimeSpan.FromMinutes(10));
   }
   if (_random.NextDouble() > 0.5)
   {
     return Round1Move.Paper;
   }
   return Round1Move.Rock;
 }
Exemplo n.º 40
0
 public GameRuleGoalPlacer(GameRules gr)
 {
     gameRules = gr;
     //pull out the goal area information
     Transform goalAreaTransform = gr.goalArea.transform;
     Vector3 goalAreaLocalScale = goalAreaTransform.localScale;
     Vector3 goalAreaLocalPosition = goalAreaTransform.localPosition;
     goalAreaBounds = new Rect(
         goalAreaLocalPosition.x - (goalAreaLocalScale.x * 0.5f),
         goalAreaLocalPosition.z - (goalAreaLocalScale.z * 0.5f),
         goalAreaLocalScale.x,
         goalAreaLocalScale.z);
     GameObject.Destroy(gr.goalArea);
 }
Exemplo n.º 41
0
    //private LineRenderer lineRenderer;
    // Use this for initialization
    void Start()
    {
        //lineRenderer = GetComponent<LineRenderer> ();
        //lineRenderer.SetVertexCount (laserNumSegments);
        //lineRenderer.SetPosition (0, Vector3.zero);

        GameObject newGun = (GameObject)Instantiate (gun, Vector3.zero, Quaternion.identity);
        newGun.transform.parent = transform;
        newGun.transform.localPosition = Vector3.zero;
        newGun.transform.localRotation = Quaternion.identity;
        laserGun = newGun.GetComponent<LaserGun> ();

        damageTaker = GetComponent<DamageTaker> ();
        cameraTracker = Camera.main.GetComponent<CameraTracker> ();
        gameRules = Camera.main.GetComponent<GameRules> ();
    }
Exemplo n.º 42
0
    void Awake()
    {
        dictionary=new List<String>();

        if (!(gameRules)) {
            gameRules=GameObject.Find("Game").GetComponent<GameRules>();
        }

        //open the dictionary data file
        FileInfo dictionaryData = new FileInfo ("Assets\\Resources\\Rules\\dictionary.txt");
        StreamReader dictionaryDataReader = dictionaryData.OpenText();
        //read each line and add the results to the dictionary list
        while (dictionaryDataReader.Peek()>=0) {
            GameRules.dictionary.Add(dictionaryDataReader.ReadLine());
        }
        dictionaryDataReader.Close();
        //Debug.Log(dictionary.Count.ToString());
    }
Exemplo n.º 43
0
        public SimpleMap(int sideSize, GameRules rules)
        {
            this.SideSize = sideSize;
            this.Rules = rules;

            int arraySize = SideSize * SideSize;
            CellMap = new Cell[arraySize];
            CellBuffer = new Cell[arraySize];

            Point point;
            for (int x = 0; x < arraySize; x++)
            {
                //Translate x/y coordinates into 1Dimensional array index
                point.X = x % SideSize;
                point.Y = x / SideSize;
                CellMap[x] = new Cell(point, false);
                CellBuffer[x] = new Cell(point, false);
            }
        }
        public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules, IGameLog log)
        {
            string youLastMove = you.LastMove == null ? String.Empty : you.LastMove.ToString().Trim();
            string opponentLastMove = opponent.LastMove == null ? String.Empty : opponent.LastMove.ToString().Trim();

            string url = String.Format(template, this.teamUrl, this.roundGuid,
                youLastMove, you.Points, you.TeamName,
                opponentLastMove, opponent.Points, opponent.TeamName,
                rules.MaximumGames, rules.PointsToWin);

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            using (WebResponse response = request.GetResponse())
            {
                using (Stream stream = response.GetResponseStream())
                {
                    string move = new StreamReader(stream).ReadToEnd();
                    return Round1Move.Moves[move];
                }
            }
        }
Exemplo n.º 45
0
    /// <summary>
    /// This is called directly from a solo game or one where you are hosting; it is also called on
    /// clients after the server tells them what the game rules are. This function will add a component
    /// to the game director which controls how the game is run. Without calling this, the playfield 
    /// would be empty and nothing would ever happen.
    /// </summary>
    /// <param name='rulesName'>
    /// The name of the game rules set.
    /// </param>
    private void BeginGame(string rulesName)
    {
        Debug.Log("in BeginGame with rules: " + gameRules);

        if ("FreeForAll" == rulesName)
        {
            gameRules = (GameRules)gameObject.AddComponent<GameRules_FFA>();
        }
        else
        {
            // This should never happen
            Debug.LogError("Unhandled game rule type: " + gameRules + "!");
            return;
        }

        // Send a message to the rules component to begin the game. This is where the scores are
        // reset, players are spawned, etc. This is the part where this player, whether they be the
        // host or a client who just joined, creates themselves on the playfield.
        SendMessage("OnBeginGame");
    }
Exemplo n.º 46
0
 public Game(GameRules gameRules, SetRules setRules, RoundRules roundRules)
 {
     RoundRules = roundRules;
     SetRules = setRules;
     GameRules = gameRules;
 }
Exemplo n.º 47
0
 public void SetRules(GameRules gr)
 {
     this.gr = gr;
 }
 public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules, IGameLog log)
 {
   return moves[random.Next(3)];
 }
Exemplo n.º 49
0
 protected abstract IGame CreateGame(string name, int maxPlayers, int maxSpectators, GameRules rule, GameOptions options, string password);
Exemplo n.º 50
0
 protected override IGame CreateGame(string name, int maxPlayers, int maxSpectators, GameRules rule, GameOptions options, string password)
 {
     return new Game(new ActionQueueMock(), new PieceProviderMock(), name, maxPlayers, maxSpectators, rule, options, password);
 }
Exemplo n.º 51
0
 public void ClientCreateAndJoinGame(string name, string password, GameRules rule, bool asSpectator)
 {
     IClient client = ClientManager[ClientCallback];
     if (client != null)
         HostClientCreateAndJoinGame.Do(x => x(client, name, password, rule, asSpectator));
     else
         Log.Default.WriteLine(LogLevels.Warning, "ClientCreateAndJoinGame from unknown client");
 }
 // Use this for initialization
 void Start()
 {
     proximity = gameObject.GetComponent<Deactivation>();
     controller = gameRules.GetComponent<GameRules>();
     playerWeapon = controller.playerWeapon.GetComponent<WeaponScript>();
 }
Exemplo n.º 53
0
 public void ClientCreateAndJoinGame(string name, string password, GameRules rule, bool asSpectator)
 {
     IClient client = ClientManager[ClientCallback];
     if (client != null && HostClientCreateAndJoinGame != null)
         HostClientCreateAndJoinGame(client, name, password, rule, asSpectator);
 }
Exemplo n.º 54
0
 public void AdminCreateGame(string name, GameRules rule, string password)
 {
     IAdmin admin = AdminManager[AdminCallback];
     if (admin != null && HostAdminCreateGame != null)
         HostAdminCreateGame(admin, name, rule, password);
 }
Exemplo n.º 55
0
 public void Initialize(GameRules rule)
 {
     switch (rule)
     {
         case GameRules.Classic:
             PieceOccurancies = new List<PieceOccurancy>
                 {
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoJ,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoZ,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoO,
                             Occurancy = 15
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoL,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoS,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoT,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoI,
                             Occurancy = 15
                         },
                 };
             SpecialOccurancies = new List<SpecialOccurancy>( /*empty*/);
             ClassicStyleMultiplayerRules = true;
             NoSpecials = true;
             InventorySize = 0;
             LinesToMakeForSpecials = 0;
             SpecialsAddedEachTime = 0;
             StartingLevel = 0;
             DelayBeforeSuddenDeath = 5;
             SuddenDeathTick = 5;
             break;
         case GameRules.Custom: // Custom starts as Standard
         case GameRules.Standard:
             PieceOccurancies = new List<PieceOccurancy>
                 {
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoJ,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoZ,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoO,
                             Occurancy = 15
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoL,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoS,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoT,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoI,
                             Occurancy = 15
                         },
                 };
             SpecialOccurancies = new List<SpecialOccurancy>
                 {
                     new SpecialOccurancy
                         {
                             Value = Specials.AddLines,
                             Occurancy = 13
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.ClearLines,
                             Occurancy = 13
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.NukeField,
                             Occurancy = 3
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.RandomBlocksClear,
                             Occurancy = 11
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.SwitchFields,
                             Occurancy = 3
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.ClearSpecialBlocks,
                             Occurancy = 10
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.BlockGravity,
                             Occurancy = 6
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.BlockQuake,
                             Occurancy = 11
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.BlockBomb,
                             Occurancy = 10
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.ClearColumn,
                             Occurancy = 5
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.Immunity,
                             Occurancy = 3
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.Darkness,
                             Occurancy = 5
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.Confusion,
                             Occurancy = 0
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.Mutation,
                             Occurancy = 7
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.ZebraField,
                             Occurancy = 0
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.LeftGravity,
                             Occurancy = 0
                         },
                 };
             ClassicStyleMultiplayerRules = true;
             NoSpecials = false;
             InventorySize = 10;
             LinesToMakeForSpecials = 1;
             SpecialsAddedEachTime = 1;
             StartingLevel = 50;
             DelayBeforeSuddenDeath = 2;
             SuddenDeathTick = 5;
             break;
         case GameRules.Extended:
             PieceOccurancies = new List<PieceOccurancy>
                 {
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoJ,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoZ,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoO,
                             Occurancy = 15
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoL,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoS,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoT,
                             Occurancy = 14
                         },
                     new PieceOccurancy
                         {
                             Value = Pieces.TetriminoI,
                             Occurancy = 15
                         },
                 };
             SpecialOccurancies = new List<SpecialOccurancy>
                 {
                     new SpecialOccurancy
                         {
                             Value = Specials.AddLines,
                             Occurancy = 11
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.ClearLines,
                             Occurancy = 11
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.NukeField,
                             Occurancy = 3
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.RandomBlocksClear,
                             Occurancy = 10
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.SwitchFields,
                             Occurancy = 3
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.ClearSpecialBlocks,
                             Occurancy = 9
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.BlockGravity,
                             Occurancy = 6
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.BlockQuake,
                             Occurancy = 9
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.BlockBomb,
                             Occurancy = 9
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.ClearColumn,
                             Occurancy = 5
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.Immunity,
                             Occurancy = 3
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.Darkness,
                             Occurancy = 5
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.Confusion,
                             Occurancy = 3
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.Mutation,
                             Occurancy = 7
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.ZebraField,
                             Occurancy = 3
                         },
                     new SpecialOccurancy
                         {
                             Value = Specials.LeftGravity,
                             Occurancy = 3
                         },
                 };
             ClassicStyleMultiplayerRules = true;
             NoSpecials = false;
             InventorySize = 10;
             LinesToMakeForSpecials = 1;
             SpecialsAddedEachTime = 1;
             StartingLevel = 50;
             DelayBeforeSuddenDeath = 2;
             SuddenDeathTick = 5;
             break;
     }
     FixOccurancies();
 }
Exemplo n.º 56
0
 public void ClientCreateAndJoinGame(string name, string password, GameRules rule, bool asSpectator)
 {
     SetCallbackAndAddress();
     Host.ClientCreateAndJoinGame(name, password, rule, asSpectator);
 }
Exemplo n.º 57
0
 public void AdminCreateGame(string name, GameRules rule, string password)
 {
     SetCallbackAndAddress();
     Host.AdminCreateGame(name, rule, password);
 }
Exemplo n.º 58
0
    // This is called by GameManagerObject's Awake() - Scene objects are initialised for pointers
    public static void LevelLoadBegin(float m_Roomtemperature, float m_Temperaturechange, float m_Abilitytemperaturechange, float levelLength)
    {
        // Initialise managers.

        temperatureValues[0] = m_Roomtemperature;
        temperatureValues[1] = m_Temperaturechange;
        temperatureValues[2] = m_Abilitytemperaturechange;

        m_LevelLength = levelLength;

        GameObject o;
        o = Object.Instantiate(Resources.Load(UIMANAGER_NAME)) as GameObject;
        g_pUIManager = o.GetComponent<UIManager>();

        o = Object.Instantiate(Resources.Load(GAMERULES_NAME)) as GameObject;
        g_pGameRules = o.GetComponent<GameRules>();

        o = Object.Instantiate(Resources.Load(TEMPERATUREMANAGER_NAME)) as GameObject;
        g_pTemperatureManager = o.GetComponent<TemperatureManager>();

        // Grab the player from the scene.

        g_pPlayer = GameObject.FindGameObjectWithTag(PLAYER_NAME).GetComponent<Player>();

    }
Exemplo n.º 59
0
 public void AdminCreateGame(string name, GameRules rule, string password)
 {
     UpdateCallCount();
 }
Exemplo n.º 60
0
    // Use this for initialization
    void Start()
    {
        RealPlayer localPlayer = GameObject.FindGameObjectWithTag("LocalPlayer").GetComponent<RealPlayer>();

        if (localPlayer == null)
        {
            throw new System.Exception("Object not found");
        }

        players = new List<GamePlayer>();
        players.Add(localPlayer);
        GameObject playerTwoObject = new GameObject();
        RandoAIPlayer playerTwo = playerTwoObject.AddComponent<RandoAIPlayer>();
        playerTwo.setInitialProperties(board, this);
        //ISSUE:  RandoAIPlayer is not getting its initial values assigned to it.  Need a prefab.
        players.Add(playerTwoObject.GetComponent<RandoAIPlayer>());

        currentTurnPlayer = players[0];

        board = GameObject.Find("Board").GetComponent<Board>();

        //This can be replaced by another game.
        _gameRules = new GameRules();
        gameRules.setUpBoard(board, players);
    }