private void SetGameObject(FreeEntityData obj, UnityObject unityObj) { GameObject go = unityObj.AsGameObject; go.name = this.name; ((FreeEntityData)obj).gameObject = go; }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; object obj = fr.GetEntity(FreeUtil.ReplaceVar(entity, args)); if (obj is FreeMoveEntity) { FreeEntityData data = (FreeEntityData)((FreeMoveEntity)obj).freeData.FreeData; if (data.effect != null) { FreeEffectDeleteAction del = new FreeEffectDeleteAction(); del.SetKey(data.effect.GetKey()); del.SetScope(4); del.Act(args); } if (data.gameObject != null) { GameObject.Destroy(data.gameObject); } ((FreeMoveEntity)obj).isFlagDestroy = true; } }
public override void DoAction(IEventArgs args) { FreeMoveEntity en = args.GameContext.freeMove.CreateEntity(); en.AddEntityKey(new EntityKey(args.GameContext.session.commonSession.EntityIdGenerator.GetNextEntityId(), (short)EEntityType.FreeMove)); en.AddPosition(); en.AddFreeData(FreeUtil.ReplaceVar(name, args), new FreeEntityData(en)); en.freeData.Cat = ""; en.freeData.Value = ""; en.freeData.ScaleX = 1f; en.freeData.ScaleY = 1f; en.freeData.ScaleZ = 1f; if (distance > 0) { en.AddPositionFilter(Core.Components.PositionFilterType.Filter2D, distance); } en.isFlagSyncNonSelf = true; FreeEntityData entityData = (FreeEntityData)en.freeData.FreeData; entityData.move = (IFreeMove)SerializeUtil.Clone(move); entityData.createAction = createAction; entityData.action = action; entityData.name = FreeUtil.ReplaceVar(name, args); entityData.condition = condition; entityData.removeAction = removeAction; entityData.effect = (FreeEffectCreateAction)SerializeUtil.Clone(effect); entityData.width = width; entityData.length = length; entityData.height = height; entityData.deadAction = deadAction; entityData.damageAction = damageAction; entityData.frameAction = (IGameAction)SerializeUtil.Clone(frameAction); entityData.removeCondition = removeCondition; entityData.removedCondition = removedCondition; entityData.hp = hp; if (width > 0 && height > 0 && length > 0) { AssetInfo info = GetAssetInfo(args, effect); if (!string.IsNullOrEmpty(info.AssetName)) { args.GameContext.session.commonSession.AssetManager.LoadAssetAsync( entityData, info, SetGameObject); } } if (skills != null) { entityData.skills = new List <ISkill>(); foreach (ISkill skill in skills) { entityData.skills.Add((ISkill)SerializeUtil.Clone(skill)); } } FreeData fd = GetPlayer(args); if (fd != null) { args.TempUse("creator", fd); } entityData.Start(args); if (fd != null) { args.Resume("creator"); } }
private bool CheckHit(IEventArgs args, FreeEntityData data, Vector3 fromV, Vector3 toV, float dis) { Ray r = new Ray(fromV, new Vector3(toV.x - fromV.x, toV.y - fromV.y, toV.z - fromV.z)); RaycastHit[] hits = Physics.RaycastAll(r, dis); if (hits.Length > 0) { PlayerEntity player = args.GameContext.player.GetEntityWithEntityKey(new Core.EntityComponent.EntityKey(data.CreatorId, (short)EEntityType.Player)); int team = 0; FreeData source = null; if (player != null) { team = player.playerInfo.Camp; source = (FreeData)player.freeData.FreeData; } foreach (RaycastHit hit in hits) { var comp = hit.collider.transform.gameObject.GetComponent <EntityReference>(); if (comp != null) { PlayerEntity hitPlayer = args.GameContext.player.GetEntityWithEntityKey(comp.EntityKey); if (hitPlayer != null && hitPlayer != player && !hitPlayer.gamePlay.IsDead()) { bool sameTeam = hitPlayer.playerInfo.Camp == team; switch ((HitType)hitType) { case HitType.HitAll: args.Act(hitAction, new TempUnit("source", source), new TempUnit("target", (FreeData)hitPlayer.freeData.FreeData), new TempUnit("pos", new ObjectUnit(hit.point))); break; case HitType.HitEnemy: if (!sameTeam) { args.Act(hitAction, new TempUnit("source", source), new TempUnit("target", (FreeData)hitPlayer.freeData.FreeData), new TempUnit("pos", new ObjectUnit(hit.point))); } break; case HitType.HitAnyGone: args.Act(hitAction, new TempUnit("source", source), new TempUnit("target", (FreeData)hitPlayer.freeData.FreeData), new TempUnit("pos", new ObjectUnit(hit.point))); return(true); case HitType.HitEnemyGone: if (!sameTeam) { args.Act(hitAction, new TempUnit("source", source), new TempUnit("target", (FreeData)hitPlayer.freeData.FreeData), new TempUnit("pos", new ObjectUnit(hit.point))); return(true); } break; } } Debug.LogFormat(hit.collider.gameObject.GetInstanceID().ToString() + " of " + hits.Length); } } } return(false); }