void loginGame()
    {
        warning.text = "";

        InputField usernameField = GameObject.Find("UsernameInputField").GetComponent <InputField>();
        InputField passwordField = GameObject.Find("PasswordInputField").GetComponent <InputField>();

        string username = usernameField.text;
        string password = passwordField.text;

        if (username == "")
        {
            warning.text = "username cannot be empty";
        }

        if (password == "")
        {
            warning.text = "password cannot be empty";
        }

        if (username != "" && password != "")
        {
            AmqpController.amqpControl.exchangeSubscription.Handler = ProcessLogin;

            LoginRequestJson loginRequest = new LoginRequestJson();
            loginRequest.id       = id;
            loginRequest.type     = "login";
            loginRequest.username = username;
            loginRequest.password = password;

            string request = JsonUtility.ToJson(loginRequest);
            AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, request);
        }
    }
Example #2
0
        public string CommandPublish(Queue <string> args)
        {
            // Validate
            if (args.Count < 2)
            {
                return("<color=red>wrong number of arguments</color>\nusage: <color=aqua>/publish {exchange name} {routing key|optional} {message}</color>\nuse double quotes to escape spaces in argument values");
            }

            // Get arguments
            string exchangeName = args.Dequeue();
            string routingKey   = args.Count > 2 ? args.Dequeue() : "";
            string message      = args.Dequeue();

            // Publish
            if (!AmqpClient.Instance.IsConnected)
            {
                return("<color=red>Must be connected to an AMQP broker in order to publish</color>");
            }
            else
            {
                AmqpClient.Publish(exchangeName, routingKey, message);
            }

            return(null);
        }
    void CallPet()
    {
        if (!foodEnabled && !ballInGround)
        {
            petCalled = true;

            targetMove = new Vector3(Camera.main.transform.position.x, 0.0f, Camera.main.transform.position.z);

            var  mapScript   = mapController.GetComponent <MapController>();
            int  tileX       = mapScript.tileX;
            int  tileY       = mapScript.tileY;
            bool readyToSend = mapScript.okToSentPetPos;

            if (readyToSend)
            {
                timeStartMove = DateTime.Now.Ticks.ToString();

                UpdatePetPos petPos = new UpdatePetPos();
                petPos.type          = "listplayer";
                petPos.username      = PlayerPrefs.GetString("username");
                petPos.timeStartMove = timeStartMove;
                petPos.petLastPosX   = transform.position.x;
                petPos.petLastPosY   = transform.position.z;
                petPos.petPosX       = targetMove.x;
                petPos.petPosY       = targetMove.z;
                petPos.tileX         = tileX;
                petPos.tileY         = tileY;
                petPos.petState      = "call";
                petPos.speed         = speed;

                string requestJson = JsonUtility.ToJson(petPos);
                AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson);
            }
        }
    }
Example #4
0
    public void Publish()
    {
        string str     = "\"id\":\"cube1\", \"posx\":2, \"posY\":0.5f, \"posZ\"-0.2f";
        var    message = str;

        AmqpClient.Publish(ExchangeName, RoutingKey, message);
    }
    public void ResetAction()
    {
        warning.text = "";

        InputField input = GameObject.Find("EmailInput").GetComponent <InputField>();
        string     email = input.text;

        if (email == "")
        {
            warning.text = "Please fill in your email";
        }
        else
        {
            AmqpController.amqpControl.exchangeSubscription.Handler = ProcessResetPass;

            ResetRequestJson request = new ResetRequestJson();
            request.id    = id;
            request.type  = "resetpassword";
            request.email = email;

            string json = JsonUtility.ToJson(request);
            //Debug.Log(json);
            AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, json);
        }
    }
Example #6
0
 public void setEstado(ArtefactoContenedor contenedor)
 {
     for (int i = 0; i < estados.Count; i++)
     {
         Estado e = estados[i];
         if (e.contenedor.getNombre().Equals(contenedor.getNombre())) // Estado nuevo de la tarea
         {
             e.comienzo     = DateTime.Now;
             e.estadoActual = true;
             string actores_ids = "[";
             foreach (Actor a in actores)
             {
                 actores_ids += "\"" + a.getId() + "\", ";
             }
             if (actores_ids.Length - 2 > 0)
             {
                 actores_ids.Remove(actores_ids.Length - 2);
             }
             actores_ids += "]";
             String message = String.Format("{{\"user_id\": \"{0}\", \"tarea_id\": \"{1}\", \"estado\": \"{2}\", \"participantes\": {3}}}", Actor.actual.getId(), this.getNombre(), e.contenedor.getNombre(), actores_ids);
             AmqpClient.Publish("topic_logs", "Tarea.Cambio.Estado", message);
         }
         else if (e.estadoActual == true) // Estado viejo. Disparo evento para registrar el tiempo que lleva en dicho estado la tarea
         {
             e.tiempoEstado = e.tiempoEstado + (DateTime.Now - e.comienzo);
             e.estadoActual = false;
             //Disparar evento de cambio de estado
         }
         estados[i] = e;
     }
 }
Example #7
0
    public void PVAbrirGraficoDeLineas()
    {
        pv.RPC("AbrirGraficoDeLineas", RpcTarget.AllViaServer);
        String message = String.Format("{{\"user_id\": \"{0}\", \"value\": \"{1}\"}}", Actor.actual.getId(), "Grafico de lineas");

        AmqpClient.Publish("topic_logs", "Recurso.Utilizado", message);
        AbrirGraficoDeLineas();
    }
    void StartRouting()
    {
        GameObject textObject  = GameObject.Find("DestinationField");
        string     destination = textObject.GetComponent <InputField>().text;

        string routeRequestJson = this.CreateRouteJsonMessage("route", destination);

        AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, routeRequestJson);
    }
    void MoveDeliver()
    {
        if (ballDeliver)
        {
            Vector3 camPos   = new Vector3(Camera.main.transform.position.x, 0.0f, Camera.main.transform.position.z);
            float   distance = Vector3.Distance(this.transform.position, camPos);
            if (distance > 0.1f)
            {
                Vector3 lookpos = camPos - this.transform.position;
                lookpos.y = 0;
                if (lookpos != Vector3.zero)
                {
                    var rotation = Quaternion.LookRotation(lookpos);
                    this.transform.rotation = Quaternion.Slerp(this.transform.rotation, rotation, Time.deltaTime * 2.0f);
                }

                this.transform.position = Vector3.MoveTowards(this.transform.position, camPos, Time.deltaTime * speed);
            }
            else
            {
                ball.transform.parent = null;
                Destroy(GameObject.FindGameObjectWithTag("Ball"));
                ballDeliver  = false;
                ballInGround = false;
                ballPlay     = false;
                ballThrown   = false;

                targetMove = transform.position;

                int curAgility = PlayerPrefs.GetInt("Walk");
                PlayerPrefs.SetInt("Walk", curAgility + 2);

                // update ball
                var  mapScript   = mapController.GetComponent <MapController>();
                int  tileX       = mapScript.tileX;
                int  tileY       = mapScript.tileY;
                bool readyToSend = mapScript.okToSentPetPos;

                if (readyToSend)
                {
                    UpdateBallState updateBall = new UpdateBallState();
                    updateBall.type      = "updateBall";
                    updateBall.username  = PlayerPrefs.GetString("username");
                    updateBall.tileX     = tileX;
                    updateBall.tileY     = tileY;
                    updateBall.ballPosX  = Camera.main.transform.position.x;
                    updateBall.ballPosY  = 0.0f;
                    updateBall.ballPosZ  = Camera.main.transform.position.z;
                    updateBall.ballState = "none";

                    string requestJson = JsonUtility.ToJson(updateBall);
                    AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson);
                }
            }
        }
    }
    public void Publish(User user)
    {
        var msg = JsonUtility.ToJson(user);

        //  string g = Guid.NewGuid().ToString();

        Debug.Log("PROPERTIES: " + GetProperties().CorrelationId);

        AmqpClient.Publish(_exchangeName, _routingKey, msg);
    }
        /// <summary>
        /// Publishes a message to the current exchange using the form's input values.
        /// </summary>
        public void Publish()
        {
            // Validate args
            var isValid = true;

            var exchangeName = PublishExchange.options[PublishExchange.value].text;

            if (string.IsNullOrEmpty(exchangeName))
            {
                isValid           = false;
                AmqpConsole.Color = Color.red;
                AmqpConsole.WriteLine("* Exchange Name cannot be blank");
                AmqpConsole.Color = null;
            }

            var message = PublishMessage.text;

            if (string.IsNullOrEmpty(message))
            {
                isValid           = false;
                AmqpConsole.Color = Color.red;
                AmqpConsole.WriteLine("* Message cannot be blank");
                AmqpConsole.Color = null;
            }

            // Don't continue if values are invald
            if (!isValid)
            {
                return;
            }

            var exchangeType = AmqpExchangeTypes.Direct;

            // Find this exchange and get its exchange type
            foreach (var exchange in exchanges)
            {
                if (exchange.Name == exchangeName)
                {
                    exchangeType = exchange.Type;
                    break;
                }
            }

            var routingKey = PublishRoutingKey.text;

            // Publish the message
            AmqpClient.Publish(exchangeName, routingKey, message);
            PublishMessage.text = null; // clear out message

            // Refocus the message area
            PublishMessage.Select();
            PublishMessage.ActivateInputField();
        }
Example #12
0
        public void SendMessageToQueue()
        {
            Debug.Log("SendMessageToQueue");
            //var rabbitCon = AmqpClient.Instance.BrokerConnection as RabbitMqBrokerConnection;
            //var basicprops = rabbitCon.Channel.CreateBasicProperties();

            //basicprops.ReplyTo = "blubb://bla/test";

            //RabbitMqMessageProperties rabbitProps = new RabbitMqMessageProperties(basicprops);

            AmqpClient.Publish(SendMessageQueueName.text, SendMessageQueueMessage.text);
        }
    void SimulateProjectile()
    {
        if (ball.transform.position.y <= 0.0f && !ballInGround)
        {
            ball.GetComponent <Rigidbody>().isKinematic = true;
            ball.transform.position = new Vector3(ball.transform.position.x, 0.0f, ball.transform.position.z);

            ballInGround = true;

            petCalled = false;

            var  mapScript   = mapController.GetComponent <MapController>();
            int  tileX       = mapScript.tileX;
            int  tileY       = mapScript.tileY;
            bool readyToSend = mapScript.okToSentPetPos;

            if (readyToSend)
            {
                // ball
                UpdateBallState updateBall = new UpdateBallState();
                updateBall.type      = "updateBall";
                updateBall.username  = PlayerPrefs.GetString("username");
                updateBall.tileX     = tileX;
                updateBall.tileY     = tileY;
                updateBall.ballPosX  = ball.transform.position.x;
                updateBall.ballPosY  = 0.0f;
                updateBall.ballPosZ  = ball.transform.position.z;
                updateBall.ballState = "inground";

                string requestJson = JsonUtility.ToJson(updateBall);
                AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson);

                // movement
                timeStartMove = DateTime.Now.Ticks.ToString();

                UpdatePetPos petPos = new UpdatePetPos();
                petPos.type          = "listplayer";
                petPos.username      = PlayerPrefs.GetString("username");
                petPos.timeStartMove = timeStartMove;
                petPos.petLastPosX   = transform.position.x;
                petPos.petLastPosY   = transform.position.z;
                petPos.petPosX       = ball.transform.position.x;
                petPos.petPosY       = ball.transform.position.z;
                petPos.tileX         = tileX;
                petPos.tileY         = tileY;
                petPos.petState      = "walktoball";
                petPos.speed         = speed;

                string requestJson2 = JsonUtility.ToJson(petPos);
                AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson2);
            }
        }
    }
Example #14
0
    public void ChangeAction()
    {
        warning.text = "";

        InputField inputOld    = GameObject.Find("OldPassInputField").GetComponent <InputField>();
        InputField inputNew    = GameObject.Find("NewPassInputField").GetComponent <InputField>();
        InputField inputRetype = GameObject.Find("RetypePassInputField").GetComponent <InputField>();

        string old     = inputOld.text;
        string newPass = inputNew.text;
        string retype  = inputRetype.text;

        if (old == "")
        {
            warning.text = "Please fill in old password";
        }

        if (newPass == "")
        {
            warning.text = "Please fill in new password";
        }

        if (retype == "")
        {
            warning.text = "Please retype new password";
        }

        if (old != "" && newPass != "" && retype != "")
        {
            if (newPass == retype)
            {
                AmqpController.amqpControl.exchangeSubscription.Handler = ProcessChangePass;

                ChangePassJson json = new ChangePassJson();
                json.id       = id;
                json.type     = "changepassword";
                json.username = PlayerPrefs.GetString("username");
                json.oldPass  = old;
                json.newPass  = newPass;

                string request = JsonUtility.ToJson(json);

                AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, request);
            }
            else
            {
                warning.text = "Retype password is different from new password";
            }
        }
    }
Example #15
0
    void restartAction()
    {
        AmqpController.amqpControl.exchangeSubscription.Handler = ProcessRestart;

        RestartRequest json = new RestartRequest();

        json.id       = id;
        json.type     = "restart";
        json.username = PlayerPrefs.GetString("username");

        string request = JsonUtility.ToJson(json);

        AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, request);
    }
Example #16
0
    public void PanelTareaClose()
    {
        //cuando cierro el panel actualizo el modelo
        tarea.addAtributo("prioridad", prioridad.transform.GetComponent <Text>().text);
        if ((this.extraerAtributoDeFecha("Año") != 0) && (extraerAtributoDeFecha("Mes") != 0) && (extraerAtributoDeFecha("Dia") != 0))
        {
            tarea.addAtributo("fecha", new DateTime(Convert.ToInt32(this.extraerAtributoDeFecha("Año")), Convert.ToInt32(this.extraerAtributoDeFecha("Mes")), Convert.ToInt32(this.extraerAtributoDeFecha("Dia"))));
        }

        Debug.Log("salio");
        PanelTarea.SetActive(false);
        isOpen = false;
        String message = String.Format("{{\"user_id\": \"{0}\", \"value\": {1}}}", Actor.actual.getId(), (DateTime.Now - timeOpen).Seconds);

        AmqpClient.Publish("topic_logs", "TiempoLecturaUserStory", message);
    }
Example #17
0
    void ReturnHome()
    {
        GameObject mapController = GameObject.Find("Map");
        var        mapScript     = mapController.GetComponent <MapController>();

        MapToHomeRequest request = new MapToHomeRequest();

        request.id       = mapScript.uniqueId;
        request.type     = "maptohome";
        request.username = PlayerPrefs.GetString("username");
        request.tileX    = mapScript.tileX;
        request.tileY    = mapScript.tileY;
        string jsonRequest = JsonUtility.ToJson(request);

        AmqpClient.Publish(AmqpControllerScript.amqpControl.requestExchange, AmqpControllerScript.amqpControl.requestRoutingKey, jsonRequest);
    }
    void GiveFood()
    {
        if (!foodEnabled && !ballInGround)
        {
            GameObject mainCam = GameObject.FindGameObjectWithTag("MainCamera");

            GameObject food = GameObject.CreatePrimitive(PrimitiveType.Cube);
            food.tag = "Food";
            food.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
            food.transform.position   = new Vector3(mainCam.transform.parent.position.x, 0, mainCam.transform.parent.position.z);
            Rigidbody foodRigibody = food.AddComponent <Rigidbody>();
            foodRigibody.mass        = 1;
            foodRigibody.isKinematic = true;

            foodEnabled = true;

            // update position in server
            var  mapScript   = mapController.GetComponent <MapController>();
            int  tileX       = mapScript.tileX;
            int  tileY       = mapScript.tileY;
            bool readyToSend = mapScript.okToSentPetPos;

            if (readyToSend)
            {
                timeStartMove = DateTime.Now.Ticks.ToString();

                UpdatePetPos petPos = new UpdatePetPos();
                petPos.type          = "listplayer";
                petPos.username      = PlayerPrefs.GetString("username");
                petPos.timeStartMove = timeStartMove;
                petPos.petLastPosX   = transform.position.x;
                petPos.petLastPosY   = transform.position.z;
                petPos.petPosX       = food.transform.position.x;
                petPos.petPosY       = food.transform.position.z;
                petPos.tileX         = tileX;
                petPos.tileY         = tileY;
                petPos.petState      = "walkFood";
                petPos.speed         = speed;

                string requestJson = JsonUtility.ToJson(petPos);
                AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson);
            }

            petCalled = false;
        }
    }
Example #19
0
        //transfer messages in update
        public override void Update()
        {
            inputInfo.CurrentHealth = transform.parent.GetComponent <Health>().health;
            // CentralBus.SightChannel.AddListener(updateCreatureInsight);
            //publish out creature info
            List <int> inputArray = WrapInput2Array(inputInfo);
            string     json       = JsonUtility.ToJson(inputInfo);

            AmqpClient.Publish(ExchangeName, OutputRoutingKey, json);


            if (Time.time >= nextTime)
            {
                //mock Recieved output
                MockProcess(inputInfo);
                nextTime += interval;
            }
        }
    void MoveBehaviour()
    {
        if (!foodEnabled && !ballInGround && !petCalled)
        {
            var  mapScript   = mapController.GetComponent <MapController>();
            int  tileX       = mapScript.tileX;
            int  tileY       = mapScript.tileY;
            bool readyToSend = mapScript.okToSentPetPos;

            if (Vector3.Distance(targetMove, transform.position) < 0.1f && readyToSend)
            {
                RandomTargetPos();
                timeStartMove = DateTime.Now.Ticks.ToString();

                UpdatePetPos petPos = new UpdatePetPos();
                petPos.type          = "listplayer";
                petPos.username      = PlayerPrefs.GetString("username");
                petPos.timeStartMove = timeStartMove;
                petPos.petLastPosX   = 0f;
                petPos.petLastPosY   = 0f;
                petPos.petPosX       = targetMove.x;
                petPos.petPosY       = targetMove.z;
                petPos.tileX         = tileX;
                petPos.tileY         = tileY;
                petPos.petState      = "walk";
                petPos.speed         = speed;

                string requestJson = JsonUtility.ToJson(petPos);
                AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson);
            }



            Vector3 lookpos = targetMove - transform.position;
            lookpos.y = 0;
            if (lookpos != Vector3.zero)
            {
                var rotation = Quaternion.LookRotation(lookpos);
                transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 2.0f);
            }

            transform.position = Vector3.MoveTowards(transform.position, targetMove, Time.deltaTime * speed);
        }
    }
Example #21
0
    // update latitude and longitude value and send the request to server through rabbitmq
    void UpdateGpsAndSendRequest()
    {
        //this.latitude = Input.location.lastData.latitude;
        //this.longitude = Input.location.lastData.longitude;
        //posText.text = "lat= " + this.latitude + " --- Long=" + this.longitude;

        if (this.lastLatitude != this.latitude || this.lastLongitude != this.longitude)
        {
            this.lastLatitude  = this.latitude;
            this.lastLongitude = this.longitude;

            Debug.Log("publish map");

            string requestJSON = this.CreateJsonMassage("map");
            AmqpClient.Publish(AmqpControllerScript.amqpControl.requestExchange, AmqpControllerScript.amqpControl.requestRoutingKey, requestJSON);

            this.mapAcquiredAndProcessed = false;
        }
    }
    void CobaInsert()
    {
        int iduser    = 50;
        int iditem    = 60;
        int itemtotal = 110;

        AmqpControllerScript.amqpControl.exchangeSubscription.Handler = ProcessCoba;

        RequestJson request = new RequestJson();

        request.id        = id;
        request.type      = "insertdata";
        request.iduser    = iduser;
        request.iditem    = iditem;
        request.itemtotal = itemtotal;

        string requestJson = JsonUtility.ToJson(request);

        Debug.Log(requestJson);

        AmqpClient.Publish(AmqpControllerScript.amqpControl.requestExchange, AmqpControllerScript.amqpControl.requestRoutingKey, requestJson);
    }
    void ThrowBall()
    {
        if (!ballThrown)
        {
            if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
            {
                if (!EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
                {
                    ball.GetComponent <Rigidbody>().isKinematic = false;
                    ball.GetComponent <Rigidbody>().velocity    = Camera.main.transform.forward * 5;

                    ballThrown = true;

                    var  mapScript   = mapController.GetComponent <MapController>();
                    int  tileX       = mapScript.tileX;
                    int  tileY       = mapScript.tileY;
                    bool readyToSend = mapScript.okToSentPetPos;

                    if (readyToSend)
                    {
                        UpdateBallState updateBall = new UpdateBallState();
                        updateBall.type      = "updateBall";
                        updateBall.username  = PlayerPrefs.GetString("username");
                        updateBall.tileX     = tileX;
                        updateBall.tileY     = tileY;
                        updateBall.ballPosX  = Camera.main.transform.forward.x;
                        updateBall.ballPosY  = Camera.main.transform.forward.y;
                        updateBall.ballPosZ  = Camera.main.transform.forward.z;
                        updateBall.ballState = "throw";

                        string requestJson = JsonUtility.ToJson(updateBall);
                        AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson);
                    }
                }
            }
        }
    }
    void LoginGame()
    {
        warning.text = "";

        InputField usernameField = GameObject.Find("InputField_username").GetComponent <InputField>();
        InputField passwordField = GameObject.Find("InputField_password").GetComponent <InputField>();

        string username = usernameField.text;
        string password = passwordField.text;

        if (username == "")
        {
            warning.text = "username cannot be empty";
        }

        if (password == "")
        {
            warning.text = "password cannot be empty";
        }

        Debug.Log(username + " & " + password);

        if (username != "" && password != "")
        {
            AmqpControllerScript.amqpControl.exchangeSubscription.Handler = ProcessLogin;

            LoginRequestJson request = new LoginRequestJson();
            request.id       = id;
            request.type     = "login";
            request.username = username;
            request.password = password;

            string requestToJson = JsonUtility.ToJson(request);
            AmqpClient.Publish(AmqpControllerScript.amqpControl.requestExchange, AmqpControllerScript.amqpControl.requestRoutingKey, requestToJson);
        }
    }
    public void returnTitle()
    {
        AmqpController.amqpControl.exchangeSubscription.Handler = ProcessReturnTitle;

        ReturnTitleJson request = new ReturnTitleJson();

        request.id   = id;
        request.type = "returntitle";

        request.username = PlayerPrefs.GetString("username");
        request.rest     = PlayerPrefs.GetInt("Sleep");
        request.energy   = PlayerPrefs.GetInt("Food");
        request.agility  = PlayerPrefs.GetInt("Walk");
        request.stress   = PlayerPrefs.GetInt("Fun");
        request.heart    = PlayerPrefs.GetInt("Health");
        request.money    = PlayerPrefs.GetInt("Bones");
        request.xp       = PlayerPrefs.GetInt("XP");

        string jsonRequest = JsonUtility.ToJson(request);

        Debug.Log(jsonRequest);

        AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, jsonRequest);
    }
Example #26
0
 public void Send(string send)
 {
     print("Sent " + send + " to " + send_to_backend_exchange);
     AmqpClient.Publish("send_to_backend", "", send);
 }
Example #27
0
    void CreateNewAccount()
    {
        warningText.text = "";

        InputField firstNameField = GameObject.Find("InputField_FirstName").GetComponent <InputField>();
        InputField lastNameField  = GameObject.Find("InputField_LastName").GetComponent <InputField>();
        InputField emailField     = GameObject.Find("InputField_Email").GetComponent <InputField>();
        InputField usernameField  = GameObject.Find("InputField_Username").GetComponent <InputField>();
        InputField passwordField  = GameObject.Find("InputField_Password").GetComponent <InputField>();
        InputField petNameField   = GameObject.Find("InputField_PetName").GetComponent <InputField>();

        string firstName = firstNameField.text;
        string lastName  = lastNameField.text;
        string email     = emailField.text;
        string username  = usernameField.text;
        string password  = passwordField.text;
        string petName   = petNameField.text;


        if (firstName == "")
        {
            warningText.text = "first name cannot be empty";
        }

        if (lastName == "")
        {
            warningText.text = "last name cannot be empty";
        }

        if (email == "")
        {
            warningText.text = "email cannot be empty";
        }

        if (username == "")
        {
            warningText.text = "username cannot be empty";
        }

        if (password == "")
        {
            warningText.text = "password cannot be empty";
        }

        if (petName == "")
        {
            warningText.text = "pet name cannot be empty";
        }

        if (firstName != "" && lastName != "" && email != "" && username != "" && password != "" && petName != "")
        {
            AmqpControllerScript.amqpControl.exchangeSubscription.Handler = ProcessAccount;

            RequestJson request = new RequestJson();
            request.id        = id;
            request.type      = "newaccount";
            request.firstName = firstName;
            request.lastName  = lastName;
            request.email     = email;
            request.username  = username;
            request.password  = password;
            request.petName   = petName;

            string requestJson = JsonUtility.ToJson(request);

            AmqpClient.Publish(AmqpControllerScript.amqpControl.requestExchange, AmqpControllerScript.amqpControl.requestRoutingKey, requestJson);
        }
    }
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Food")
        {
            anim = GameObject.Find("cu_puppy_shiba_a").GetComponent <Animator>();
            anim.runtimeAnimatorController = Resources.Load("AnimationController/PetEatController") as RuntimeAnimatorController;
            isEating = true;
            eatTime  = 160;

            var  mapScript   = mapController.GetComponent <MapController>();
            int  tileX       = mapScript.tileX;
            int  tileY       = mapScript.tileY;
            bool readyToSend = mapScript.okToSentPetPos;

            if (readyToSend)
            {
                timeStartMove = DateTime.Now.Ticks.ToString();

                UpdatePetPos petPos = new UpdatePetPos();
                petPos.type          = "listplayer";
                petPos.username      = PlayerPrefs.GetString("username");
                petPos.timeStartMove = timeStartMove;
                petPos.petLastPosX   = 0f;
                petPos.petLastPosY   = 0f;
                petPos.petPosX       = this.transform.position.x;
                petPos.petPosY       = this.transform.position.z;
                petPos.tileX         = tileX;
                petPos.tileY         = tileY;
                petPos.petState      = "eatFood";
                petPos.speed         = speed;

                string requestJson = JsonUtility.ToJson(petPos);
                AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson);
            }
        }

        if (col.gameObject.tag == "Ball")
        {
            ball.transform.parent = this.transform;

            ballDeliver = true;

            var  mapScript   = mapController.GetComponent <MapController>();
            int  tileX       = mapScript.tileX;
            int  tileY       = mapScript.tileY;
            bool readyToSend = mapScript.okToSentPetPos;

            if (readyToSend)
            {
                // movement
                timeStartMove = DateTime.Now.Ticks.ToString();

                UpdatePetPos petPos = new UpdatePetPos();
                petPos.type          = "listplayer";
                petPos.username      = PlayerPrefs.GetString("username");
                petPos.timeStartMove = timeStartMove;
                petPos.petLastPosX   = 0f;
                petPos.petLastPosY   = 0f;
                petPos.petPosX       = Camera.main.transform.position.x;
                petPos.petPosY       = Camera.main.transform.position.z;
                petPos.tileX         = tileX;
                petPos.tileY         = tileY;
                petPos.petState      = "walkbringball";
                petPos.speed         = speed;

                string requestJson = JsonUtility.ToJson(petPos);
                AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson);
            }
        }
    }
Example #29
0
 public void Send(string message)
 {
     AmqpClient.Publish(txtexcname.text, "", sndtxt.text);
 }
    void PlayBall()
    {
        if (!ballThrown)
        {
            if (!ballPlay)
            {
                ball     = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                ball.tag = "Ball";
                ball.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
                float pos = (Camera.main.nearClipPlane + 2f);
                ball.transform.position = Camera.main.transform.position + Camera.main.transform.forward * pos;

                Rigidbody ballRigibody = ball.AddComponent <Rigidbody>();
                ballRigibody.mass        = 1;
                ballRigibody.isKinematic = true;

                ballPlay = true;

                var  mapScript   = mapController.GetComponent <MapController>();
                int  tileX       = mapScript.tileX;
                int  tileY       = mapScript.tileY;
                bool readyToSend = mapScript.okToSentPetPos;

                if (readyToSend)
                {
                    UpdateBallState updateBall = new UpdateBallState();
                    updateBall.type      = "updateBall";
                    updateBall.username  = PlayerPrefs.GetString("username");
                    updateBall.tileX     = tileX;
                    updateBall.tileY     = tileY;
                    updateBall.ballPosX  = Camera.main.transform.position.x;
                    updateBall.ballPosY  = 10.0f;
                    updateBall.ballPosZ  = Camera.main.transform.position.z;
                    updateBall.ballState = "live";

                    string requestJson = JsonUtility.ToJson(updateBall);
                    AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson);
                }
            }
            else
            {
                Destroy(GameObject.FindGameObjectWithTag("Ball"));
                ballPlay = false;

                var  mapScript   = mapController.GetComponent <MapController>();
                int  tileX       = mapScript.tileX;
                int  tileY       = mapScript.tileY;
                bool readyToSend = mapScript.okToSentPetPos;

                if (readyToSend)
                {
                    UpdateBallState updateBall = new UpdateBallState();
                    updateBall.type      = "updateBall";
                    updateBall.username  = PlayerPrefs.GetString("username");
                    updateBall.tileX     = tileX;
                    updateBall.tileY     = tileY;
                    updateBall.ballPosX  = Camera.main.transform.position.x;
                    updateBall.ballPosY  = 10.0f;
                    updateBall.ballPosZ  = Camera.main.transform.position.z;
                    updateBall.ballState = "none";

                    string requestJson = JsonUtility.ToJson(updateBall);
                    AmqpClient.Publish(AmqpController.amqpControl.requestExchangeName, AmqpController.amqpControl.requestRoutingKey, requestJson);
                }
            }
        }
    }