private void TryActions(SequenceAction[] actions, Transform actor) { if (actions == null) return; foreach (SequenceAction action in actions) { if (action != null && action.condition != null && action.condition.IsTrue(actor)) DoAction(action, actor); } }
public void DoAction(SequenceAction action, Transform actor) { if (action != null) { Transform sequenceActor = Tools.Select(action.actor, this.transform); Transform otherParticipant = Tools.Select(action.otherParticipant, actor); DialogueManager.PlaySequence(action.sequence, sequenceActor, otherParticipant); } }
public void FightDemo1() { SequenceAction demoFight = new SequenceAction(); AnimeAction p1Attack = CreateAttackAction(enemy, hero, 0, true, CreateHitDamageAction(hero)); demoFight.AddAction(p1Attack); AnimeAction p2Attack = CreateAttackAction(hero, enemy, 0, true, CreateHitDamageAction(enemy, slashEffect)); demoFight.AddAction(p2Attack); actionManager.RunAction(demoFight); }
public ActionResult Build([FromBody] BuildVM build) { Console.WriteLine(build != null); var username = SuperDataBase.Configs.GetRealUserName(build.resource.lastChangedBy.uniqueName) ?? SuperDataBase.Configs.GetRealUserName(build.resource.requestedFor.uniqueName) ?? SuperDataBase.Configs.GetRealUserName(build.resource.requestedBy.uniqueName); var display = SuperDataBase.Configs.GetDisplayName(username); if (username == null || display == null) { return(Ok("no user")); } var branch = build.resource.sourceBranch.Split('/').Last(); var part1name = build.resource.result.Equals("succeeded") ? "TBuildSuccessFirst" : "TBuildFailFirst"; var part2name = build.resource.result.Equals("succeeded") ? "TBuildSuccessLast" : "TBuildFailLast"; var actionPart1 = SuperDataBase.Actions.SpeakActions.Where(x => x.Name.StartsWith(part1name)) .GetRandom() .DeepCopy(); var actionPart2 = SuperDataBase.Actions.SpeakActions.Where(x => x.Name.StartsWith(part2name)) .GetRandom() .DeepCopy(); var actionMove = SuperDataBase.Actions["B" + username]; actionPart1.Text = actionPart1.Text.Replace("{branch}", branch); actionPart2.Text = actionPart2.Text.Replace("{userdisplay}", display); var seq = new SequenceAction(); seq.AddPararellActions(actionPart1); seq.AddPararellActions(actionMove); seq.AddPararellActions(actionPart2); SuperDataBase.Queue.Add(new ActionContainer(seq)); return(Ok("queued")); }
//人下船 public void getOffBoat(GameObject people, int shoreNum) { action1 = MoveToAction.GetAction(new Vector3(people.transform.position.x, 2.5f, 0), speed);//人向上移动 if (shoreNum == 0) { action2 = MoveToAction.GetAction(new Vector3(-6f - sceneController.distanceBetweenObj * Convert.ToInt32(people.name), 2.5f, 0), speed); //人向左移动 } else { action2 = MoveToAction.GetAction(new Vector3(6f + sceneController.distanceBetweenObj * Convert.ToInt32(people.name), 2.5f, 0), speed); //人向右移动 } SequenceAction saction = SequenceAction.GetAction(0, 0, new List <SSAction> { action1, action2 }); this.RunAction(people, saction, this); }
public void getOffBoat(GameObject people, int shoreNum) { horizontal = MoveToAction.getAction(new Vector3(people.transform.position.x, 2.7f, 0), speed);//上移 if (shoreNum == 0) { vertical = MoveToAction.getAction(new Vector3(-16f + 1.5f * Convert.ToInt32(people.name), 2.7f, 0), speed); //左移 } else { vertical = MoveToAction.getAction(new Vector3(16f - 1.5f * Convert.ToInt32(people.name), 2.7f, 0), speed); //右移 } SequenceAction saction = SequenceAction.getAction(0, 0, new List <SSAction> { horizontal, vertical }); //将动作组合 this.Action(people, saction, this); }
public void AttackFromTeam(SequenceAction sequence, Model[] attackTeam, Model[] targetTeam) { for (int i = 0; i < attackTeam.Length; i++) { Model actor = attackTeam[i]; Model target = targetTeam[i]; short style = (short)Random.Range(0, 2); effectIndex++; int effectIdx = effectIndex % 2; AnimeAction attackAttack = CreateAttackAction(actor, target, style, true, CreateHitDamageAction(target, effectPrefab[effectIdx])); sequence.AddAction(attackAttack); //for(Model actor in attackTeam) { } }
public AnimeAction CreateProjectileAction(Model actor, Model target, GameObject projectile, GameObject hitEffect) { // Sequence: Projectile Movement, Hit Effect, ModelHit HitValue SequenceAction sequence = new SequenceAction(); Vector3 launchPos = actor.GetLaunchPosition(); Vector3 targetCenterPos = (Vector3)target.GetCenterPosition() + new Vector3(0, 0, -5); Vector3 targetPos = (Vector3)target.GetOriginPosition() + new Vector3(0, 0, -5); float duration = 0.5f; // Projectile Move EffectAction projectileAction = EffectAction.CreateProjectileEffect( projectile, launchPos, targetCenterPos, duration); sequence.AddAction(projectileAction); // Hit Effect ParallelAction damagePack = new ParallelAction(); sequence.AddAction(damagePack); EffectAction effectAction = EffectAction.CreatePointEffect(hitEffect, targetPos); damagePack.AddAction(effectAction); ModelHitAction hitAction = new ModelHitAction(); hitAction.name = "enemyHit"; hitAction.actor = target; damagePack.AddAction(hitAction); int damage = Random.Range(500, 10000); GameTextAction damageAction = GameTextAction.Create( damageTextPrefab, damage.ToString(), target.transform.position + new Vector3(0, 2, -2)); damagePack.AddAction(damageAction); return(sequence); }
public RedirectToActionResult Configs(Configs configs) { configs.UserNamesToUserName.RemoveAll(x => string.IsNullOrEmpty(x.From) || string.IsNullOrEmpty(x.To)); configs.UserNameToDisplayName.RemoveAll(x => string.IsNullOrEmpty(x.From) || string.IsNullOrEmpty(x.To)); SuperDataBase.Configs = configs; var actionIPT = SuperDataBase.Actions.SpeakActions.Where( x => x.Name.StartsWith(configs.IPT >= configs.IPTGoodLimit ? "TGoodMark" : "TBadMark")).GetRandom().DeepCopy(); var actionIET = SuperDataBase.Actions.SpeakActions.Where( x => x.Name.StartsWith(configs.IET <= configs.IETGoodLimit? "TGoodMark" : "TBadMark")).GetRandom().DeepCopy(); actionIET.Text = actionIET.Text.Replace("{current}", configs.IET.ToString()).Replace("{mark}", "erros"); actionIPT.Text = actionIPT.Text.Replace("{current}", configs.IPT.ToString()).Replace("{mark}", "produtividade"); SuperDataBase.Actions.SequenceActions.RemoveAll(x => x.Name.Equals("SMarks")); var actionMarks = new SequenceAction("SMarks"); actionMarks.AddPararellActions(actionIET); actionMarks.AddPararellActions(new SavedAction("Rest")); actionMarks.AddPararellActions(actionIPT); SuperDataBase.Actions.SequenceActions.Add(actionMarks); SuperDataBase.Actions.SequenceActions.RemoveAll(x => x.Name.Equals("SRD")); var actionRD = new SequenceAction("SRD"); actionRD.AddPararellActions(SuperDataBase.Actions.SpeakActions.Where(x => x.Name.StartsWith("TMorningTeam")).GetRandom()); actionRD.AddPararellActions(new SavedAction("Rest")); actionRD.AddPararellActions(actionIET); actionRD.AddPararellActions(new SavedAction("Rest")); actionRD.AddPararellActions(actionIPT); actionRD.AddPararellActions(new SavedAction("Rest")); actionRD.AddPararellActions(SuperDataBase.Actions.SpeakActions.Where(x => x.Name.StartsWith("TTip")).GetRandom()); SuperDataBase.Actions.SequenceActions.Add(actionRD); SuperDataBase.SaveConfigs(); SuperDataBase.SaveActions(); return(RedirectToAction("Configs")); }
public void ShowCubeBubble(Vector3 position, float flyHeight) { var effectObj = _factory.Create("CubeClickBubble"); effectObj.transform.parent = _visualRoot.Root; effectObj.transform.position = position; var effAction = new SequenceAction(); effAction.Add(new MoveToAction(effectObj.transform, new Vector3(position.x, position.y + flyHeight, position.z), 0.7f)); effAction.Add(new FadeToAction(effectObj, 1f, 0f, 0.2f)); effAction.Add(new ExecuteAction(() => { _factory.Remove(effectObj); })); _actionsSequencer.Execute(effAction); }
private void SaveActionOriginalState(SequenceStep step, SequenceAction action, RectTransform xform) { switch (action.Type) { case ActionType.Move: case ActionType.Fly: case ActionType.Shake: action.OrigVector = xform.anchoredPosition3D; break; case ActionType.RotateZ: action.OrigVector = xform.rotation.eulerAngles; break; case ActionType.Scale: action.OrigVector = xform.localScale; break; case ActionType.Fade: { var cg = step.Target.GetComponent <CanvasGroup>(); var graphic = step.Target.GetComponent <Graphic>(); if (cg != null) { action.OrigFloat = cg.alpha; } else if (graphic != null) { action.OrigFloat = graphic.color.a; } break; } case ActionType.Hide: case ActionType.Show: action.OrigFloat = step.Target.activeSelf ? 1 : 0; break; default: break; } }
public static Action getAction(int _i, Passenger[] _passenger, Boat _boat, Callback callback) { List <Action> list = new List <Action>(); list.Add(Action_MoveTo.getAction( _passenger[_i].gameobject(), aboardPoint(_boat.CoastPos == CoastPos.BoatLeft), 0.2f, callback )); list.Add(Action_MoveTo.getAction( _passenger[_i].gameobject(), dist(_passenger, _boat), 0.2f, callback )); Action ac = SequenceAction.getAction(list, callback); return(ac); }
public void Show(string message, Action callback) { _isShowing = true; // Set message _messageText.text = message; var move1 = AnchoredMoveAction.Create(Vector2.zero, false, 0.5f, Ease.SineOut); var delay = DelayAction.Create(1.0f); var move2 = AnchoredMoveAction.Create(new Vector2(0, OffsetY), false, 0.5f, Ease.SineIn); var action = SequenceAction.Create(move1, delay, move2); gameObject.Play(action, () => { _isShowing = false; if (callback != null) { callback(); } }); }
public void OnNextRound(int nextRound) { int index = (nextRound > 3) ? 2 : nextRound - 1; round.SetImageSprite(rounds[index]); target.SetImageSprite(targets[index]); round.Show(); target.Show(); var roundMove1 = AnchoredMoveAction.MoveTo(new Vector2(0, _roundPosition.y), 0.25f, Ease.SineOut); var roundDelay = DelayAction.Create(1.0f); var roundMove2 = AnchoredMoveAction.MoveTo(new Vector2(_targetPosition.x, _roundPosition.y), 0.25f, Ease.SineIn); var targetMove1 = AnchoredMoveAction.MoveTo(new Vector2(0, _targetPosition.y), 0.25f, Ease.SineOut); var targetDelay = DelayAction.Create(1.0f); var targetMove2 = AnchoredMoveAction.MoveTo(new Vector2(_roundPosition.x, _targetPosition.y), 0.25f, Ease.SineIn); round.Play(SequenceAction.Create(roundMove1, roundDelay, roundMove2, SetAnchoredPositionAction.Create(_roundPosition), HideAction.Create())); target.Play(SequenceAction.Create(targetMove1, targetDelay, targetMove2, SetAnchoredPositionAction.Create(_targetPosition), HideAction.Create())); }
public void MoveCharacter(myGame.MyCharacterController characterCtrl, Vector3 destination) { Vector3 currentPos = characterCtrl.getPosition(); Vector3 middlePos = currentPos; if (destination.y > currentPos.y) { middlePos.y = destination.y; } else { middlePos.x = destination.x; } SSAction action1 = SSMoveToAction.GetSSMoveToAction(middlePos, characterCtrl.speed); SSAction action2 = SSMoveToAction.GetSSMoveToAction(destination, characterCtrl.speed); SSAction seqAction = SequenceAction.GetSequenceAction(1, 0, new List <SSAction> { action1, action2 }); AddAction(characterCtrl.getCharacter(), seqAction, this); }
public void moveCharacter(MyCharacterController character, Vector3 target) { Vector3 nowPos = character.getPos(); Vector3 tmpPos = nowPos; if (target.y > nowPos.y) { tmpPos.y = target.y; } else { tmpPos.x = target.x; } SSAction action1 = MoveAction.getAction(tmpPos, character.speed); SSAction action2 = MoveAction.getAction(target, character.speed); SSAction sequenceAction = SequenceAction.getAction(1, 0, new List <SSAction> { action1, action2 }); this.addAction(character.getInstance(), sequenceAction, this); }
void Jump() { Direction direction = _solution.Dequeue(); int nextRow = -1; int nextColumn = -1; if (NextCell(direction, ref nextRow, ref nextColumn)) { // Set direction SetDirection(direction); // Get foothold type FootholdType type = _types[_curRow, _curColumn]; // Update foothold if (type == FootholdType.Double) { // Set foothold SetFoothold(_curRow, _curColumn, FootholdType.Normal); } else if (type != FootholdType.None) { // Set foothold SetFoothold(_curRow, _curColumn, FootholdType.None); } // Set next cell _curRow = nextRow; _curColumn = nextColumn; // Jump var jump = MoveAction.MoveTo(GetPosition(nextRow, nextColumn), jumpDuration * 0.5f); var delay = DelayAction.Create(jumpDuration * 0.5f); var callFunc = CallFuncAction.Create(JumpCallback); var action = SequenceAction.Create(jump, delay, callFunc); _frog.gameObject.Play(action); } }
private void ResetActionToInitialState(SequenceStep step, SequenceAction action) { var xform = step.Target.GetComponent <Transform>(); var rectxform = step.Target.GetComponent <RectTransform>(); switch (action.Type) { case ActionType.Move: case ActionType.Fly: case ActionType.Shake: rectxform.anchoredPosition3D = action.OrigVector; break; case ActionType.RotateZ: xform.rotation = Quaternion.Euler(action.OrigVector); break; case ActionType.Scale: xform.localScale = action.OrigVector; break; case ActionType.Fade: var cg = step.Target.GetComponent <CanvasGroup>(); var graphic = step.Target.GetComponent <Graphic>(); if (cg != null) { cg.alpha = action.OrigFloat; } else if (graphic != null) { graphic.color = graphic.color.WithA(action.OrigFloat); } break; case ActionType.Show: case ActionType.Hide: step.Target.SetActive(action.OrigFloat > 0f); break; } }
public void MoveItem(ItemControl itemCtrl, Vector3 finalDes) { //Debug.Log("enter MoveItem!"); float time = 3; float g = -10; Vector3 v0; float vy_ByGravity = 0; float stepTime = 0.1f; Vector3 currentDes = itemCtrl.item.transform.position; List <SSAction> divide = new List <SSAction>(); // the des here is the final des v0 = new Vector3((finalDes.x - itemCtrl.item.transform.position.x) / time, (finalDes.y - itemCtrl.item.transform.position.y) / time - 0.5f * g * time, (finalDes.z - itemCtrl.item.transform.position.z) / time); //Debug.Log(v0); //Debug.Log(time / stepTime); // divide the curve to many parts for (int i = 0; i < time / stepTime - 1; i++) { //Debug.Log(divide[i]); //Debug.Log(currentDes); // change the vy vy_ByGravity += g * stepTime; // set current des currentDes += v0 * stepTime; currentDes.y += vy_ByGravity * stepTime; // get the current speed float currentSpeed = Mathf.Sqrt(v0.x * v0.x + (v0.y + vy_ByGravity) * (v0.y + vy_ByGravity)); // add one of the movements SSAction temp = SSMoveToAction.GetSSMoveToAction(currentDes, currentSpeed * 10); divide.Add(temp); } SSAction seqAction = SequenceAction.GetSequenceAction(1, 0, divide); AddAction(itemCtrl.item, seqAction, this); }
public AnimeAction CreateProjectileAction(Vector3 startPos, Vector3 targetPos) { ObjectMoveAction projectAction = new ObjectMoveAction(); projectAction.startPosition = startPos + new Vector3(0, 0, zOrderVfx);; projectAction.endPosition = targetPos + new Vector3(0, 1, zOrderVfx); projectAction.objectPrefab = projectilePrefab; projectAction.SetDuration(0.5f); SimpleAnimationAction explodeAction = new SimpleAnimationAction(); explodeAction.clip = explodeEffect; explodeAction.spawnPosition = targetPos + new Vector3(0, 0, zOrderVfx); explodeAction.repeat = 1; SequenceAction fullFireAction = new SequenceAction(); fullFireAction.AddAction(projectAction); fullFireAction.AddAction(explodeAction); return(fullFireAction); }
public AnimeAction GetTargetHitDamageAction() { SequenceAction sequence = new SequenceAction(); sequence.name = "HitSequence"; AnimatorAction hitAction = new AnimatorAction(); hitAction.name = "enemyHit"; hitAction.animator = target; hitAction.triggerState = "Hit"; sequence.AddAction(hitAction); HitValueAction damageAction = new HitValueAction(); damageAction.valueTextPrefab = hitValuePrefab; damageAction.hitValue = 1000; damageAction.position = target.transform.position + new Vector3(0, 1, -2); sequence.AddAction(damageAction); return(sequence); }
public void addRandomAction(GameObject gameObj, float speed) { Vector3 currentPos = gameObj.transform.position; Vector3 randomTarget1 = new Vector3( Random.Range(currentPos.x - 7, currentPos.x + 7), Random.Range(1, currentPos.y + 5), Random.Range(currentPos.z - 7, currentPos.z + 7) ); MoveToAction moveAction1 = MoveToAction.getAction(randomTarget1, speed); Vector3 randomTarget2 = new Vector3( Random.Range(currentPos.x - 7, currentPos.x + 7), Random.Range(1, currentPos.y + 5), Random.Range(currentPos.z - 7, currentPos.z + 7) ); MoveToAction moveAction2 = MoveToAction.getAction(randomTarget2, speed); SequenceAction sequenceAction = SequenceAction.getAction(new List <ObjAction> { moveAction1, moveAction2 }, -1); addAction(gameObj, sequenceAction, this); }
void UpdateTime() { // Get current time int time = Mathf.CeilToInt(_time); if (time != _currentTime) { if (_currentTime > 0) { // Frame frame.StopAction(); frame.Show(); frame.Play(BlinkAction.Create(2, 0.3f, false, false), () => { frame.Hide(); }); // Play effect GameObject effect = numberEffect.gameObject; effect.StopAction(true); effect.Show(); effect.transform.localScale = Vector3.one; effect.SetColor(_currentTime > 3 ? Color.white : alarmColor, true); numberEffect.Number = _currentTime; var zoomOut = ScaleAction.ScaleTo(alarmScale, alarmDuration); var fadeOut = FadeAction.RecursiveFadeOut(alarmDuration); var hide = HideAction.Create(); effect.Play(SequenceAction.Create(ParallelAction.ParallelAll(zoomOut, fadeOut), hide)); } // Set current time _currentTime = time; // Update number number.Number = time; } }
public void CastProjectile() { // Using ObjectMove ObjectMoveAction projectAction = new ObjectMoveAction(); projectAction.startPosition = player.GetLaunchPosition() + new Vector3(0, 0, zOrderVfx);; projectAction.endPosition = enemyAnimator.transform.position + new Vector3(0, 1, zOrderVfx); projectAction.objectPrefab = projectilePrefab; projectAction.SetDuration(0.5f); SimpleAnimationAction explodeAction = new SimpleAnimationAction(); explodeAction.clip = animeClip; explodeAction.spawnPosition = enemyAnimator.transform.position + new Vector3(0, 0, zOrderVfx); explodeAction.repeat = 1; SequenceAction fullFireAction = new SequenceAction(); fullFireAction.AddAction(projectAction); fullFireAction.AddAction(explodeAction); // Using MoveAction // MoveAction moveAction = new MoveAction(); // moveAction.startPosition = player.GetLaunchPosition(); // moveAction.endPosition = enemyAnimator.transform.position + new Vector3(0, 1, 0); // moveAction.targetObject = testObject; // moveAction.SetDuration(0.5f); AnimatorAction animeAction = new AnimatorAction(); animeAction.name = "character"; animeAction.animator = charAnimator; animeAction.triggerState = "Cast"; animeAction.onHitAction = fullFireAction; actionManager.RunAction(animeAction); }
static public Action getAction(int roundNum) { List <Action> acList = new List <Action>(); acList.Add(roundHint.getAction(roundNum)); switch (roundNum) { case 1: for (int times = 3; times-- != 0;) { acList.Add(ThrowUFO.getAction(1, 20)); } break; case 2: for (int times = 3; times-- != 0;) { acList.Add(ThrowUFO.getAction(2, 20)); } break; case 3: for (int times = 5; times-- != 0;) { acList.Add(ThrowUFO.getAction(5, 30)); } break; case 4: for (int times = 10; times-- != 0;) { acList.Add(ThrowUFO.getAction(5, 40)); } break; } return(SequenceAction.getAction(acList)); }
public void SequenceTest() { List <AnimeAction> actionList = new List <AnimeAction>(); AnimatorAction action; action = new AnimatorAction(); action.name = "vfx1"; action.animator = animator1; action.triggerState = "Thunder"; actionList.Add(action); action = new AnimatorAction(); action.name = "vfx2"; action.animator = animator2; action.triggerState = "Fire"; actionList.Add(action); DelayAction delay = new DelayAction(); delay.SetDuration(1.0f); actionList.Add(delay); action = new AnimatorAction(); action.name = "vfx3"; action.animator = animator1; action.triggerState = "Thunder"; actionList.Add(action); SequenceAction sequence = new SequenceAction(); sequence.name = "sequence"; sequence.AddActionList(actionList); actionManager.RunAction(sequence); //action.animator = bat }
private void ReadKeyboardAction() { KeyboardActionBase action; if (radKeyboardDown.Checked) { action = new KeyDownAction(); } else if (radKeyboardPress.Checked) { action = new KeyPressAction(); } else if (radKeyboardUp.Checked) { action = new KeyUpAction(); } else { throw new ArgumentException("Keyboard event type could not be determined."); } action.KeyCode = (VirtualKeyCode)Enum.Parse(typeof(VirtualKeyCode), cmbVKC.SelectedValue.ToString()); SetAction = action; }
public AnimeAction CreateCastAction(string name, string vfx, Animator target, int damage) { SequenceAction sequence = new SequenceAction(); sequence.name = name; Vector3 targetPosition = target.transform.position; AnimatorAction animeAction; VFXAction vfxAction = new VFXAction(); vfxAction.name = "vfxAction"; vfxAction.vfxName = vfx; vfxAction.position = targetPosition + new Vector3(0, 0, -2); vfxAction.vfxPrefab = vfxPrefab; sequence.AddAction(vfxAction); animeAction = new AnimatorAction(); animeAction.name = "enemyHit"; animeAction.animator = target; animeAction.triggerState = "Hit"; sequence.AddAction(animeAction); HitValueAction hitAction = new HitValueAction(); hitAction.valueTextPrefab = hitValuePrefab; hitAction.hitValue = damage; hitAction.position = targetPosition + new Vector3(0, 1, -2); sequence.AddAction(hitAction); return(sequence); }
public void OneOnOne() { Debug.Log("###### TEST 1 ######"); SequenceAction demoFight = new SequenceAction(); BattleModel actor, target; // Right-0 attack Left-0 actor = rightTeam[0]; target = leftTeam[0]; AnimeAction p1Attack = CreateAttackAction(actor, target, 0, true, CreateHitDamageAction(target)); demoFight.AddAction(p1Attack); // Left-0 attack Right-1 actor = leftTeam[0]; target = rightTeam[0]; AnimeAction p2Attack = CreateAttackAction(actor, target, 0, true, CreateHitDamageAction(target, slashEffect[0])); demoFight.AddAction(p2Attack); actionManager.RunAction(demoFight); }
/// <summary> /// 创建自动战斗的行为树。 /// </summary> /// <returns>自动战斗的行为树。</returns> private Action CreateBehaviorTree() { ParallelAction ret = new AutoAI.ParallelAction(); //保持血量 SequenceAction keeplife = new SequenceAction(); keeplife.AddAction(new AutoAICheckLife()); keeplife.AddAction(new AutoAICheckPotion()); keeplife.AddAction(new AutoAIUsePotion()); ret.AddAction(new RepeatAction(keeplife, 0, 5)); //战斗 SequenceAction fight = new SequenceAction(); AutoAIFindTarget find = new AutoAIFindTarget(); fight.AddAction(find); fight.AddAction(new MoveAction(Vector3.zero, 0, find.GetTargetPosition)); fight.AddAction(new AutoAIAttackTarget()); ret.AddAction(new RepeatAction(fight)); //复活 return(ret); }
public void JumpToMap(float delay1, Vector3 position, float delay2, Action callback) { Vector2 start = transform.position; Vector2 end = position; Vector2 control; Direction direction = DirectionHelper.GetDirection(start, end); // Up if (direction.IsUp()) { // Left if (direction.IsLeft()) { animator.SetTrigger(nhayNgang); transform.SetHorizontalFlip(false); control = new Vector2((start.x + end.x) * 0.5f, start.y + Mathf.Sqrt(Mathf.Abs(end.x - start.x)) * controlHeightFactor); } // Right else if (direction.IsRight()) { animator.SetTrigger(nhayNgang); transform.SetHorizontalFlip(true); control = new Vector2((start.x + end.x) * 0.5f, start.y + Mathf.Sqrt(Mathf.Abs(end.x - start.x)) * controlHeightFactor); } else { animator.SetTrigger(nhayLen); transform.SetHorizontalFlip(false); control = new Vector2(start.x, end.y + controlDeltaY); } } else { // Left if (direction.IsLeft()) { animator.SetTrigger(nhayNgang); transform.SetHorizontalFlip(false); control = new Vector2((start.x + end.x) * 0.5f, start.y + Mathf.Sqrt(Mathf.Abs(end.x - start.x)) * controlHeightFactor); } // Right else if (direction.IsRight()) { animator.SetTrigger(nhayNgang); transform.SetHorizontalFlip(true); control = new Vector2((start.x + end.x) * 0.5f, start.y + Mathf.Sqrt(Mathf.Abs(end.x - start.x)) * controlHeightFactor); } else { animator.SetTrigger(nhayXuong); transform.SetHorizontalFlip(false); control = new Vector2(start.x, start.y + controlDeltaY); } } var jump = SequenceAction.Create(QuadBezierAction.BezierTo(control, end, 0.5f), CallFuncAction.Create(() => { animator.SetTrigger(nghiXuong); })); BaseAction action = null; if (delay1 > 0) { if (delay2 > 0) { action = SequenceAction.Create(DelayAction.Create(delay1), jump, DelayAction.Create(delay2)); } else { action = SequenceAction.Create(DelayAction.Create(delay1), jump); } } else { if (delay2 > 0) { action = SequenceAction.Create(jump, DelayAction.Create(delay2)); } else { action = jump; } } // Jump gameObject.Play(action, callback); }
public void SeqTest() { m_SeqAction = new SequenceAction(); ActionTween mRotActionTween = this.transform.RotationTween(m_RotToValue, mDuration, m_RotModle); mRotActionTween .SetEase(mEaseType) .SetActionDirectionType(mDirectionType) .SetActionScaleTime(mScaleTime) .SetActionType(mActionType) .SetLoopTime(mLoopTime) .SetSpeedAble(m_UseSpeed) .SetSpeed(m_Speed) .SetRelative(m_Relative) .SetAutoKill(mAutoKill) .SetKillCallback(() => { LOG.Log("mRotActionTween Kill"); }) .SetCompleteCallback(() => { // LOG.Log("mRotActionTween Finish"); }); var moveAction = this.transform.MoveTween(mTargetTran, mDuration); moveAction .SetEase(mEaseType) .SetActionDirectionType(mDirectionType) .SetActionScaleTime(mScaleTime) .SetActionType(mActionType) .SetLoopTime(0) .SetSpeedAble(m_UseSpeed) .SetSpeed(m_Speed) .SetRelative(m_Relative) .SetAutoKill(mAutoKill); var colorAction = this.transform.ColorTween(Color.blue, mDuration); colorAction.SetActionType(mActionType); m_SeqAction.Add(0, mRotActionTween); m_SeqAction.Add(2, moveAction); m_SeqAction.Append(colorAction); m_SeqAction // .SetActionType(mActionType) .SetAutoKill(mAutoKill) .SetStepUpdateCallback(() => { mActionCurTime = Time.realtimeSinceStartup - mTempTime; }) .SetBeginPlayCallback(() => { mTempTime = Time.realtimeSinceStartup; // LOG.Log(this.gameObject.name + " anim Begin m_SeqAction"); }) .SetCompleteCallback(() => { mActionExTime = Time.realtimeSinceStartup - mTempTime; //LOG.Log(this.gameObject.name + " anim Complete m_SeqAction"); }) .SetKillCallback(() => { LOG.Log(this.gameObject.name + " anim Kill m_SeqAction"); }); m_SeqAction.SetAutoPlay(m_AutoPlay); mTestActionTween = m_SeqAction; }