Exemple #1
0
    public void EmitCurrentParts()
    {
        JSONObject data = new JSONObject();

        data["action"] = "currentParts";
        data["name"]   = gameObject.name;
        JSONArray parts = new JSONArray();

        foreach (Transform part in gameObject.transform)
        {
            var        partHealth = part.gameObject.GetComponent <PartHealth>();
            JSONObject newPart    = new JSONObject();
            newPart["type"]      = partHealth.GetPartType();
            newPart["x"]         = (partHealth.GetRelPos().x + centerPos.x);
            newPart["y"]         = (partHealth.GetRelPos().y + centerPos.y);
            newPart["direction"] = partHealth.GetPartDirection();
            newPart["health"]    = partHealth.GetHealth();
            if (robotParts[partHealth.GetRelPos().x + 4, partHealth.GetRelPos().y + 4] != "none")
            {
                parts.Add(newPart);
            }
        }
        data["parts"] = parts;
        socketConnectionHandler.EmitGameMessage(data);
    }
    private void EmitCurrentBoosts()
    {
        JSONObject data = new JSONObject();

        data["action"] = "currentBoosts";
        data["name"]   = gameObject.name;
        data["boosts"] = boostsRemaining;
        socketConnectionHandler.EmitGameMessage(data);
    }
    public void OnSubmitButtonClicked()
    {
        JSONObject dataObject = JSON.Parse(InputElement.text).AsObject;

        socketIO.EmitGameMessage(dataObject);
    }