protected override void UpdateSprite() { if (_animation == null) { _animation = Animation as IDirectionalAnimation; if (_animation == null) { return; } } _lastOrientation = _billboard.Orientation; var facing = _billboard.Orientation; if (_billboard.Facing.RequiresFlipping()) { facing = _billboard.Orientation.GetFlippedSide(); Renderer.Flip(_billboard.Orientation.IsFlipped()); } var animFacing = _animation.GetFacing(facing); if (animFacing == null || Animator.FrameIndex >= animFacing.FrameIndices.Length) { return; } var idx = animFacing.FrameIndices[Animator.FrameIndex]; Renderer.SetSprite(_animation.GetSprite(idx), _animation.NormalMap, _animation.EmissiveMap, _animation.GetSpriteCollider(idx)); }
private void setAnimation(IDirectionalAnimation animation) { if (animation != null) { _faceDirection.CurrentDirectionalAnimation = animation; _faceDirection.FaceDirection(_faceDirection.Direction); } }
private async Task setAnimation(IDirectionalAnimation animation) { if (animation != null) { _faceDirection.CurrentDirectionalAnimation = animation; await _faceDirection.FaceDirectionAsync(_faceDirection.Direction); } }
public override void Dispose() { base.Dispose(); _setup = false; _animation = null; _directionalAnimation = null; _animNode.Animation.ReleaseAsset(); }
protected override void SetAnimation(SpriteAnimation animation) { _animation = animation as IDirectionalAnimation; if (_animation == null) { Debug.Log(Animation != null ? Animation.name : "Null animation"); } base.SetAnimation(animation); }
public async Task FaceDirectionAsync(Direction direction) { Direction = direction; IDirectionalAnimation animation = CurrentDirectionalAnimation; if (animation == null) { return; } switch (direction) { case Direction.Down: await faceDirectionAsync(Direction.Down, Direction.Up, Direction.Left, Direction.Right); return; case Direction.Up: await faceDirectionAsync(Direction.Up, Direction.Down, Direction.Left, Direction.Right); return; case Direction.Left: await faceDirectionAsync(Direction.Left, Direction.Down, Direction.Up, Direction.Right); return; case Direction.Right: await faceDirectionAsync(Direction.Right, Direction.Down, Direction.Up, Direction.Left); return; case Direction.DownRight: await faceDirectionAsync(Direction.DownRight, Direction.Right, Direction.Down, Direction.Up, Direction.Left); return; case Direction.DownLeft: await faceDirectionAsync(Direction.DownLeft, Direction.Left, Direction.Down, Direction.Up, Direction.Right); return; case Direction.UpRight: await faceDirectionAsync(Direction.UpRight, Direction.Right, Direction.Up, Direction.Down, Direction.Left); return; case Direction.UpLeft: await faceDirectionAsync(Direction.UpLeft, Direction.Left, Direction.Up, Direction.Down, Direction.Right); return; default: throw new NotSupportedException("Direction is not supported: " + direction.ToString()); } }
protected virtual void SetAnimation(SpriteAnimation animation) { _animation = animation; _directionalAnimation = animation as DirectionalAnimation; if (_directionalAnimation != null) { _billboard = Graph.Entity.Get <SpriteBillboardComponent>(); } SetupAnimation(); }
public void Assign(IDirectionalAnimation animation, params int[] frames) { Assign(animation.Down, frames); Assign(animation.Left, frames); Assign(animation.Right, frames); Assign(animation.Up, frames); Assign(animation.DownLeft, frames); Assign(animation.DownRight, frames); Assign(animation.UpLeft, frames); Assign(animation.UpRight, frames); }
private async Task setDirection(float xSource, float ySource, float xDest, float yDest) { float angle = getAngle(xSource, ySource, xDest, yDest); IDirectionalAnimation animation = CurrentDirectionalAnimation; if (animation == null) { return; } if (angle < -30 && angle > -60 && animation.DownRight != null) { Direction = Direction.DownRight; await changeAnimationIfNeeded(animation.DownRight); } else if (angle < -120 && angle > -150 && animation.DownLeft != null) { Direction = Direction.DownLeft; await changeAnimationIfNeeded(animation.DownLeft); } else if (angle > 120 && angle < 150 && animation.UpLeft != null) { Direction = Direction.UpLeft; await changeAnimationIfNeeded(animation.UpLeft); } else if (angle > 30 && angle < 60 && animation.UpRight != null) { Direction = Direction.UpRight; await changeAnimationIfNeeded(animation.UpRight); } else if (angle < -65 && angle > -115 && animation.Down != null) { Direction = Direction.Down; await changeAnimationIfNeeded(animation.Down); } else if (angle > 65 && angle < 115 && animation.Up != null) { Direction = Direction.Up; await changeAnimationIfNeeded(animation.Up); } else if (xDest > xSource && animation.Right != null) { Direction = Direction.Right; await changeAnimationIfNeeded(animation.Right); } else if (animation.Left != null) { Direction = Direction.Left; await changeAnimationIfNeeded(animation.Left); } }
private async Task faceDirectionAsync(params Direction[] directions) { IDirectionalAnimation dirAnimation = CurrentDirectionalAnimation; if (dirAnimation == null) { return; } foreach (Direction dir in directions) { var animation = dirAnimation.GetAnimation(dir); if (await animateAsync(animation)) { return; } } }
private async Task faceDirectionAsync(params Direction[] directions) { IDirectionalAnimation animation = CurrentDirectionalAnimation; if (animation == null) { return; } foreach (Direction dir in directions) { switch (dir) { case Direction.Down: if (await animateAsync(animation.Down)) { return; } break; case Direction.Up: if (await animateAsync(animation.Up)) { return; } break; case Direction.Left: if (await animateAsync(animation.Left)) { return; } break; case Direction.Right: if (await animateAsync(animation.Right)) { return; } break; case Direction.DownLeft: if (await animateAsync(animation.DownLeft)) { return; } break; case Direction.DownRight: if (await animateAsync(animation.DownRight)) { return; } break; case Direction.UpLeft: if (await animateAsync(animation.UpLeft)) { return; } break; case Direction.UpRight: if (await animateAsync(animation.UpRight)) { return; } break; } } }
public override void Dispose() { base.Dispose(); _animation = null; }
private Contract <IDirectionalAnimation> fromItem(AGSSerializationContext context, IDirectionalAnimation animation) { Contract <IDirectionalAnimation> item = new Contract <IDirectionalAnimation> (); item.FromItem(context, animation); return(item); }