コード例 #1
0
        private void OnEntityCreated(WorldCommands.CreateEntity.ReceivedResponse response)
        {
            if (!ReferenceEquals(this, response.Context))
            {
                // This response was not for a command from this behaviour.
                return;
            }

            if (response.StatusCode != StatusCode.Success)
            {
                logDispatcher.HandleLog(LogType.Error,
                                        new LogEvent("CreateEntity failed.")
                                        .WithField(LoggingUtils.EntityId, response.RequestPayload.EntityId)
                                        .WithField("Reason", response.Message));

                return;
            }

            var spawnedCubesCopy =
                new List <EntityId>(cubeSpawnerWriter.Data.SpawnedCubes);
            var newEntityId = response.EntityId.Value;

            spawnedCubesCopy.Add(newEntityId);

            cubeSpawnerWriter.Send(new CubeSpawner.Update
            {
                SpawnedCubes = spawnedCubesCopy
            });
        }
コード例 #2
0
 private void OnCreateDinoResponse(WorldCommands.CreateEntity.ReceivedResponse response)
 {
     if (response.EntityId.HasValue)
     {
         var entityId = response.EntityId.Value;
         // 这个函数回调的时候,被创建出来的恐龙的GameObject还没有被创建,所以本函数不能有任何访问被创建出来的物体的操作
         // 只能写一些针对自己的操作
     }
 }
コード例 #3
0
 static private void OnCreateEntityResponse(WorldCommands.CreateEntity.ReceivedResponse response)
 {
     if (response.StatusCode == StatusCode.Success)
     {
         var createdEntityId = response.EntityId.Value;
         // handle success
     }
     else
     {
         // handle failure
     }
 }
コード例 #4
0
 private void OnCreateEntityResponse(WorldCommands.CreateEntity.ReceivedResponse response)
 {
     if (response.StatusCode == StatusCode.Success)
     {
         var createdEntityId = response.EntityId.Value;
         // handle success
         Debug.Log("create success");
     }
     else
     {
         // handle failure
         Debug.Log("failure");
     }
 }
コード例 #5
0
    private void OnCreateEggResponse(WorldCommands.CreateEntity.ReceivedResponse response)
    {
        if (response.EntityId.HasValue)
        {
            var entityId = response.EntityId.Value;
            //Debug.Log("Server - new egg created:"+entityId);
        }
        // 下蛋成功,身上的粮食要减半
        _curFood = attrsWriter.Data.CurrentFood;
        var update = new DinoAttrs.Update
        {
            CurrentFood = _curFood / 2,
        };

        attrsWriter.SendUpdate(update);
    }
コード例 #6
0
 private void OnCreateEggResponse(WorldCommands.CreateEntity.ReceivedResponse response)
 {
     if (response.StatusCode != Improbable.Worker.CInterop.StatusCode.Success)
     {// 创建实体失败
         Debug.LogError("PlayerBehaviour - OnCreateEggResponse() failed! " + response.Message);
         string errMsg    = "Send CreateEntigyCommand failed - " + response.Message;
         long   requestId = (long)response.Context;
         commandReceiver.SendLayEggFailure(requestId, errMsg);
         return;
     }
     if (response.EntityId.HasValue)
     {// 返回下蛋成功消息
         var entityId = response.EntityId.Value;
         //Debug.Log("Server - new egg created:"+entityId);
         long requestId = (long)response.Context;
         var  response1 = new LayEggResponse
         {
             Result    = true,
             ErrorCode = 0
         };
         commandReceiver.SendLayEggResponse(requestId, response1);
     }
 }
コード例 #7
0
 public void AddCreateEntityResponse(WorldCommands.CreateEntity.ReceivedResponse response)
 {
     worldCommandsReceivedStorage.AddResponse(response);
 }
コード例 #8
0
 private void CannonballEntityCreated(WorldCommands.CreateEntity.ReceivedResponse response)
 {
 }