public int movePlayer(Player player, List <Hex> hexPath, AnimationCallback callback) { int numHexesMoved = 0; if (hexPath.Count > 0) { // Get the center point of each hex List <HexPointF> centerPoints = new List <HexPointF>(); foreach (Hex hex in hexPath) { HexPointF centerPoint = hex.getCenter(); centerPoints.Add(centerPoint); } List <Vector3> vectorPath = new List <Vector3>(); HexPointF[] centerArray = centerPoints.ToArray(); int maxPoints = centerArray.Length; HexPointF point1, point2; for (int index = 0; index <= maxPoints - 2; index++) { point1 = centerArray[index]; point2 = centerArray[index + 1]; vectorPath.AddRange(findPointsAlongLine3D(point1, point2, player.WalkingSpeed)); } player.walk(vectorPath, callback); } return(hexPath.Count); }
void OnEnemyIntro(AnimationCallback animCallback) { gameManager.ShowGamePanelEnemy(); Sequence uiFadeInSequence = DOTween.Sequence(); uiFadeInSequence.Insert(0f, knobControl.transform.DOScale(0f, 1f).SetEase(Ease.InOutBack)); uiFadeInSequence.Insert(0f, knobControl.GetComponent <CanvasGroup>().DOFade(0f, 1f)); float delay = 0f; foreach (SelectorScript selector in selectors) { // Fade In NoteGenerators uiFadeInSequence.Insert(delay, selector.GetComponent <Image>().DOColor(new Color(0f, 0f, 0f, 0f), 0.5f)); delay += 0.2f; } uiFadeInSequence.OnComplete(() => { // Fade color to grey FadeOutBoardBG(animCallback); //FadeColorUI(Color.grey, animCallback, true); }); }
public void FadeColorUI(Color uiColor, AnimationCallback animationCallback, bool isEnemySelect) { Sequence uiColorSequence = DOTween.Sequence(); uiColorSequence.Insert(0f, overlayImage.DOColor(uiColor, 0.5f)); float delay = 0.0f; foreach (NoteGeneratorScript noteGen in noteGenerators) { // Fade In NoteGenerators uiColorSequence.Insert(delay, noteGen.GetComponent <Image>().DOColor(uiColor, 0.5f)); delay += 0.1f; } if (!isEnemySelect) { foreach (SelectorScript selector in selectors) { // Fade In NoteGenerators uiColorSequence.Insert(delay, selector.GetComponent <Image>().DOColor(uiColor, 0.5f)); delay += 0.2f; } } // set is turn visible to true on complete uiColorSequence.OnComplete(() => { animationCallback?.Invoke(); }); }
public void EndGameUI(bool hasWon, AnimationCallback animCallback) { uiSequence.Complete(); RectTransform band1Transform = band1Poster.GetComponent <RectTransform>(); RectTransform band2Transform = band2Poster.GetComponent <RectTransform>(); bandBattleImage.transform.localScale = Vector3.zero; band1Transform.localScale = Vector3.zero; band2Transform.localScale = Vector3.zero; band1Poster.gameObject.SetActive(true); band2Poster.gameObject.SetActive(true); bandBattleImage.gameObject.SetActive(true); uiSequence = DOTween.Sequence(); uiSequence.Insert(0f, bandBattleImage.DOFade(1f, encounterConstants.startUIFadeDuration / 2)); uiSequence.Insert(encounterConstants.startUIFadeDuration / 4, band1Poster.DOFade(1f, encounterConstants.startUIFadeDuration / 4)); uiSequence.Insert(encounterConstants.startUIFadeDuration / 4, band1Transform.DOScale(1f, encounterConstants.startUIFadeDuration / 3).SetEase(Ease.InOutBack)); uiSequence.Insert(encounterConstants.startUIFadeDuration / 3, band2Poster.DOFade(1f, encounterConstants.startUIFadeDuration / 4)); uiSequence.Insert(encounterConstants.startUIFadeDuration / 3, band2Transform.DOScale(1f, encounterConstants.startUIFadeDuration / 3).SetEase(Ease.InOutBack)); ShowTextDescription(hasWon ? encounterConstants.UITextSets[9] : encounterConstants.UITextSets[10]); winnerStamp.GetComponent <RectTransform>().position = hasWon ? band1Transform.position: band2Transform.position; uiSequence.Insert(encounterConstants.startUIFadeDuration / 2, winnerStamp.DOFade(1f, encounterConstants.startUIFadeDuration / 3)); uiSequence.OnComplete(() => { animCallback?.Invoke(); }); }
public void FadeInSelectorUI(AnimationCallback animationCallback) { Sequence uiFadeInSequence = DOTween.Sequence(); float delay = 0.0f; foreach (NoteGeneratorScript noteGen in noteGenerators) { // Fade In NoteGenerators noteGen.transform.localScale = Vector3.one * 0.75f; uiFadeInSequence.Insert(delay, noteGen.GetComponent <Image>().DOColor(new Color(1f, 1f, 1f, 1f), 0.5f)); uiFadeInSequence.Insert(delay + 0.1f, noteGen.transform.DOScale(1, 0.25f).SetEase(Ease.InOutBack)); delay += 0.1f; } foreach (SelectorScript selector in selectors) { // Fade In NoteGenerators selector.transform.localScale = Vector3.one * 1.2f; uiFadeInSequence.Insert(delay, selector.GetComponent <Image>().DOColor(new Color(1f, 1f, 1f, 1f), 0.5f)); uiFadeInSequence.Insert(delay + 0.1f, selector.transform.DOScale(1, 0.25f).SetEase(Ease.InOutBack)); delay += 0.2f; } // set is turn visible to true on complete uiFadeInSequence.OnComplete(() => { animationCallback(); }); }
public void ClearUI(AnimationCallback animCallback) { Sequence uiFadeOutSequence = DOTween.Sequence(); isTurnVisible = false; playerEntities.ResetBandEndTurn(); HideMoveDescription(); uiFadeOutSequence.Insert(0f, GetComponent <CanvasGroup>().DOFade(0f, 1f)); uiFadeOutSequence.Insert(0f, transform.DOScale(0.75f, 0.25f)); foreach (NoteGeneratorScript noteGen in noteGenerators) { uiFadeOutSequence.Insert(0f, noteGen.transform.DOScale(0.1f, 0.35f)); uiFadeOutSequence.Insert(0f, noteGen.GetComponent <Image>().DOColor(new Color(1f, 1f, 1f, 0f), 0.5f)); } foreach (SelectorScript selector in selectors) { uiFadeOutSequence.Insert(0f, selector.transform.DOScale(0.0f, 0.35f)); uiFadeOutSequence.Insert(0f, selector.GetComponent <Image>().DOColor(new Color(1f, 1f, 1f, 0f), 0.5f)); } uiFadeOutSequence.Insert(0f, knobControl.GetComponent <CanvasGroup>().DOFade(0f, 0.5f)); uiFadeOutSequence.OnComplete(() => { animCallback?.Invoke(); }); }
public void StartGameUI(AnimationCallback animCallback) { uiSequence.Complete(); Transform band1Transform = band1Poster.GetComponent <Transform>(); Transform band2Transform = band2Poster.GetComponent <Transform>(); ShowTextDescription(encounterConstants.UITextSets[1]); uiSequence = DOTween.Sequence(); uiSequence.Insert(encounterConstants.startGameUIFadeDuration / 2, bandBattleImage.DOFade(0f, encounterConstants.startGameUIFadeDuration / 2)); uiSequence.Insert(encounterConstants.startGameUIFadeDuration / 2, bandBattleImage.GetComponent <Transform>().DOScale(1.5f, encounterConstants.startGameUIFadeDuration / 2).SetEase(Ease.InOutBack)); uiSequence.Insert(encounterConstants.startGameUIFadeDuration / 4, band1Poster.DOFade(0f, encounterConstants.startGameUIFadeDuration / 4)); uiSequence.Insert(encounterConstants.startGameUIFadeDuration / 4, band1Transform.DOScale(0.8f, encounterConstants.startGameUIFadeDuration / 3).SetEase(Ease.InOutBack)); uiSequence.Insert(encounterConstants.startUIFadeDuration / 4, band2Poster.DOFade(0f, encounterConstants.startUIFadeDuration / 4)); uiSequence.Insert(encounterConstants.startUIFadeDuration / 4, band2Transform.DOScale(0.8f, encounterConstants.startUIFadeDuration / 3).SetEase(Ease.InOutBack)); uiSequence.OnComplete(() => { band1Poster.gameObject.SetActive(false); band2Poster.gameObject.SetActive(false); bandBattleImage.gameObject.SetActive(false); animCallback?.Invoke(); }); }
public override void walk(List <Vector3> path, AnimationCallback callback) { animationCallback = callback; movePath = path; totalMoveCount = path.Count; showPlayerWalking(); }
public override void OnInitialized() { _rigidbody = _owner.GetComponent <Rigidbody2D>(); _collider = _owner.GetComponent <Collider2D>(); _animator = _owner.GetComponent <Animator>(); _animDeadTrigger = Animator.StringToHash(AnimatorKey.Dead); _animationCallback = _owner.GetComponent <AnimationCallback>(); }
public override void hit(Ammo ammo, AnimationCallback callback) { animationCallback = callback; // TO DO: Change animation based on the ammo that hit you. If it was a flamethrower then the player would be on fire. MyAttributes.hitPoints -= ammo.HitPoints; showPlayerBeenHit(); }
public override void OnInitialized() { _animator = _owner.GetComponent <Animator>(); _animHurtTrigger = Animator.StringToHash(AnimatorKey.Hurt); _rigidbody = _owner.GetComponent <Rigidbody2D>(); _animationCallback = _owner.GetComponent <AnimationCallback>(); }
void OnPlay(AnimationCallback animCallback) { gameManager.ShowGamePanelTurn(); OnNoteGeneratorFade(() => { FadeInSelectorUI(animCallback); }); }
public static void setAnimationCallback(AnimationCallback animationCallback) { if (animationCallback != null) { AnimationModel.OnConnectAnimateionPause = new AnimationModel.OnConnectAnimateionPauseDelegate(animationCallback.OnConnectAnimateionPause); AnimationModel.OnConnectAnimateionResume = new AnimationModel.OnConnectAnimateionResumeDelegate(animationCallback.OnConnectAnimateionResume); } }
private void Init(Transform transform, Vector3 from, Vector3 to, float animTime, Property property, AnimationCallback callback = null) { this.transform = transform; this.from = from; this.to = to; this.animTime = animTime; this.property = property; this.callback = callback; }
public override void OnInitialized() { _animator = _owner.GetComponent <Animator>(); _animationCallback = _owner.GetComponent <AnimationCallback>(); _attackAnimHash = Animator.StringToHash("Attack"); _piranhaController = _owner as EnemyControllerPiranhaPlant; _shootOffset = _piranhaController._shootOffset; }
void OnStartGame(AnimationCallback animCallback) { currentPlayer = -1; // Set initial sizes and scales playerEntities.StartTurn(); animCallback(); }
private void OnHyped(AnimationCallback animCallback) { gameManager.ShowGamePanelTurn(); knobControl.OnHypeSelector(); OnNoteGeneratorFade(() => { playerEntities.OnHyped(); FadeInSelectorUI(animCallback); }); }
void OnNoteGeneratorFade(AnimationCallback animCallback) { transform.localScale = Vector3.one * 0.8f; // Start animations and on complete, go to Intro transform.DOScale(1f, 0.25f); GetComponent <CanvasGroup>().DOFade(1f, 1f).OnComplete(() => { animCallback?.Invoke(); }); }
public static void TopDown2DVectorTouchControl( float rotationAmount, float xVelocity, float zVelocity, bool buttonPressed, out Vector3 displacementVector, out Vector3 rotationalVector, Transform transform = null, ActionCallback actionCallback = null, AnimationCallback animationCallback = null) { displacementVector = Vector3.zero; if (transform == null) { rotationalVector = Vector3.zero; } else { rotationalVector = transform.rotation.eulerAngles; } if (animationCallback == null) { animationCallback = DefaultAnimationCallback; } if (actionCallback == null) { actionCallback = DefaultActionCallback; } if (buttonPressed) { actionCallback(); animationCallback(actionAnimation: true); } rotationalVector.z -= xVelocity * rotationAmount; displacementVector = VectorAnalysis.CalculateDisplacementFromAngle2D(rotationalVector) * zVelocity; if (displacementVector != Vector3.zero && ((transform != null && rotationalVector != transform.rotation.eulerAngles) || rotationalVector != Vector3.zero)) { animationCallback(travelAnimation: true); } else { animationCallback(idleAnimation: true); } }
public void Restore(SwipeConfig config, AnimationCallback beginRestoreCallback, Action restoreCompleteCallback) { beginRestoreCallback?.Invoke(config.EasingFunc, 0, config.Duration); DisplayAnimation(config, 0, 0, ()=> { config.SwipeClipRectangle.Rect = new Rect(0, 0, 0, config.ItemActualHeight); config.SwipeClipTransform.ScaleX = 1; restoreCompleteCallback?.Invoke(); }); }
public void Restore(SwipeConfig config, AnimationCallback beginRestoreCallback, Action restoreCompleteCallback) { beginRestoreCallback?.Invoke(config.EasingFunc, 0, config.Duration); DisplayAnimation(config, 0, 0, () => { config.SwipeClipRectangle.Rect = new Rect(0, 0, 0, 0); config.SwipeClipTransform.ScaleX = 1; restoreCompleteCallback?.Invoke(); }); }
public void AdvanceTime(int id, double time, AnimationCallback handler) { foreach (var pair in renderObjects) { AnimationController animationController = pair.Value.AnimationController; animationController.SetTrackSpeed(id, 1); animationController.AdvanceTime(time, handler); animationController.SetTrackSpeed(id, 0); } Render(); }
/* Set Callback * Add callback to animation. * * Callbacks are called when the animation ends. */ public UIAnimation SetCallback(AnimationCallback callback, bool add = false) { if (add) { onFinish += callback; } else { onFinish = callback; } return(this); }
public void OnPlaySongComplete() { if (currentState == NotesGameStates.Hyped) { hypedCount++; playHypeSongCallback?.Invoke(); } else { playSongCallback?.Invoke(); playSongCallback = null; } }
public void EnemyIntroUI(AnimationCallback animCallback) { uiSequence.Complete(); uiSequence = DOTween.Sequence(); ShowTextDescription(encounterConstants.UITextSets[5]); uiSequence.OnComplete(() => { animCallback?.Invoke(); }); }
public void TurnPlayoutUI(bool isBetter, AnimationCallback animCallback) { uiSequence.Complete(); uiSequence = DOTween.Sequence(); ShowTextDescription(isBetter ? encounterConstants.UITextSets[6]: encounterConstants.UITextSets[7]); uiSequence.OnComplete(() => { animCallback?.Invoke(); }); }
public static void FirstPersonTouchScreenControlHandler( float xVelocity, float zVelocity, bool buttonPressed, out Vector3 displacementVector, out Vector3 rotationalVector, Transform transform = null, ActionCallback actionCallback = null, AnimationCallback animationCallback = null) { displacementVector = Vector3.zero; if (transform == null) { rotationalVector = Vector3.zero; } else { rotationalVector = transform.rotation.eulerAngles; } if (animationCallback == null) { animationCallback = DefaultAnimationCallback; } if (actionCallback == null) { actionCallback = DefaultActionCallback; } if (buttonPressed) { actionCallback(); animationCallback(actionAnimation: true); } rotationalVector.y += xVelocity; displacementVector = VectorAnalysis.CalculateDisplacementFromAngle(rotationalVector) * zVelocity; if (displacementVector != Vector3.zero && rotationalVector != transform.rotation.eulerAngles) { animationCallback(travelAnimation: true); } else { animationCallback(idleAnimation: true); } }
/// <summary> /// Manages tracking the progress of an animation, running a callback with the information. /// Returns a lifetime that ends when the animation has expired. /// </summary> public static Lifetime AnimateWith(this Game game, TimeSpan duration, AnimationCallback callback, Lifetime? constraint = default(Lifetime?)) { var remaining = duration; var life = (constraint ?? game.Life).CreateDependentSource(); game.LoopActions.Add( step => { remaining -= step.TimeStep; if (remaining >= TimeSpan.Zero) { callback(step, 1 - remaining.TotalSeconds / duration.TotalSeconds, duration - remaining); } else { life.EndLifetime(); } }, life.Lifetime); return life.Lifetime; }
public void IntroUI(bool canHype, AnimationCallback animCallback) { uiSequence.Complete(); uiSequence = DOTween.Sequence(); // Fade out text and change values // If canHype, Show different text ShowTextDescription(canHype ? encounterConstants.UITextSets[8] : encounterConstants.UITextSets[2]); uiSequence.OnComplete(() => { animCallback?.Invoke(); }); }
public int handleCombatChooseMove(AnimationCallback callback) { // locate the nearest human List <Human> humans = MyBoard.getHumans(); if (humans.Count() > 0) { Human human = humans[0]; HexBoard hexBoard = MyBoard.MyHexBoard; return(MyBoard.movePlayer(this, human.Location, MyAttributes.actionPoints, callback)); } return(0); }
public override void die(AnimationCallback callback) { animationCallback = callback; animationType = AnimationType.Dying; showPlayerDying(); this.isActive = false; this.isAlive = false; // Move the player to an inactive state on the hex board Hex currentHex = getCurrentHex(); currentHex.MyGameEntity = null; currentHex.InactiveEntity = this; }
public static void TopDownTouchScreenControlHandler( float xVelocity, float zVelocity, bool buttonPressed, out Vector3 displacementVector, out Vector3 rotationalVector, Transform transform = null, ActionCallback actionCallback = null, AnimationCallback animationCallback = null) { displacementVector = new Vector3(xVelocity, 0, zVelocity); if (transform == null) { rotationalVector = Vector3.zero; } else { rotationalVector = transform.rotation.eulerAngles; } rotationalVector.y = VectorAnalysis.CalculateAngleFromDisplacement(displacementVector); if (animationCallback == null) { animationCallback = DefaultAnimationCallback; } if (actionCallback == null) { actionCallback = DefaultActionCallback; } if (buttonPressed) { actionCallback(); animationCallback(actionAnimation: true); } if (displacementVector != Vector3.zero) { animationCallback(travelAnimation: true); } else { animationCallback(idleAnimation: true); } }
void invokeEvents(AnimationCallback.AnimationCallbackType t, Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { switch(t) { case AnimationCallbackType.Enter: foreach (AnimationCallback.AnimationListener l in m_Listeners) l.OnStateEnter(animator, stateInfo, layerIndex); break; case AnimationCallbackType.Stay: foreach (AnimationCallback.AnimationListener l in m_Listeners) l.OnStateUpdate(animator, stateInfo, layerIndex); break; case AnimationCallbackType.Exit: foreach (AnimationCallback.AnimationListener l in m_Listeners) l.OnStateExit(animator, stateInfo, layerIndex); break; default: break; } }
public Animation(AnimationTypes type, object target, int offset, AnimationFinishedHandler handler, int duration, AnimationCallback callback, int startValue) { this.type = type; this.target = target; this.offset = offset; this.handler = handler; this.duration = duration; // timings in ms interval = 10; timePassed = 0; Control c; Form f; switch (type) { case AnimationTypes.ResizeHoriz: c = target as Control; if (c == null) return; start = c.Width; end = start + offset; if (this.duration == 0) this.duration = 150; break; case AnimationTypes.ResizeVert: c = target as Control; if (c == null) return; start = c.Height; end = start + offset; if (this.duration == 0) this.duration = 150; break; case AnimationTypes.FadeIn: f = target as Form; if (f == null) return; start = (int)(f.Opacity * 100); end = start + offset; if (this.duration == 0) this.duration = 250; break; case AnimationTypes.FadeOut: f = target as Form; if (f == null) return; start = (int)(f.Opacity * 100); end = start + offset; if (this.duration == 0) this.duration = 2000; break; case AnimationTypes.Callback: if (callback == null) return; start = startValue; end = start + offset; if (this.duration == 0) this.duration = 1000; this.callback = callback; break; default: return; } Next(); }
public abstract void ActionTrigger(SwipeDirection direction, SwipeConfig config, AnimationCallback beginTriggerCallback, Action triggerCompleteCallback);
public override void ActionTrigger(SwipeDirection direction, SwipeConfig config, AnimationCallback beginTriggerCallback, Action triggerCompleteCallback) { beginTriggerCallback?.Invoke(config.EasingFunc, 0, config.Duration); DisplayAnimation(config, 0, 0, () => { triggerCompleteCallback?.Invoke(); config.AdjustForNotSwipeFixCompleted(); }); }
public void DisplaySwipeAnimation(SwipeDirection direction, AnimationCallback beginTriggerCallback, Action triggerCompleteCallback, AnimationCallback beginRestoreCallback, Action restoreCompleteCallback) { var swipeAnimator = GetSwipeAnimator(_config.GetSwipeMode(direction)); if (swipeAnimator == null) return; Config.ResetSwipeClipCenterX(); if (swipeAnimator.ShouldTriggerAction(Config)) { swipeAnimator.ActionTrigger(direction, Config, beginTriggerCallback, triggerCompleteCallback); } else { swipeAnimator.Restore(Config, beginRestoreCallback, restoreCompleteCallback); } }
public void AddListener(AnimationCallback.AnimationListener l) { m_Listeners.Enqueue(l); }
public override void ActionTrigger(SwipeDirection direction, SwipeConfig config, AnimationCallback beginTriggerCallback, Action triggerCompleteCallback) { var targetWidth = config.TriggerActionTargetWidth; var targetX = config.Direction == SwipeDirection.Left ? targetWidth : -targetWidth; var clipScaleX = targetWidth / config.CurrentSwipeWidth; beginTriggerCallback?.Invoke(config.EasingFunc, targetX, config.Duration); DisplayAnimation(config, targetX, clipScaleX, ()=> { triggerCompleteCallback?.Invoke(); config.AdjustForSwipeFixCompleted(targetWidth); }); }