示例#1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         board = new GameBoard();
         pdao  = new PlayerDAO(ConfigurationManager.ConnectionStrings["myConn"].ConnectionString);
         string playerName = pdao.GetNamebyEmail(Session["currentEmail"].ToString());
         int    pid        = pdao.GetIdByEmail(Session["currentEmail"].ToString());
         player             = new ConnectPlayer(pid, playerName, Session["currentEmail"].ToString());
         bot                = new ConnectBot(null, null);
         game               = new ConnectFour(bot, player, board);
         tblBoard.GridLines = GridLines.Both;
         printBoard();
         Session.Add("board", board);
         Session.Add("player", player);
         Session.Add("bot", bot);
         Session.Add("game", game);
     }
     else
     {
         board  = (GameBoard)Session["board"];
         player = (ConnectPlayer)Session["player"];
         bot    = (ConnectBot)Session["bot"];
         game   = (ConnectFour)Session["game"];
     }
 }
示例#2
0
    /// <summary>
    /// Tells the client handler to send a CreateObject event to the client that just connected
    /// </summary>
    /// <param name="handler"></param>
    public void SpawnObjects(ClientHandler handler)
    {
        ConnectPlayer connectPlayer = new ConnectPlayer(handler.GetClientNetworkID());

        handler.SendPacket(connectPlayer.Serialize(), 0);

        int i        = 0;
        int prefabID = 0;

        foreach (NetworkingObject netObj in _networkingObjects)
        {
            if (i < 2)
            {
                prefabID = 1;
            }
            else
            {
                prefabID = 0;
            }
            CreateObject createObject = new CreateObject(prefabID, netObj.transform.position.x, netObj.transform.position.z, netObj.GetNetworkID(), netObj.GetPlayerNetworkID());
            i++;
            byte[] createObjectBytes = createObject.Serialize();

            handler.SendPacket(createObjectBytes, 0);
        }
    }