Example #1
0
        //public Room getMyroom(string playerName)
        //{
        //    foreach (var r in gameRooms)
        //    {
        //        if (r.player1.Name==playerName||r.player2.Name==playerName)
        //        {
        //            return r;
        //        }
        //    }
        //    return null;
        //}
        public bool StartRoom(Room room)
        {
            IMainPageCallBack client = OperationContext.Current.GetCallbackChannel <IMainPageCallBack>();

            Console.WriteLine("YOOhahahaha " + room.RoomName);
            if (room.player1.callBack != null && room.player1.callBack != client)
            {
                room.player1.callBack.OnStartGame(room);
            }
            if (room.player2.callBack != null && room.player2.callBack != client)
            {
                room.player2.callBack.OnStartGame(room);
            }

            //IMainPageCallBack client = OperationContext.Current.GetCallbackChannel<IMainPageCallBack>();
            //if (opponent == "AI")
            //{
            //    Service.Room room = new Room(this.userName, heroName, "AI", "Karrigen");
            //    client.OnStartGame(room);
            //}
            //else
            //{
            //    Service.Room room = new Room(this.userName, heroName, opponent, );
            //    client.OnStartGame(room);
            //}
            return(false);
        }
Example #2
0
        public Room ChooseHeroes(string heroName, string playerName)
        {
            IMainPageCallBack client = OperationContext.Current.GetCallbackChannel <IMainPageCallBack>();
            bool find = false;

            foreach (var R in gameRooms)
            {
                if (R.player1.Name == playerName)
                {
                    R.player1.Hero       = heroName;
                    R.player1.HeroFigure = fac.createFigure(heroName);
                    //R.player1.fixHeroFigure();
                    find = true;
                    if (R.player1.Hero != null && R.player2.Hero != null)
                    {
                        this.StartRoom(R);
                        return(R);
                    }
                }
                if (R.player2.Name == playerName)
                {
                    R.player2.Hero       = heroName;
                    R.player2.HeroFigure = fac.createFigure(heroName);

                    //R.player2.fixHeroFigure();
                    find = true;
                    if (R.player1.Hero != null && R.player2.Hero != null)
                    {
                        this.StartRoom(R);
                        return(R);
                    }
                }
            }


            if (!find)
            {
                Service.Room room = new Room(new Player(playerName, heroName), new Player("AI", "Kerrigan"));
                this.AddDatabaseNrofGame(playerName, "AI");
                this.gameRooms.Add(room);
                this.StartRoom(room);
                return(room);
            }

            return(null);
        }
Example #3
0
        //IMainPage : here start my our second interface implementation
        public List <string> AfterLogin()
        {
            IMainPageCallBack client = OperationContext.Current.GetCallbackChannel <IMainPageCallBack>();

            //thisPlayer = client;
            onlinePlayers.Add(client);
            onlinePlayerNames.Add(userName);

            foreach (var c in onlinePlayers)
            {
                if (c != client)
                {
                    c.OnPlayerChange(this.onlinePlayerNames);
                }
            }
            return(this.PlayerInfo);
        }
Example #4
0
        public bool SendGameRequest(string reqSender, string reqReciever)
        {
            IMainPageCallBack client = OperationContext.Current.GetCallbackChannel <IMainPageCallBack>();
            bool response            = false;

            foreach (var c in onlinePlayers)
            {
                if (c != client && c.GetName() == reqReciever)
                {
                    response = c.OnRecieveRequest(reqSender);
                    if (response)
                    {
                        Service.Room room = new Room(new Player(reqSender, client), new Player(reqReciever, c));

                        Match match = new Match(room);
                        this.AddDatabaseNrofGame(reqReciever, reqSender);
                        this.gameRooms.Add(room);
                        this.matchList.Add(match);
                        this.RoomsName.Add(room.RoomName);
                        this.onlinePlayerNames.Remove(reqSender);
                        this.onlinePlayerNames.Remove(reqReciever);
                        foreach (var cli in onlinePlayers)
                        {
                            if (cli != client)
                            {
                                cli.OnRoomChanges(this.RoomsName);
                                cli.OnPlayerChange(this.onlinePlayerNames);
                            }
                        }
                        //if(room.LPlayerHero!=null && room.RPlayerHero!=null)
                        //{
                        //    StartRoom(room);
                        //}
                    }
                }
            }
            //
            return(response);
        }
Example #5
0
        public void QuitGame()
        {
            IMainPageCallBack client = OperationContext.Current.GetCallbackChannel <IMainPageCallBack>();
            bool found = false;

            foreach (var c in onlinePlayers)
            {
                if (c == client)
                {
                    found = true;
                }
            }
            if (found == true)
            {
                onlinePlayers.Remove(client);
                onlinePlayerNames.Remove(userName);
            }
            foreach (var c in onlinePlayers)
            {
                c.OnPlayerChange(this.onlinePlayerNames);
                c.OnRoomChanges(this.RoomsName);
            }
        }
Example #6
0
 public Player(string N, IMainPageCallBack cb)
 {
     this.Name     = N;
     this.callBack = cb;
 }
Example #7
0
 private void updateLists(string reqSender, string reqReciever)
 {
     IMainPageCallBack client = OperationContext.Current.GetCallbackChannel <IMainPageCallBack>();
 }