protected override async ETTask Run(ETModel.Session session, M2C_CreateSpilings message)
        {
            SpilingInfo spilingInfo = message.Spilings;

            if (spilingInfo == null)
            {
                ETModel.Log.Error("收到的木桩回调信息为空");
            }
            //创建木桩
            Unit unit = UnitFactory.CreateSpiling(spilingInfo.UnitId, spilingInfo.ParentUnitId);

            //因为血条需要,创建热更层unit
            HotfixUnit hotfixUnit = HotfixUnitFactory.CreateHotfixUnit(unit);

            hotfixUnit.AddComponent <FallingFontComponent>();
            unit.Position = new Vector3(spilingInfo.X, spilingInfo.Y, spilingInfo.Z);

            unit.AddComponent <HeroDataComponent, long>(10001);

            // 创建头顶Bar
            Game.EventSystem.Run(EventIdType.CreateHeadBar, spilingInfo.UnitId);
            // 挂载头顶Bar
            hotfixUnit.AddComponent <HeroHeadBarComponent, Unit, FUI>(unit,
                                                                      Game.Scene.GetComponent <FUIComponent>().Get(spilingInfo.UnitId));

            await ETTask.CompletedTask;
        }
Beispiel #2
0
        protected override ETTask Run(Unit entity, Actor_CreateSpiling message)
        {
            Unit unit = UnitFactory.CreateSpiling(message.ParentUnitId);

            //设置木桩位置
            unit.Position = new Vector3(message.X, 0, message.Z);
            // 广播创建的木桩unit
            M2C_CreateSpilings createSpilings = new M2C_CreateSpilings();

            SpilingInfo spilingInfo = new SpilingInfo();

            spilingInfo.X            = unit.Position.x;
            spilingInfo.Y            = unit.Position.y;
            spilingInfo.Z            = unit.Position.z;
            spilingInfo.UnitId       = unit.Id;
            spilingInfo.ParentUnitId = message.ParentUnitId;
            createSpilings.Spilings  = spilingInfo;

            //向所有小骷髅广播信息
            MessageHelper.Broadcast(createSpilings);
            return(ETTask.CompletedTask);
        }