예제 #1
0
    private void OnNumberOfPointsUpdated(Scale.Update update)
    {
        float v = update.s.Value * SimulationSettings.ScoreIncrement - (SimulationSettings.ScoreIncrement - 1);
        int   numberOfPoints = (int)v;

        updateGUI(numberOfPoints);
    }
예제 #2
0
 void OnScaleUpdated(Scale.Update update)
 {
     if (ScaleReader.Authority == Authority.NotAuthoritative)
     {
         if (update.s.HasValue)
         {
             var v   = update.s.Value;
             var old = transform.localScale.x;
             transform.localScale = new Vector3(v, v, v);
         }
     }
 }
예제 #3
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.IsSpatialOsEntity())
            {
                if (other != null && other.gameObject.GetSpatialOsEntity().PrefabName == "Cube")
                {
                    //Debug.LogWarning("0: Collision accepted from " + gameObject.GetSpatialOsEntity().PrefabName+ "with " + other.gameObject.GetSpatialOsEntity().PrefabName);

                    SpatialOS.Commands.DeleteEntity(ClientConnectionWriter, other.gameObject.EntityId(), result => {
                        if (result.StatusCode != StatusCode.Success)
                        {
                            Debug.Log("Failed to delete entity with error: " + result.ErrorMessage);
                            return;
                        }
                        Debug.Log("Deleted entity: " + result.Response.Value);
                    });
                    var current = ScaleWriter.Data.s;

                    Debug.LogWarning("1: " + current + " - " + gameObject.transform.localScale.x);
                    var scaleUpdate = new Scale.Update()
                                      .SetS(current + SimulationSettings.PlayerIncrement);
                    Debug.LogWarning("2:");
                    ScaleWriter.Send(scaleUpdate);
                    Debug.LogWarning("3:");
                }
                if (other != null && other.gameObject.GetSpatialOsEntity().PrefabName == "Cube1")
                {
                    //Debug.LogWarning("0: Collision accepted from " + gameObject.GetSpatialOsEntity().PrefabName+ "with " + other.gameObject.GetSpatialOsEntity().PrefabName);

                    SpatialOS.Commands.DeleteEntity(ClientConnectionWriter, other.gameObject.EntityId(), result => {
                        if (result.StatusCode != StatusCode.Success)
                        {
                            Debug.Log("Failed to delete entity with error: " + result.ErrorMessage);
                            return;
                        }
                        Debug.Log("Deleted entity: " + result.Response.Value);
                    });
                    var current = ScaleWriter.Data.s;

                    Debug.LogWarning("1: " + current + " - " + gameObject.transform.localScale.x);
                    if (current >= 2)
                    {
                        var scaleUpdate = new Scale.Update()
                                          .SetS(current - SimulationSettings.PlayerDecrement);
                        Debug.LogWarning("2:");
                        ScaleWriter.Send(scaleUpdate);
                        Debug.LogWarning("3:");
                    }
                }
            }
        }
예제 #4
0
    void OnScaleUpdated(Scale.Update update)
    {
        if (update.s.HasValue)
        {
            var v = update.s.Value;
            Debug.LogWarning("value = " + v);
            if (v >= SimulationSettings.MaxScore)
            {
                Debug.LogWarning("if");

                ResetQuery();
                return;
            }
            transform.localScale = new Vector3(v, v, v);
        }
    }
예제 #5
0
 void OnScaleUpdated(Scale.Update update)
 {
     if (ScaleReader.Authority == Authority.NotAuthoritative)
     {
         if (update.s.HasValue)
         {
             if (update.s.Value == 1.0f)
             {
                 offset = new Vector3(0, -10, 9);
             }
             else
             {
                 offset = (new Vector3(offset.x, offset.y - 0.3F, offset.z + 0.3F));
             }
         }
     }
 }
예제 #6
0
    void Respawning()
    {
        float x         = 18.0f;
        float y         = 18.0f;
        float xCoord    = Random.Range(-x, x);
        float yCoord    = Random.Range(-y, y);
        var   rigidbody = GetComponent <Rigidbody>();

        rigidbody.isKinematic = false;
        transform.position    = new Vector3(xCoord, SimulationSettings.PlayerSpawnHeight, yCoord);
        transform.rotation    = UnityEngine.Quaternion.identity;
        rigidbody.velocity    = new Vector3(0, 0, 0);


        var pos = rigidbody.position;

        Debug.LogWarning("Respawning: " + pos.y);
        var positionUpdate = new Position.Update()

                             .SetCoords(new Coordinates(pos.x, pos.y, pos.z));

        PositionWriter.Send(positionUpdate);

        var rotationUpdate = new Rotation.Update()

                             .SetRotation(rigidbody.rotation.ToNativeQuaternion());

        RotationWriter.Send(rotationUpdate);


        var scaleUpdate = new Scale.Update()

                          .SetS(1.0f);

        ScaleWriter.Send(scaleUpdate);
    }