// Use this for initialization void Start() { scene_controller = (FirstController)Director.getInstance().currentSceneController; moveToLeft = MoveToAction.GetAction(new Vector3(-1, 0, 0), 1); moveToRight = MoveToAction.GetAction(new Vector3((float)1.5, 0, 0), 1); teleportTo = TeleportAction.GetAction(new Vector3(0, 0, 0)); }
public static TeleportAction GetAction(Vector3 target) { TeleportAction action = ScriptableObject.CreateInstance <TeleportAction> (); action.target = target; return(action); }
// called in UI event public void TriggerTeleport(Vector2 position) { if (m_IsTeleporting) { return; } var flags = m_HOLDFilterSelector.GetValue() ? new [] { SpatialActor.k_IsHlodFlag, SpatialActor.k_IsDisabledFlag } : new [] { SpatialActor.k_IsDisabledFlag }; var picker = (ISpatialPickerAsync <Tuple <GameObject, RaycastHit> >)m_TeleportPickerSelector.GetValue(); picker.Pick(m_Camera.ScreenPointToRay(position), results => { if (results.Count == 0) { return; } var hitInfo = results[0].Item2; var point = hitInfo.point; var normal = hitInfo.normal; var target = point + m_ArrivalOffsetFixed + m_ArrivalOffsetNormal * normal + m_ArrivalOffsetRelative * (m_Source - point).normalized; Dispatcher.Dispatch(TeleportAction.From(target)); }, flags); }
void OnTeleport(InputAction.CallbackContext obj) { if (m_CanTeleport && m_IsTeleporting && m_TeleportationTarget.gameObject.activeSelf) { Vector3 offset = new Vector3(0, m_XrRig.cameraYOffset / 4f, 0); Dispatcher.Dispatch(TeleportAction.From(m_TeleportationTarget.transform.position + offset)); SetTeleportCurve(k_MaxVelocity); } }
public Teleport(BaseEvent ef, Character caster, Environment environment) { this.ef = ef; this.caster = caster; this.environment = environment; TeleportAction ta = (TeleportAction)ef.action; TeleportAction.ModeName mode = ta.mode.ShowModeName(); switch (mode) { case TeleportAction.ModeName.PredefinedPositionOnMap: TeleportAction.PredefinedPositionOnMapMode ppomm = (TeleportAction.PredefinedPositionOnMapMode)ta.mode; Vector2 pos = environment.GetPositionOnMap(ppomm.positionName); Vector2 displacement = pos - (Vector2)caster.Position(); caster.DisplaceBy(displacement); break; case TeleportAction.ModeName.KeepDistance: TeleportAction.KeepDistanceMode kdm = (TeleportAction.KeepDistanceMode)ta.mode; List <Character> enemies = environment.FindNearbyCharacters( caster, Vector3.zero, 999, new[] { FindingFilter.ExcludeAllies, FindingFilter.ExcludeDead, FindingFilter.ExcludeMe } ); if (enemies.Count > 0) { Character enemy = enemies[0]; CharacterId enemyCharId = enemy.CharacterId(); CharacterId charToControl = environment.CharacterToControl(); CharacterId casterCharId = caster.CharacterId(); if (casterCharId != charToControl) { float from = kdm.distanceRange[0]; float to = kdm.distanceRange[1]; float distanceBetween = Math.Abs(enemy.Position().x - caster.Position().x); float distance = distanceBetween; if (distanceBetween <= from) { distance = from; } else if (distanceBetween >= to) { distance = to; } Vector2 targetPos = (Vector2)enemy.Position() + enemy.FacingDirection().ToNormalizedVector2() * distance; caster.DisplaceBy(targetPos - (Vector2)caster.Position()); } } break; } }
bool forceMove(Vector3 mForceMovePos) {//强制瞬移 if (Self.mCurRoomGUID != -1 && Self.mCurRoomGUID != MainActor.mCurRoomGUID) { if (!SM.RandomRoomLevel.Singleton.QuickFindPath(Self.MainPos, mForceMovePos)) { TeleportAction teleportAction = Self.ActionControl.AddAction(ActorAction.ENType.enTeleportAction) as TeleportAction; if (teleportAction != null) { teleportAction.Init(mForceMovePos); } mDisAbleFindPathTime = 0; return(true); } } return(false); }
bool NormalForceMove(float distance, Vector3 mForceMovePos) {//瞬移 bool isCanFindPath = SM.RandomRoomLevel.Singleton.QuickFindPath(Self.MainPos, mForceMovePos); if (!isCanFindPath || distance > ForceMoveDistance) { //跟主控角色之间不能寻路或者距离过大 if (mDisAbleFindPathTime == 0) { //如果不能寻路的时间为0说明这次是第一次不能寻路,为不能寻路的时间赋值 mDisAbleFindPathTime = Time.time; } if (Time.time - mDisAbleFindPathTime > MaxFindPathTime) { TeleportAction teleportAction = Self.ActionControl.AddAction(ActorAction.ENType.enTeleportAction) as TeleportAction; if (teleportAction != null) { teleportAction.Init(mForceMovePos); } //Self.ForceMoveToPosition(mForceMovePos); mDisAbleFindPathTime = 0; return(true); } } return(false); // float distance = ActorTargetManager.GetTargetDistance(Self.RealPos, MainActor.RealPos); // distance = Mathf.Abs(distance); // if (distance > ForceMoveDistance) // {//距离大于瞬移距离 // if (!SDungeonsMgr.Singleton.QuickFindPath(Self.MainPos, ActorManager.Singleton.MainActor.MainPos)) // {//跟主控角色之间不能寻路 // if (mDisAbleFindPathTime == 0) // {//如果不能寻路的时间为0说明这次是第一次不能寻路,为不能寻路的时间赋值 // mDisAbleFindPathTime = Time.time; // } // if (Time.time - mDisAbleFindPathTime > MaxFindPathTime) // { // Self.ForceMoveToPosition(ActorManager.Singleton.MainActor.MainPos); // mDisAbleFindPathTime = 0; // return true; // } // } // } // return false; }
void ToggleFollowUserTool() { var networkUserData = m_UsersSelector.GetValue().Find(user => user.matchmakerId == MatchmakerId); if (m_NavigationModeSelector.GetValue() == SetNavigationModeAction.NavigationMode.VR) { if (!ReferenceEquals(networkUserData.visualRepresentation, null)) { Dispatcher.Dispatch(TeleportAction.From(networkUserData.visualRepresentation.transform.position)); } } else { Dispatcher.Dispatch(SetWalkEnableAction.From(false)); var followUserData = new FollowUserAction.FollowUserData(); followUserData.matchmakerId = networkUserData.matchmakerId; followUserData.visualRepresentationGameObject = networkUserData.visualRepresentation.gameObject; Dispatcher.Dispatch(FollowUserAction.From(followUserData)); Dispatcher.Dispatch(SetDeltaDNAButtonAction.From($"FollowUser")); } }
private ActorAction CreateObj(ActorAction.ENType newType) { ActorAction action = m_pool.GetObjectFromPool(newType) as ActorAction; if (action != null) { return(action); } switch (newType) { case ActorAction.ENType.enStandAction: action = new StandAction(); break; //站立 case ActorAction.ENType.enMoveAction: action = new MoveAction(); break; //移动 case ActorAction.ENType.enAttackAction: action = new AttackAction(); break; //攻击 case ActorAction.ENType.enSpasticityAction: action = new SpasticityAction(); break; //被动僵直 case ActorAction.ENType.enBeAttackAction: action = new BeAttackAction(); break; //受击 case ActorAction.ENType.enUndownAction: action = new UndownAction(); break; //霸体 case ActorAction.ENType.enDeadAction: action = new DeadAction(); break; //死亡 case ActorAction.ENType.enReliveAction: action = new ReliveAction(); break; //复活 case ActorAction.ENType.enPlayEffectAction: action = new PlayEffectAction(); break; //播放特效 case ActorAction.ENType.enSearchEnemyAction: //action = new SearchEnemyAction(); break; //搜索敌人 case ActorAction.ENType.enTeleportAction: action = new TeleportAction(); break; //瞬移 case ActorAction.ENType.enControlMoveAction: action = new ControlMoveAction(); break; //控制技能定身 case ActorAction.ENType.enHoldDownAction: action = new HoldDownAction(); break; //按下状态 case ActorAction.ENType.enSelfSpasticityAction: action = new SelfSpasticityAction(); break; //主动僵直 case ActorAction.ENType.enAlertAction: action = new AlertAction(); break; //警戒 case ActorAction.ENType.enJumpinAction: action = new JumpinAction(); break; //入场 case ActorAction.ENType.enJumpoutAction: action = new JumpoutAction(); break; //退场 case ActorAction.ENType.enRollAction: action = new RollAction(); break; //翻滚 case ActorAction.ENType.enFakeBeAttackAction: action = new FakeBeAttackAction(); break; //假受击 case ActorAction.ENType.enActorExitAction: action = new ActorExitAction(); break; //主控角色退场 case ActorAction.ENType.enActorEnterAction: action = new ActorEnterAction(); break; //主控角色入场 case ActorAction.ENType.enControlAttackAction: action = new ControlAttackAction(); break; //不能攻击 case ActorAction.ENType.enControlBeAttackAction: action = new ControlBeAttackAction(); break; //不能受击 case ActorAction.ENType.enAttackingMoveAction: action = new AttackingMoveAction(); break;//攻击时移动 case ActorAction.ENType.enDragMoveAction: action = new DragMoveAction(); break;//拖拽 default: throw new Exception("Miss Action Create for" + newType.ToString()); } return(action); }
/// <summary> /// Create an action from a string line /// </summary> public static Action Create(string line) { Action.ActionTypes actionType = (Action.ActionTypes)int.Parse(line.Substring (0, line.IndexOf (','))); switch(actionType) { case Action.ActionTypes.Movement: MovementAction mAction = new MovementAction(); mAction.Load(line); return mAction; break; case Action.ActionTypes.Look: LookAction lAction = new LookAction(); lAction.Load(line); return lAction; break; case Action.ActionTypes.Interact: InteractAction iAction = new InteractAction(); iAction.Load(line); return iAction; break; case Action.ActionTypes.TextInfo: TextInfoAction tAction = new TextInfoAction(); tAction.Load(line); return tAction; break; case Action.ActionTypes.Teleport: TeleportAction tlAction = new TeleportAction(); tlAction.Load(line); return tlAction; break; default: return null; break; } }
public Loopable Produce(Character caster, Skill skill, SkillId skillId, BaseEvent baseEvent, SkillCastingSource skillCastingSource, TemplateArgs args) { BaseAction ba = baseEvent.ShowAction(); ActionType actionType = ba.ShowActionType(); Loopable loopable = null; switch (actionType) { case ActionType.Camera: CameraAction ca = (CameraAction)ba; CameraAction.BaseFx bf = ca.fx; CameraAction.FxType fxType = bf.ShowFxType(); switch (fxType) { case CameraAction.FxType.Shake: CameraAction.ShakeFx sf = (CameraAction.ShakeFx)bf; loopable = new CameraShake(environment, sf); break; case CameraAction.FxType.Fade: loopable = new CameraFade(environment, baseEvent); break; case CameraAction.FxType.CinematicZoomToSelf: loopable = new CameraCinematicZoomToSelf(environment, baseEvent, caster); break; case CameraAction.FxType.SlowMotion: loopable = new CameraSlowMotion(environment, baseEvent); break; case CameraAction.FxType.AddTarget: loopable = new CameraAddTarget(environment, baseEvent, caster); break; default: throw new Exception("Missing logic to handle camera fx of type " + fxType); } break; case ActionType.Dash: Dash dash = new Dash(baseEvent, caster, skill.IgnoreMinSpeedOnAirForDashes(), skill, environment); loopable = dash; break; case ActionType.Jump: bool jumpOverDistance = true; if (args != null) { bool found; jumpOverDistance = args.TryGetEntry <bool>(TemplateArgsName.JumpSkill_JumpOverDistance, out found); if (!found) { jumpOverDistance = true; } } Jump jump = new Jump(baseEvent, caster, skill, environment, jumpOverDistance); loopable = jump; break; case ActionType.Vfx: Vfxs.Vfx vfx = new Vfxs.Vfx( baseEvent, environment, caster, skillCastingSource, skill, args ); loopable = vfx; break; case ActionType.Modifier: ModifierAction ma = (ModifierAction)ba; BaseModifierConfig bmc = ma.modifierConfig; ModifierInfo mi = modifierInfoFactory.CreateFrom(skill, bmc, environment); EntityReference er = caster.GameObject().GetComponent <EntityReference>(); Modifier modifier = DamageSystem.Instance.CreateModifier( mi, er.Entity, er.Entity, caster.Position(), caster.Position(), skill, skillId, 0 ); if (modifier != null) { caster.AddModifier(modifier); } loopable = new ModifierLoopable(modifier); break; case ActionType.Animation: loopable = new AnimationPlayback(baseEvent, caster); break; case ActionType.Teleport: TeleportAction ta = (TeleportAction)baseEvent.action; TeleportAction.ModeName mode = ta.mode.ShowModeName(); switch (mode) { case TeleportAction.ModeName.PredefinedPositionOnMap: new Teleport(baseEvent, caster, environment); loopable = new ImmediatelyFinishedLoopable(); break; case TeleportAction.ModeName.KeepDistance: TeleportAction.KeepDistanceMode kdm = (TeleportAction.KeepDistanceMode)ta.mode; loopable = new TeleportKeepDistanceLogic(kdm, skill, environment, caster); break; case TeleportAction.ModeName.AroundTarget: TeleportAction.AroundTargetMode atm = (TeleportAction.AroundTargetMode)ta.mode; loopable = new TeleportAroundTargetLogic(atm, caster, environment, skill); break; case TeleportAction.ModeName.AroundTeamMate: TeleportAction.AroundTeamMateMode atmm = (TeleportAction.AroundTeamMateMode)ta.mode; loopable = new TeleportAroundTeamMate(atmm, caster, environment, skill); break; default: throw new Exception("Cannot create teleport of type " + mode); } break; case ActionType.FacingDirection: loopable = new FacingDirection(baseEvent, caster, environment); break; case ActionType.DashTowardTarget: DashTowardTarget dtt = new DashTowardTarget(baseEvent, caster, environment); loopable = dtt; break; case ActionType.JumpTowardTarget: loopable = new JumpTowardTarget(baseEvent, caster, environment); break; case ActionType.SpawnCharacter: SpawnCharacterAction sca = (SpawnCharacterAction)ba; loopable = new SpawnCharacter(sca, entitySpawner, caster, args, environment, skillId, hamc); break; case ActionType.Rotation: loopable = new Rotation(baseEvent, caster, environment); break; case ActionType.Timer: loopable = new Timer(baseEvent, skill); break; case ActionType.Sound: loopable = new AudioClipPlayback(baseEvent, environment); break; case ActionType.PassiveSkillOnOff: loopable = new PassiveSkillOnOff(baseEvent, caster); break; case ActionType.DistanceTracker: loopable = new DistanceTracker(baseEvent, skill, caster); break; case ActionType.SelfDamageDealing: loopable = new SelfDamageDealing(baseEvent, caster, skill, skillId); break; case ActionType.SwitchPhase: loopable = new SwitchPhase(skill); break; case ActionType.Movable: Entity casterEntity = caster.GameObject().GetComponent <EntityReference>().Entity; UserInput userInput = casterEntity.GetComponent <HeroStateMachineComponent>().UserInput; MovableAction movableAction = (MovableAction)ba; loopable = new Movable(movableAction, skill, caster.FacingDirection(), userInput, caster); break; case ActionType.Input: casterEntity = caster.GameObject().GetComponent <EntityReference>().Entity; userInput = casterEntity.GetComponent <HeroStateMachineComponent>().UserInput; InputAction ia = (InputAction)ba; loopable = new InputSimulation(ia, (DefaultUserInput)userInput); break; #if UNITY_EDITOR case ActionType.Macro: loopable = new Macro(baseEvent, caster); break; #endif default: DLog.Log("Missing logic to handle action of type " + actionType); break; } return(loopable); }