public void Test_Wrong_Exit_Point()
        {
            List <Library.Action> actions = new List <Library.Action>()
            {
                Library.Action.Move,
                Library.Action.Rotate,
                Library.Action.Move,
                Library.Action.Move,
                Library.Action.Move,
                Library.Action.Move,
                Library.Action.Rotate,
                Library.Action.Move,
                Library.Action.Move
            };

            try
            {
                var setup = new SetupGame(config, actions);
                setup.ValidateBoard();
            }
            catch (Exception e)
            {
                Assert.True(true);
            }
        }
Beispiel #2
0
    private void Awake()
    {
        SetupGame = GetComponent <SetupGame>();
        SetupGame.StartCoroutine("GetWordsFromTheServerAndStartFirstLevel");

        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Beispiel #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            //Grid initialization
            gridGame = FindViewById <GridView>(Resource.Id.gridGame);

            //Imageview Initialization
            imgResetGame = FindViewById <ImageView>(Resource.Id.imgResetGame);

            imgflagCell = FindViewById <ImageView>(Resource.Id.imgflag);

            //Object with game settings
            settings = SetupGame.LoadGameSetup("easy");

            //Max number of colums for the grid, equivalent to the horizontal spots
            gridGame.NumColumns = settings.xAxis;

            availableFlags = settings.mines;

            //All Game Data
            GameData = new GameMatrix(settings.xAxis, settings.yAxis, settings.mines);



            GameData.InitialSetup(rand);
            //List is sent to the Custom Adapter
            objCell = new deviget_minesweeper.ClassAdapters.CustomCellAdapter(GameData.ListCells, (AppCompatActivity)this);


            objCell.actionMenuSelected += ObjCell_actionMenuSelected;
            imgResetGame.Click         += ImgResetGame_Click;
            imgflagCell.Click          += ImgflagCell_Click;

            //Data populate to the GridView
            gridGame.Adapter = objCell;

            objCell.NotifyDataSetChanged();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            ReadFiles();

            try
            {
                setup = new SetupGame(Conf, Actions);
                play  = new PlayGame(Conf, Actions);

                Conf.Board = setup.ValidateBoard();
                PlayGame();
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine(e.Message);
                Console.ResetColor();
                Console.ReadKey();
            }
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            Configuration = new ConfigurationBuilder()
                            .AddCommandLine(args)
                            .AddEnvironmentVariables("ASPNETCORE_")
                            .SetBasePath(Directory.GetCurrentDirectory())
                            .AddJsonFile("Configuration/generalconfig.json")
                            .Build();

            var host = new WebHostBuilder()
                       .UseConfiguration(Configuration)
                       .UseKestrel()
                       .UseContentRoot(Directory.GetCurrentDirectory())
                       .UseIISIntegration()
                       .UseStartup <Startup>()
                       .Build();

            SetupGame.Initialise();

            host.Run();
        }
Beispiel #6
0
 private void Awake()
 {
     instance = this;
 }
Beispiel #7
0
        public async void ReadMessage()
        {
            await Task.Run(() =>
            {
                try
                {
                    var buffer = new byte[1028];
                    int numOfBytes;
                    while (Socket.IsConnected && !Reading)
                    {
                        numOfBytes = inputStream.Read(buffer, 0, buffer.Length);
                        Reading    = true;
                        if (numOfBytes > 0)
                        {
                            string message = Encoding.ASCII.GetString(buffer);
                            if (BGStuff.settingUpGame)
                            {
                                if (message.Contains("resume"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.setupGame.ReceiveResume();
                                    });
                                }
                                else if (message.Contains("accept"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.setupGame.AcceptResume();
                                    });
                                }
                                else if (message.Contains("reject"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.setupGame.RejectResume();
                                    });
                                }
                                else if (message.Contains("Setup2"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        SetupGame.StatGoToSetup2();
                                    });
                                }
                                else if (message.Contains(","))
                                {
                                    string[] split;
                                    split = message.Split(',');

                                    if (split[1].Contains("grid"))
                                    {
                                        Device.BeginInvokeOnMainThread(() =>
                                        {
                                            SetupGame.StatSetPicker(split[0]);
                                        });
                                    }
                                    else if (split[1].Contains("num"))
                                    {
                                        Device.BeginInvokeOnMainThread(() =>
                                        {
                                            SetupGame.StatSetNumOfShotsEntry(split[0]);
                                        });
                                    }
                                    else if (split[1].Contains("nam"))
                                    {
                                        Device.BeginInvokeOnMainThread(() =>
                                        {
                                            SetupGame.StatSetEnemyName(split[0]);
                                        });
                                    }
                                }
                            }
                            else if (BGStuff.settingUpGame2)
                            {
                                if (message.Contains("unready"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.setUpGame2.SetEnemyReady(false);
                                    });
                                }
                                else if (message.Contains("ready"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.setUpGame2.SetEnemyReady(true);
                                    });
                                }
                            }
                            else if (BGStuff.InGame)
                            {
                                if (message.Contains("hit"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.game.ReceiveHit(true);
                                    });
                                }
                                else if (message.Contains("miss"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.game.ReceiveHit(false);
                                    });
                                }
                                else if (message.Contains("ready"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.game.Ready();
                                    });
                                }
                                else if (message.Contains("endgame"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.game.EndGame(false);
                                    });
                                }
                                else if (message.Contains(","))
                                {
                                    string[] split = message.Split(',');
                                    int len        = split[0].Length;
                                    string temp    = "";

                                    for (int i = 0; i < len; i++)
                                    {
                                        temp += split[1][i];
                                    }

                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.game.ReceiveCheck(split[0] + "," + temp);
                                    });
                                }
                                else if (message.Contains("0") || message.Contains("1"))
                                {
                                    Device.BeginInvokeOnMainThread(() =>
                                    {
                                        BGStuff.game.GoesFirst(int.Parse(message));
                                    });
                                }

                                buffer = new byte[1028];
                            }
                        }
                        Reading = false;
                    }
                }
                catch (Exception ex)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        ToastLoader toast = new ToastLoader();
                        toast.Show("Connection Lost");

                        if (BGStuff.settingUpGame)
                        {
                            BGStuff.setupGame.Reconnect();
                        }
                        else if (BGStuff.settingUpGame2)
                        {
                            BGStuff.setUpGame2.Reconnect();
                        }
                        else if (BGStuff.InGame)
                        {
                            BGStuff.game.Reconnect();
                        }
                    });
                    Reconnect();
                }
            });
        }