예제 #1
0
        public override async ETTask M2C_OnEntityChangedHandler(ETModel.Session session, M2C_OnEntityChanged message)
        {
            Log.Debug($"M2C_OnEntityChangedHandler {Dumper.DumpAsString(message)}");
            var entityType = EntityDefine.TypeIds.GetKeyByValue((ushort)message.EntityType);

            ETModel.Entity entity = null;
            if (entityType == typeof(Unit))
            {
                entity = UnitComponent.Instance.Get(message.EntityId);
            }
            if (entityType == typeof(Bullet))
            {
                var bullet = BulletComponent.Instance.Get(message.EntityId);
                entity = bullet;
                if (entity is null)
                {
                    return;
                }
                if (bullet.BodyView != null)
                {
                    bullet.BodyView.transform.DOMove(new Vector3(message.X / 100f, message.Y / 100f, message.Z / 100f), 0.2f);
                }
            }
            if (entityType == typeof(Monster))
            {
                var monster = MonsterComponent.Instance.Get(message.EntityId);
                entity = monster;
                if (entity is null)
                {
                    return;
                }
                if (monster.BodyView != null)
                {
                    monster.BodyView.transform.DOMove(new Vector3(message.X / 100f, message.Y / 100f, message.Z / 100f), 0.2f);
                }
            }
            if (entity is null)
            {
                return;
            }
            if (message.ComponentType > 0)
            {
                entity = entity.GetComponent(EntityDefine.GetType(message.ComponentType));
            }

            var propertyCollection = EntityDefine.PropertyCollectionMap[EntityDefine.GetTypeId(entity.GetType())];

            if (propertyCollection.ContainsKey((ushort)message.PropertyId))
            {
                entity.SetPropertyValue((ushort)message.PropertyId, message.PropertyValue.bytes);
            }
            await ETTask.CompletedTask;
        }
예제 #2
0
 /// <summary>
 /// 消息体解析
 /// </summary>
 /// <param name="msg"></param>
 /// <param name="type"></param>
 public static void Msg(object msg, int type)
 {
     if (!Define.IsOutPutServerMsg)
     {
         return;
     }
     if (type == 0)
     {
         //发送消息
         Debug($"<color=yellow>发送:{Dumper.DumpAsString(msg)}</color>");
     }
     else
     {
         //收到消息
         Debug($"<color=green>接收:{Dumper.DumpAsString(msg)}</color>");
     }
 }
예제 #3
0
 public static void Msg(object msg)
 {
     Debug(Dumper.DumpAsString(msg));
 }