Exemple #1
0
        private HackathonPacket Handle(HackathonPacket packet)
        {
            var result = new HackathonPacket();

            if (packet.name != null)
            {
                if (Name == "none" && packet.name != "none")
                {
                    Name = packet.name;
                    _gameManager.ConnectionReady(this);
                }
            }
            if (packet.command != null)
            {
                _gameManager.ExecuteCommand(this, packet.command);
            }
            if (packet.speed != null)
            {
                _gameManager.ChangeSpeed(this, packet.speed.Value);
            }
            if (packet.rotation != null)
            {
                _gameManager.ChangeRotation(this, packet.rotation.Value);
            }
            if (packet.scene != null)
            {
                _gameManager.UpdateScene(packet.scene);
            }

            // Prepare output...
            if (packet.ping != null && packet.ping == "ping")
            {
                result.ping = "pong";
            }

            if (packet.ping == null && _gameManager.DoPing())
            {
                result.ping = "ping";
            }

            if (Name == "none" && "none" != _gameManager.GetName() && _gameManager.GetName() != null)
            {
                result.name = _gameManager.GetName();
                Name        = result.name;
            }

            result.command  = _gameManager.GetCommand();
            result.speed    = _gameManager.GetSpeed();
            result.rotation = _gameManager.GetRotation();
            result.scene    = _gameManager.GetScene();

            return(result);
        }