/// <summary> /// Function used to transition the animation for the guy. /// </summary> private static void AnimationTransition() { // We'll cycle between different animations depending on where we are on the screen. switch (_current) { case AnimationName.WalkUp: if (_controller.State != AnimationState.Playing) { _controller.Play(_guySprite, _animations[_current]); } _guyPosition.Y -= (_guySprite.ScaledSize.Height / 4.0f) * GorgonTiming.Delta; if (_guySprite.Position.Y < _icicle.Position.Y + 16) { _controller.Stop(); _current = AnimationName.Turn; // Make it so the guy will appear behind the icicle. _guySprite.Depth = _icicle.Depth + 0.1f; _controller.Play(_guySprite, _animations[_current]); } break; case AnimationName.Turn: if (_controller.State == AnimationState.Stopped) { _current = AnimationName.WalkLeft; } break; case AnimationName.WalkLeft: if (_controller.State != AnimationState.Playing) { _controller.Play(_guySprite, _animations[_current]); } _guyPosition.X -= (_guySprite.ScaledSize.Width / 2.25f) * GorgonTiming.Delta; if (_guySprite.Position.X < -_guySprite.ScaledSize.Width * 1.25f) { _controller.Stop(); // If we reach the extreme left of the screen (and we're off screen), then move to the right side and continue this animation. if (_guyPosition.Y < _icicle.Position.Y + _snowTile.ScaledSize.Height) { _guyPosition = new DX.Vector2(_screen.Width + _guySprite.ScaledSize.Width * 1.25f, _icicle.Position.Y + _icicle.ScaledSize.Height / 2.0f); } else { // Otherwise, reset and start over. _current = AnimationName.WalkUp; _guyPosition = new DX.Vector2(_screen.Width / 2 + _guySprite.ScaledSize.Width * 1.25f, _screen.Height + _snowTile.ScaledSize.Height); } // Ensure that the guy's depth value is less than the icicle so he'll appear in front of it. _guySprite.Depth = _icicle.Depth - 0.1f; } break; } }
//public event AnimationEventFunction onFinish; public SpriteAnimation(Sprite sprite, AnimationName animationName) { spriteSheetVariants = new Sprite[1]; spriteSheetVariants[0] = sprite; name = animationName; loops = !(animationName == AnimationName.Attack || animationName == AnimationName.Death); }
public void SetAnimation(AnimationName animationName, bool resetAnimationToStart = false) { if (resetAnimationToStart) { animationTime = 0f; } CurrentAnimation = animations.Get(animationName); }
public void SetAnimation(AnimationName name) { if (DefaultClient.OptimizeForServer()) { return; } SetAnimation(name, AnimationLayer.Base); }
public TweenData(MonoBehaviour mono, AnimationName animation, FunctionName function, float duration, GameObject gameObject, params object[] customData) { Mono = mono; Animation = Animations[(int)animation]( Functions[(int)function], duration, gameObject, customData); Duration = duration; GameObject = gameObject; CustomData = customData; }
private IEnumerator DisableCollider(GameObject collider, AnimationName animation) { yield return(new WaitForSeconds(exitTime)); collider.SetActive(false); //还原collieder的初始属性和bool值 collider.transform.position = rb.position; collider.transform.rotation = Quaternion.identity; actionBoolArray[(int)animation] = false; }
/*---- 碰撞体相关function ----*/ private IEnumerator EnableCollider(AnimationName animation) { yield return(new WaitForSeconds(startTime)); switch (animation) { case AnimationName.Enemy_S_Attack: hitbox = AttackDirction(); break; } StartCoroutine(DisableCollider(hitbox, animation)); }
/// <summary> /// 更换动画状态 /// </summary> /// <param name="newAnimation">需要更换的动画名称</param> private void ChangeAnimationStates(AnimationName newAnimation) { //如果正在播放动画则直接返回 if (currentAnimation == newAnimation) { return; } //核心function,直接播放对应名称动画 animator.Play(newAnimation.ToString()); //播放完赋值给现在动画 currentAnimation = newAnimation; }
private void SetFlashText(AnimationName iName) { if (iName == AnimationName.ProdNormalAttackLine) { _uiFlashText.SetActive(isActive: true); _uiFlashText.pivot = UIWidget.Pivot.Center; Vector2 localSize = _listSlots[0].slotName.localSize; float num = localSize.x / 2f; _uiFlashText.transform.localPosition = new Vector3(num * (float)((!_isFriend) ? 1 : (-1)), 0f, 0f); _uiFlashText.text = _listSlots[0].slotName.text; } else { _uiFlashText.SetActive(isActive: false); } }
static void SetAniamtionSpeed(AnimatorController ac, AnimationName name, float speed) { //AnimatorController ac = animator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController; AnimatorControllerLayer[] layers = ac.layers; AnimatorStateMachine state = layers[0].stateMachine; ChildAnimatorState[] sts = state.states; for (int i = 0; i < sts.Length; i++) { if (name.ToString() == sts[i].state.name) { sts[i].state.speed = speed; Debug.Log(name + "------修改成功"); break; } } }
private int GetTriggerId(AnimationName name, AnimationLayer layer) { if (!layers.ContainsKey(layer)) { layers[layer] = new Dictionary <AnimationName, int>(); } if (!layers[layer].ContainsKey(name)) { string pathName = layer.ToString() + "." + name.ToString(); int pathHash = Animator.StringToHash(pathName); layers[layer][name] = pathHash; triggerNames[pathHash] = pathName; } return(layers[layer][name]); }
internal bool SwapToAnimation(AnimationName _Name) { if (!Animations.ContainsKey(_Name)) { return(false); } if (CurrentAnimation.AlwaysFinnish && !IsAnimationOver) { mNextAnimationName = _Name; } else { CurrentAnimation = Animations[_Name]; mNextAnimationName = null; } return(true); }
public override void PrepareFrame(Playable playable, FrameData info) { int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); ScriptPlayable <GfxAnimatorBehaviour> inputPlayable = (ScriptPlayable <GfxAnimatorBehaviour>)playable.GetInput(i); GfxAnimatorBehaviour input = inputPlayable.GetBehaviour(); if (inputWeight == 1.0f && animationName != input.animationName) { animationName = input.animationName; } } base.PrepareFrame(playable, info); }
private void SetSlotIconPos(AnimationName iName) { Vector3 localPosition = Vector3.zero; switch (iName) { case AnimationName.ProdNormalAttackLine: localPosition = new Vector3(138f * (float)((!_isFriend) ? 1 : (-1)), 194f, 0f); break; case AnimationName.ProdAircraftAttackLine: localPosition = Vector3.zero; break; default: localPosition = Vector3.up * 30f; break; } _listSlots[0].slotIcon.transform.localPosition = localPosition; }
internal bool AddAnimation(AnimationName _Name, Animation _Animation, bool _OverwriteOld = false) { if (Animations.ContainsKey(_Name)) { if (_OverwriteOld != true) { return(false); } Animations[_Name] = _Animation; return(true); } else { Animations.Add(_Name, _Animation); if (CurrentAnimation == null) { CurrentAnimation = Animations[_Name]; } return(true); } }
public void Play(AnimationName iName, bool isNotFlipHorizontal, Action callback) { _isFriend = isNotFlipHorizontal; panel.widgetsAreStatic = false; _listOverlay.ForEach(delegate(UITexture x) { Color color = (!_isFriend) ? new Color(1f, 0f, 0f, x.alpha) : new Color(0f, 51f / 160f, 1f, x.alpha); x.transform.localScaleOne(); x.color = color; }); this.isNotFlipHorizontal = isNotFlipHorizontal; slotIconActive = iName; depth = iName; ResetRotation(); SetFlashText(iName); _clsGlowIcon.isActive = (iName == AnimationName.ProdAircraftAttackLine); _clsNoiseMove.enabled = (iName == AnimationName.ProdAircraftAttackLine); SetSlotIconPos(iName); slotNamePivot = iName; base.transform.localScaleOne(); base.Play(iName, callback); }
private int GetTriggerId(AnimationName name, AnimationLayer layer) { if (!layers.ContainsKey(layer)) { layers[layer] = new Dictionary<AnimationName, int>(); } if (!layers[layer].ContainsKey(name)) { string pathName = layer.ToString() + "." + name.ToString(); int pathHash = Animator.StringToHash(pathName); layers[layer][name] = pathHash; triggerNames[pathHash] = pathName; } return layers[layer][name]; }
public static Unit Create(UnitType unittype, Owner owner, int hp = 10, AnimationName startingAnimation = AnimationName.idle, Guid guid = default(Guid)) { AnimatedEntity animEntity = new AnimatedEntity(Vector2.Zero, Vector2.Zero, Color.White, LayerDepth.Unit); animEntity.LoadContent(CONTENT_MANAGER.animationSheets[unittype.GetSpriteSheetUnit(owner)]); #region declare animation frame Animation idle; Animation right; Animation up; Animation down; Animation done; switch (unittype) { case UnitType.TransportCopter: case UnitType.BattleCopter: animEntity.Origin = new Vector2(8, 16); idle = new Animation("idle", true, 3, string.Empty); for (int i = 0; i < 3; i++) { idle.AddKeyFrame(i * 64, 0, 64, 64); } right = new Animation("right", true, 4, string.Empty); for (int i = 0; i < 4; i++) { right.AddKeyFrame(i * 64, 64, 64, 64); } up = new Animation("up", true, 4, string.Empty); for (int i = 0; i < 4; i++) { up.AddKeyFrame(i * 64, 128, 64, 64); } down = new Animation("down", true, 4, string.Empty); for (int i = 0; i < 4; i++) { down.AddKeyFrame(i * 64, 192, 64, 64); } done = new Animation("done", true, 1, string.Empty); done.AddKeyFrame(0, 256, 64, 64); break; case UnitType.Fighter: case UnitType.Bomber: animEntity.Origin = new Vector2(8, 16); idle = new Animation("idle", true, 4, string.Empty); for (int i = 0; i < 4; i++) { idle.AddKeyFrame(i * 64, 0, 64, 64); } right = new Animation("right", true, 4, string.Empty); for (int i = 0; i < 4; i++) { right.AddKeyFrame(i * 64, 64, 64, 64); } up = new Animation("up", true, 4, string.Empty); for (int i = 0; i < 4; i++) { up.AddKeyFrame(i * 64, 128, 64, 64); } down = new Animation("down", true, 4, string.Empty); for (int i = 0; i < 4; i++) { down.AddKeyFrame(i * 64, 192, 64, 64); } done = new Animation("done", true, 1, string.Empty); done.AddKeyFrame(0, 256, 64, 64); break; default: idle = new Animation("idle", true, 4, string.Empty); for (int i = 0; i < 4; i++) { idle.AddKeyFrame(i * 48, 0, 48, 48); } right = new Animation("right", true, 4, string.Empty); for (int i = 0; i < 4; i++) { right.AddKeyFrame(i * 48, 48, 48, 48); } up = new Animation("up", true, 4, string.Empty); for (int i = 0; i < 4; i++) { up.AddKeyFrame(i * 48, 96, 48, 48); } down = new Animation("down", true, 4, string.Empty); for (int i = 0; i < 4; i++) { down.AddKeyFrame(i * 48, 144, 48, 48); } done = new Animation("done", true, 1, string.Empty); done.AddKeyFrame(0, 192, 48, 48); break; } #endregion animEntity.AddAnimation(idle, right, up, down, done); Unit result; if (guid == default(Guid)) { result = new Unit(unittype, animEntity, owner, hp); } else { result = new Unit(unittype, animEntity, owner, guid, hp); } result.Animation.PlayAnimation(startingAnimation.ToString()); return(result); }
public void Set(Sprite sprite, AnimationName animationName) { animations[(int)animationName] = new SpriteAnimation(sprite, animationName); }
public void SetAnimation(AnimationName name, AnimationLayer layer, bool blocking = false) { if (DefaultClient.OptimizeForServer()) { return; } int layerId = GetLayerId(layer); if (animator.IsInTransition(layerId)) { return; } stateInfo = animator.GetCurrentAnimatorStateInfo(layerId); if (blockingId != -1) { AnimatorStateInfo blockInfo = animator.GetCurrentAnimatorStateInfo(blockingLayer); if (blockState == BlockState.PreAnimation) { if (blockInfo.fullPathHash == blockingId) { blockState = BlockState.Animation; } return; } else if (blockState == BlockState.Animation) { if (blockInfo.fullPathHash == blockingId) { return; } else { blockingId = -1; blockState = BlockState.None; } } } int triggerId = GetTriggerId(name, layer); int currentTrigger = GetCurrentTrigger(layer); if (blocking) { blockingId = triggerId; blockingLayer = layerId; blockState = BlockState.PreAnimation; } if (currentTrigger == triggerId) { if (Time.time - lastReset > 0.20 && currentTrigger != stateInfo.fullPathHash) { SetCurrentTrigger(layer, stateInfo.fullPathHash); lastReset = Time.time; } else { return; } } if (stateInfo.fullPathHash == triggerId) { return; } animator.SetTrigger(triggerId); SetCurrentTrigger(layer, triggerId); }
private void SetAnimation(AnimationName name) { animationController.SetAnimation(name); }
public void SetAnimation(AnimationName name, AnimationLayer layer, bool blocking=false) { if (DefaultClient.OptimizeForServer()) { return; } int layerId = GetLayerId(layer); if (animator.IsInTransition(layerId)) { return; } stateInfo = animator.GetCurrentAnimatorStateInfo(layerId); if (blockingId != -1) { AnimatorStateInfo blockInfo = animator.GetCurrentAnimatorStateInfo(blockingLayer); if (blockState == BlockState.PreAnimation) { if (blockInfo.fullPathHash == blockingId) { blockState = BlockState.Animation; } return; } else if (blockState == BlockState.Animation) { if (blockInfo.fullPathHash == blockingId) { return; } else { blockingId = -1; blockState = BlockState.None; } } } int triggerId = GetTriggerId(name, layer); int currentTrigger = GetCurrentTrigger(layer); if (blocking) { blockingId = triggerId; blockingLayer = layerId; blockState = BlockState.PreAnimation; } if (currentTrigger == triggerId) { if (Time.time - lastReset > 0.20 && currentTrigger != stateInfo.fullPathHash) { SetCurrentTrigger(layer, stateInfo.fullPathHash); lastReset = Time.time; } else { return; } } if (stateInfo.fullPathHash == triggerId) { return; } animator.SetTrigger(triggerId); SetCurrentTrigger(layer, triggerId); }
public virtual void Play(AnimationName iName, Action callback) { _isFinished = false; _actCallback = callback; GetComponent <Animation>().Play(iName.ToString()); }
public UISAnimation(AnimationName name) : base() { base.TokenTag = ObjectTag.AnimationProeprty; this.Name = name; }
public void PlayShipAnimation(AnimationName iName) { _animShipAnimation.Play(iName.ToString()); }
public void AddObject(MonoBehaviour mono, AnimationName animation, FunctionName function, float duration, GameObject gameObject, params object[] customData) { TweenObjects.Add(new TweenObject(mono, animation, function, duration, gameObject, customData)); }
public TweenObject(MonoBehaviour mono, AnimationName animation, FunctionName function, float duration, GameObject gameObject, params object[] customData) { Tweens = new Queue <TweenData>(); Tweens.Enqueue(new TweenData(mono, animation, function, duration, gameObject, customData)); }
public void Play(AnimationName iName, Action onFinished) { panel.widgetsAreStatic = false; base.transform.localScaleOne(); base.Play(iName, onFinished); }
public bool IsSame(DependentAnimation depAnim) { return(Asset.Equals(depAnim.Asset) && AnimationName.Equals(depAnim.AnimationName) && TransformPath.Equals(depAnim.TransformPath)); }
public SpriteAnimation Get(AnimationName animationName) { return(animations[(int)animationName]); }
protected void PlayAnimation(AnimationName name_) { if (animator != null) { animator.Play(name_.ToString()); } }
public override void Update(GameTime gameTime) { mouseInputState = CONTENT_MANAGER.inputState.mouseState; lastMouseInputState = CONTENT_MANAGER.lastInputState.mouseState; keyboardInputState = CONTENT_MANAGER.inputState.keyboardState; lastKeyboardInputState = CONTENT_MANAGER.lastInputState.keyboardState; selectedMapCell = Utility.HelperFunction.TranslateMousePosToMapCellPos(mouseInputState.Position, camera, map.Width, map.Height); if (HelperFunction.IsKeyPress(Keys.OemTilde)) { console.IsVisible = !console.IsVisible; } #region change unit and animation if (console.IsVisible) //suck all input in to the input box { console.Update(CONTENT_MANAGER.inputState, CONTENT_MANAGER.lastInputState); } else //accept input { //cylce through unit if (HelperFunction.IsKeyPress(Keys.Left)) { if (currentUnit == UnitType.Soldier) { currentUnit = UnitType.Battleship; } else { currentUnit = currentUnit.Previous(); } } if (HelperFunction.IsKeyPress(Keys.Right)) { if (currentUnit == UnitType.Battleship) { currentUnit = UnitType.Soldier; } else { currentUnit = currentUnit.Next(); } } //cycle through animation if (HelperFunction.IsKeyPress(Keys.Up)) { if (currentAnimation == AnimationName.idle) { currentAnimation = AnimationName.done; } else { currentAnimation = currentAnimation.Previous(); } } if (HelperFunction.IsKeyPress(Keys.Down)) { if (currentAnimation == AnimationName.done) { currentAnimation = AnimationName.idle; } else { currentAnimation = currentAnimation.Next(); } } //cycle through color if (HelperFunction.IsKeyPress(Keys.E)) { if (currentColor == GameData.Owner.Yellow) { currentColor = GameData.Owner.Red; } else { currentColor = currentColor.Next(); } } if (HelperFunction.IsKeyPress(Keys.Q)) { if (currentColor == GameData.Owner.Red) { currentColor = GameData.Owner.Yellow; } else { currentColor = currentColor.Previous(); } } } Unit unit = map[position].unit; UnitType nextUnit = unit.UnitType; GameData.Owner nextOwner = unit.Owner; AnimationName nextAnimation = unit.Animation.CurntAnimationName.ToEnum <AnimationName>(); bool isChanged = false; if (nextUnit != currentUnit) { isChanged = true; } if (nextOwner != currentColor) { isChanged = true; } if (nextAnimation != currentAnimation) { isChanged = true; } if (isChanged) { map[position].unit = UnitCreationHelper.Create(currentUnit, currentColor, startingAnimation: currentAnimation); } map[position].unit.Animation.Update(gameTime); #endregion if (mouseInputState.LeftButton == ButtonState.Released && lastMouseInputState.LeftButton == ButtonState.Pressed) { SelectUnit(); } //if (isMovingUnitAnimPlaying) //{ // UpdateMovingUnit(gameTime); //} //calculate movepath if (isMovePathCalculated) { if (movementRange.Contains(selectedMapCell) && selectedMapCell != lastSelectedMapCell) { //update movement path movementPath = DijkstraHelper.FindPath(dijkstarGraph, selectedMapCell); dirarrowRenderer.UpdatePath(movementPath); lastSelectedMapCell = selectedMapCell; } } base.Update(gameTime); }