Beispiel #1
0
        private IEnumerator sendGame()
        {
            while (moves.Count > 1)
            {
                yield return(new WaitForSeconds(SnakeGameLogic.refreshRate));

                theRenderer.handleBoardUpdate(moves [0]);
                moves.RemoveAt(0);
            }
            yield return(new WaitForSeconds(SnakeGameLogic.refreshRate));

            theRenderer.handleAdminGameOver(moves[0]);
            //theRenderer.displayCrash (new Vector2 (finalMsg.crashPos [0] [0], finalMsg.crashPos [0] [1]));
        }
Beispiel #2
0
        public void handleBoardUpdate(NetworkMessage msg)
        {
            BoardUpdate updateMsg = Deserialize <BoardUpdate> (msg.reader.ReadBytesAndSize());

            if (updateMsg.updateNumber <= lastUpdateID)
            {
                return;
            }
            lastUpdateID = updateMsg.updateNumber;

            localRenderer.handleBoardUpdate(updateMsg);

            //Extract information and store it
            lastBlocked = new List <Position2D> ();
            lastBlocked.AddRange(updateMsg.blueCoords);
            lastBlocked.AddRange(updateMsg.redCoords);
            lastBluePos = updateMsg.blueCoords [updateMsg.blueCoords.Length - 1];
            lastRedPos  = updateMsg.redCoords [updateMsg.redCoords.Length - 1];
            lastBlueDir = updateMsg.blueDir;
            lastRedDir  = updateMsg.redDir;

            addLocalBoardUpdate(lastBlocked, updateMsg.blueDir, updateMsg.redDir, lastBluePos, lastRedPos, BoardState.ongoing);
        }