Ejemplo n.º 1
0
    public static void OnPositionChange(string name, PositionStructure position)
    {
        var positionMessage = new PositionMessage();

        positionMessage.name     = name;
        positionMessage.position = position;
        string json = JsonUtility.ToJson(positionMessage);

        Static.SendUnityMessage(json);
    }
Ejemplo n.º 2
0
    public static void UpdatePositionById(string id, string name, PositionStructure structure)
    {
        if (!transforms.ContainsKey(id))
        {
            transforms.Add(id, CreatePlayer());
        }
        var      t        = transforms[id];
        TextMesh textMesh = t.Find("Title")?.GetComponent <TextMesh>();

        textMesh.text = name;
        UpdateTargetById(id, structure);
    }
Ejemplo n.º 3
0
 void SendData(PositionStructure lastPosition)
 {
     if (
         lastPosition.x == position.x &&
         lastPosition.y == position.y &&
         lastPosition.z == position.z &&
         lastPosition.yAngle == position.yAngle
         )
     {
         return;
     }
     Static.OnPositionChange(name, position);
 }
Ejemplo n.º 4
0
    public static void UpdateTargetById(string id, PositionStructure structure)
    {
        if (!targets.ContainsKey(id))
        {
            targets[id]       = new Target();
            TTLDictionary[id] = TTL;
        }
        RefreshTTL(id);
        Target target = targets[id];

        target.position  = new Vector3(structure.x, structure.y, structure.z);
        target.yAngle    = structure.yAngle;
        target.isJumping = !target.isJumping && structure.isJumping;
        target.isRunning = structure.isRunning;
    }
Ejemplo n.º 5
0
    PositionStructure UpdatePosition()
    {
        var       controller   = transform.GetComponent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>();
        Transform pivot        = transform.Find("Pivot")?.GetComponent <Transform>();
        var       lastPosition = position;

        position           = new PositionStructure();
        position.x         = pivot.position.x;
        position.y         = pivot.position.y > 0 ? pivot.position.y : 0;
        position.z         = pivot.position.z;
        position.yAngle    = pivot.eulerAngles.y;
        position.isRunning = !controller.m_IsWalking;
        position.isJumping = false;
        return(lastPosition);
    }
Ejemplo n.º 6
0
    }    // Debug

    public static void SendPositionDebug(string name, PositionStructure structure)
    {
        structure.z += 2f;
        MultiplayerStatic.UpdatePositionById("1", "Ratto", structure);
    }