Esempio n. 1
0
    public void OnLeftRoom()
    {
        CurState = RoomStates.None;
        _playersInRoom.Clear();

        LogDebugMessage("We have left the room");
    }
Esempio n. 2
0
 private void checkGameState()
 {
     if (this.checkWinState(1))
     {
         this.client1.Send(new GameEndPacket(true, new int[4] {
             0, 0, 0, 0
         }));
         this.client2.Send(new GameEndPacket(false, new int[4] {
             0, 0, 0, 0
         }));
         this.state = RoomStates.END;
         this.closeRoom(true);
     }
     else if (this.checkWinState(2))
     {
         this.client1.Send(new GameEndPacket(false, new int[4] {
             0, 0, 0, 0
         }));
         this.client2.Send(new GameEndPacket(true, new int[4] {
             0, 0, 0, 0
         }));
         this.state = RoomStates.END;
         this.closeRoom(true);
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            RoomStates roomStates = db.RoomStates.Find(id);

            db.RoomStates.Remove(roomStates);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
    public void LookForQuickGame(int minOpponents, int maxOpponents)
    {
        _minOpponents = minOpponents;
        _maxOpponents = maxOpponents;

        PlayGamesPlatform.Instance.RealTime.CreateQuickGame(minOpponents, maxOpponents, 0, this);

        CurState = RoomStates.LookingForGame;
    }
Esempio n. 5
0
    /// <summary>
    /// Called when we are told that another player has joined the room
    /// Adds to the players in room list
    /// </summary>
    /// <param name="thePlayer">The player who joined.</param>
    void OtherPlayerJoinedRoom(MPPlayer thePlayer)
    {
        _playersInRoom.Add(thePlayer);
        thePlayer.ChangeStateTo(UserStates.Connected);

        if (_playersInRoom.Count >= _minOpponents)
        {
            CurState = RoomStates.WaitingForPlayersReady;
        }
    }
 public ActionResult Edit([Bind(Include = "Id,RoomId,Date,PriceChange,AvaibleRoom")] RoomStates roomStates)
 {
     if (ModelState.IsValid)
     {
         db.Entry(roomStates).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RoomId = new SelectList(db.Room, "Id", "RoomType", roomStates.RoomId);
     return(View(roomStates));
 }
Esempio n. 7
0
    void Awake()
    {
        GameObject manager = GameObject.FindGameObjectWithTag("GameController");

        this.gameManager  = manager.GetComponent <GameManager> ();
        this.scoreManager = manager.GetComponent <ScoreManager> ();
        this.timeManager  = manager.GetComponent <TimeManager> ();

        this.image = this.GetComponent <Image> ();
        this.state = RoomStates.OFF;
    }
Esempio n. 8
0
    /// <summary>
    /// Called when we are told that another player has left the room.
    /// Removes the player from the player list
    /// </summary>
    /// <param name="thePlayer">The player.</param>
    void OtherPlayerLeftRoom(MPPlayer thePlayer)
    {
        LogDebugMessage("Other player left room");

        _playersInRoom.Remove(thePlayer);
        thePlayer.ChangeStateTo(UserStates.Disconnected);

        if (_playersInRoom.Count < _minOpponents)
        {
            CurState = RoomStates.WaitingForPlayersConnected;
        }
    }
Esempio n. 9
0
 private void handleAction(GameClient c, GameActionPacket p)
 {
     if (c.Id == this.client1.Id)
     {
         //Its client 1
         if (this.state == RoomStates.CLIENT1_TURN)
         {
             int ySlot = this.getSlot(p.Column);
             if (ySlot != -1)
             {
                 this.fieldState[p.Column, ySlot] = 1;
                 GameActionNotifyPacket np = new GameActionNotifyPacket(p.Column);
                 this.client1.Send(np);
                 this.client2.Send(np);
                 this.state = RoomStates.CLIENT2_TURN;
                 this.checkGameState();
             }
             else //Invalid Move!
             {
                 c.Send(new GameActionNotifyPacket(p.Column, false));
             }
         }
         else
         {
             c.Send(new GameErrorPacket(0x03, "Its not your Turn!"));
         }
     }
     else if (c.Id == this.client2.Id)
     {
         if (this.state == RoomStates.CLIENT2_TURN)
         {
             int ySlot = this.getSlot(p.Column);
             if (ySlot != -1)
             {
                 this.fieldState[p.Column, ySlot] = 2;
                 GameActionNotifyPacket np = new GameActionNotifyPacket(p.Column);
                 this.client1.Send(np);
                 this.client2.Send(np);
                 this.state = RoomStates.CLIENT1_TURN;
                 this.checkGameState();
             }
             else //Invalid Move!
             {
                 c.Send(new GameActionNotifyPacket(p.Column, false));
             }
         }
         else
         {
             c.Send(new GameErrorPacket(0x03, "Its not your Turn!"));
         }
     }
 }
Esempio n. 10
0
    /// <summary>
    /// Called when we have joined a game room
    /// </summary>
    void JoinedRoomSucessfuly()
    {
        LogDebugMessage("Joined room");

        _playersInRoom = new List <MPPlayer>();

        OurPlayer = new MPPlayer(PlayGamesPlatform.Instance.RealTime.GetSelf());
        OurPlayer.PlayerStateChangedEvent += OurUserStateChanged;
        _playersInRoom.Add(OurPlayer);

        CurState = RoomStates.WaitingForPlayersConnected;

        SendMessageToAll(_introductionConst);
    }
        // GET: RoomStates/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RoomStates roomStates = db.RoomStates.Find(id);

            if (roomStates == null)
            {
                return(HttpNotFound());
            }
            return(View(roomStates));
        }
        // GET: RoomStates/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RoomStates roomStates = db.RoomStates.Find(id);

            if (roomStates == null)
            {
                return(HttpNotFound());
            }
            ViewBag.RoomId = new SelectList(db.Room, "Id", "RoomType", roomStates.RoomId);
            return(View(roomStates));
        }
Esempio n. 13
0
    public void setRoomState(RoomStates state)
    {
        switch (state)
        {
        case RoomStates.HavePlayer:
            ButtonText.text = "加入游戏";
            roomstates      = state;
            break;

        case RoomStates.NoPlayer:
            roomstates      = state;
            ButtonText.text = "开始游戏";
            break;
        }
    }
Esempio n. 14
0
    void DeactivateState()
    {
        if (this.state == RoomStates.CRIME)
        {
            this.gameManager.criminalCount--;
        }
        if (this.state != RoomStates.OFF)
        {
            gameManager.lightsCount--;
        }

        // Reset room to default state
        image.color     = Color.white;
        roomDescription = defaultRoomDescription;
        this.state      = RoomStates.OFF;
    }
Esempio n. 15
0
	public DataStore()
	{
		activeConditions = new Dictionary<string, Condition> ();
		increasingConditions = new List<string> ();

		roomStates = IOManager.LoadRoomStates ();
		playerState = IOManager.LoadPlayerState ();
		worldState = IOManager.LoadWorldState ();
		worldConstants = IOManager.LoadWorldConstants ();

		WorldClock.SetDate (worldState.clock);
		WeatherSystem.SetWeather (worldState.weather);

		foreach(Condition c in playerState.conditions.Values) {
			DataStore.AddCondition (c);
		}
	}
Esempio n. 16
0
    public void ActivateState(float invokeMin, float invokeMax, RoomDescription description)
    {
        if (description.isCrime)
        {
            this.state = RoomStates.CRIME;
        }
        else
        {
            this.state = RoomStates.NORMAL;
        }

        this.roomDescription = description;
        // TODO: change the sprite
        this.image.color = Color.yellow;

        Invoke("DeactivateStateAuto", Random.Range(invokeMin, invokeMax));
    }
Esempio n. 17
0
 public GameRoom(GameServerRunner server, int roomId, GameClient c1)
 {
     this.server = server;
     for (int x = 0; x < 7; x++)
     {
         for (int y = 0; y < 6; y++)
         {
             fieldState[x, y] = 0;
         }
     }
     this.client1 = c1;
     this.roomId  = roomId;
     c1.RoomId    = roomId;
     Console.WriteLine("New Gameroom Created! Player 1: " + c1.Name);
     //Room Sends Connect Ack
     c1.Send(new ConnectAckPacket(0, c1.Id, roomId));
     this.client2 = null;
     this.state   = RoomStates.WAITING;
     c1.setIngame(this.roomId);
 }
Esempio n. 18
0
        public void AddRow()
        {
            if (RoomStates.Count() > 0)
            {
                if (RoomStates[RoomStates.Count() - 1].Name == null && RoomStates[RoomStates.Count() - 1].Color == null)
                {
                    new MessageWindow(thiswindow, "有空行还未填写").ShowDialog();
                    return;
                }
                else if (RoomStates[RoomStates.Count() - 1].Name == null)
                {
                    new MessageWindow(thiswindow, "房间状态不能为空").ShowDialog();
                    return;
                }
            }
            RoomStateModel rt = new RoomStateModel()
            {
                StateID = Guid.NewGuid(),
                Color   = "默认(灰色)"
            };

            RoomStates.Add(rt);
        }
Esempio n. 19
0
        public void UpdateData()
        {
            if (RoomStates[RoomStates.Count() - 1].Name == null && RoomStates[RoomStates.Count() - 1].Color == null)
            {
                new MessageWindow(thiswindow, "有空行还未填写").ShowDialog();
                return;
            }
            else if (RoomStates[RoomStates.Count() - 1].Name == null)
            {
                new MessageWindow(thiswindow, "房间状态不能为空").ShowDialog();
                return;
            }
            Guid[] names = new Guid[GetRoomStates.Count()];
            for (int i = 0; i < GetRoomStates.Count(); i++)
            {
                names[i] = GetRoomStates[i].StateID;
            }
            using (RetailContext context = new RetailContext())
            {
                foreach (RoomStateModel rs in RoomStates)
                {
                    if (names.Contains(rs.StateID))
                    {
                        string sql = string.Format("update RoomStates set Name = '{0}',Color = '{1}' where UPPER(HEX([StateID]))='{2}'", rs.Name, rs.Color, rs.StateID.ConvertGuid());
                        context.Database.ExecuteSqlCommand(sql);
                    }
                    else
                    {
                        context.RoomStates.Add(rs);
                    }
                }
                context.SaveChanges();
            }


            LoadData();
        }
Esempio n. 20
0
 public void LoadData()
 {
     GetRoomStates = new ObservableCollection <RoomStateModel>();
     using (RetailContext context = new RetailContext())
     {
         var rmtypes = context.RoomStates.ToList();
         foreach (RoomStateModel rt in rmtypes)
         {
             GetRoomStates.Add(rt);
         }
     }
     if (RoomStates != null)
     {
         RoomStates.Clear();
     }
     else
     {
         RoomStates = new ObservableCollection <RoomStateModel>();
     }
     foreach (RoomStateModel rs in GetRoomStates)
     {
         RoomStates.Add(rs);
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Called when all players are ready and the game has started
 /// </summary>
 void GameStarted()
 {
     OurPlayer.ChangeStateTo(UserStates.Playing);
     CurState = RoomStates.GameInProgress;
 }
Esempio n. 22
0
 private void emitGameBegin()
 {
     this.client1.Send(new GameReadyPacket(this.client2.Name, true));
     this.client2.Send(new GameReadyPacket(this.client1.Name, false));
     this.state = RoomStates.CLIENT1_TURN;
 }