protected override async ETTask Run(Session session, C2G_EnterMap request, G2C_EnterMap response, Action reply) { Player player = session.GetComponent <SessionPlayerComponent>().GetMyPlayer(); // 在Gate上动态创建一个Map Scene,把Unit从DB中加载放进来,然后传送到真正的Map中,这样登陆跟传送的逻辑就完全一样了 GateMapComponent gateMapComponent = player.AddComponent <GateMapComponent>(); gateMapComponent.Scene = await SceneFactory.Create(gateMapComponent, "GateMap", SceneType.Map); Scene scene = gateMapComponent.Scene; // 这里可以从DB中加载Unit Unit unit = UnitFactory.Create(scene, player.Id, UnitType.Player); unit.AddComponent <UnitGateComponent, long>(session.InstanceId); StartSceneConfig startSceneConfig = StartSceneConfigCategory.Instance.GetBySceneName(session.DomainZone(), "Map1"); response.MyId = player.Id; reply(); // 开始传送 await TransferHelper.Transfer(unit, startSceneConfig.InstanceId, startSceneConfig.Name); }
public void Run(SkillPara para) { int curIndex = para.CurIndex; var stepPara = para.StepPara[curIndex]; #if SERVER Log.Info("SkillWatcher_GenerateCollider"); if (int.TryParse(stepPara.Paras[0].ToString(), out var colliderId)) { SkillJudgeConfig collider = SkillJudgeConfigCategory.Instance.Get(colliderId); if (collider != null) { var aoiUnit = para.From.unit.GetComponent <AOIUnitComponent>(); var scene = aoiUnit.Scene.GetParent <Scene>(); Unit unit = null; Vector3 FromUnitPos = para.From.unit.Position; Vector3 ToUnitPos = Vector3.zero; if (para.To != null) { ToUnitPos = para.To.unit.Position; } #region 创建碰撞体AOIUnit if (collider.ColliderType == SkillJudgeType.FixedPosition)//固定位置碰撞体 { if (collider.StartPosType == ColliderStartPosType.Self) { unit = UnitFactory.CreateSkillCollider(scene, colliderId, FromUnitPos, para.Rotation, para); } else if (collider.StartPosType == ColliderStartPosType.Aim && para.To != null) { unit = UnitFactory.CreateSkillCollider(scene, colliderId, ToUnitPos, para.Rotation, para); } else if (collider.StartPosType == ColliderStartPosType.MousePos) { unit = UnitFactory.CreateSkillCollider(scene, colliderId, para.Position, para.Rotation, para); } else { Log.Info("目标未指定,或触发体类型不存在"); return; } } else if (collider.ColliderType == SkillJudgeType.FixedRotation)//固定方向碰撞体 { var dir = new Vector3(para.Position.x - FromUnitPos.x, para.Position.y - FromUnitPos.y, para.Position.z - FromUnitPos.z).normalized; if (collider.ColliderShape == SkillColliderShapeType.OBB)//立方找到中点 { var point = FromUnitPos + dir * collider.ColliderPara[2] / 2; if (collider.StartPosType == ColliderStartPosType.Self) { unit = UnitFactory.CreateSkillCollider(scene, colliderId, point, para.Rotation, para); } else { Log.Info("目标未指定,或触发体类型不存在"); return; } } else { Log.Info("目标未指定,或触发体类型不存在"); return; } } else if (collider.ColliderType == SkillJudgeType.Target)//朝指定位置方向飞行碰撞体 { Vector3 startPos = FromUnitPos; if (collider.StartPosType == ColliderStartPosType.Self) { startPos = FromUnitPos; } else if (collider.StartPosType == ColliderStartPosType.Aim && para.To != null) { startPos = ToUnitPos; } else if (collider.StartPosType == ColliderStartPosType.MousePos) { startPos = para.Position; } else { Log.Info("目标未指定,或触发体类型不存在"); return; } unit = UnitFactory.CreateSkillCollider(scene, colliderId, startPos, para.Rotation, para); } else if (collider.ColliderType == SkillJudgeType.Aim)//锁定目标飞行 { Vector3 startPos = FromUnitPos; if (collider.StartPosType == ColliderStartPosType.Self && para.To != null) { startPos = FromUnitPos; } else if (collider.StartPosType == ColliderStartPosType.Aim && para.To != null) { startPos = ToUnitPos; } else if (collider.StartPosType == ColliderStartPosType.MousePos && para.To != null) { startPos = para.Position; } else { Log.Info("目标未指定,或触发体类型不存在"); return; } unit = UnitFactory.CreateSkillCollider(scene, colliderId, startPos, para.Rotation, para); } else if (collider.ColliderType == SkillJudgeType.Immediate) //立刻结算 { if (collider.StartPosType == ColliderStartPosType.Self) { EventSystem.Instance.Publish(new EventType.OnSkillTrigger { From = aoiUnit, To = aoiUnit, Para = stepPara, Type = AOITriggerType.Enter, Config = para.Ability.SkillConfig, Cost = para.Cost, CostId = para.CostId, }); } else if (collider.StartPosType == ColliderStartPosType.Aim && para.To != null) { EventSystem.Instance.Publish(new EventType.OnSkillTrigger { From = aoiUnit, To = para.To.unit.GetComponent <AOIUnitComponent>(), Para = stepPara, Type = AOITriggerType.Enter, Config = para.Ability.SkillConfig, Cost = para.Cost, CostId = para.CostId, }); } else if (collider.StartPosType == ColliderStartPosType.MousePos) { Log.Error("立刻结算类型,必须指定目标"); return; } else { Log.Info("目标未指定,或触发体类型不存在"); return; } } else { Log.Error("碰撞体类型未处理" + collider.ColliderType); return; } #endregion } } #endif }