protected virtual void ChangeDirection(Vector2 direction) { XDirection thisX = XDirection.right; YDirection thisY = YDirection.down; if (direction.x > 0) // Going Right { thisX = XDirection.right; } else if (direction.x < 0) // Going Left { thisX = XDirection.left; } else // Not Moving Horizontally { thisX = curXDirection; } if (direction.y > 0) // Going Up { thisY = YDirection.up; } else if (direction.y < 0) // Going Down { thisY = YDirection.down; } else // Not Moving Vertically { thisY = curYDirection; } ChangeEffectorBoxLocation(direction); ChangeDirection(thisX, thisY); }
public ZoomableArea() { this.m_HBaseRangeMin = 0f; this.m_HBaseRangeMax = 1f; this.m_VBaseRangeMin = 0f; this.m_VBaseRangeMax = 1f; this.m_HAllowExceedBaseRangeMin = true; this.m_HAllowExceedBaseRangeMax = true; this.m_VAllowExceedBaseRangeMin = true; this.m_VAllowExceedBaseRangeMax = true; this.m_HScaleMin = 1E-05f; this.m_HScaleMax = 100000f; this.m_VScaleMin = 1E-05f; this.m_VScaleMax = 100000f; this.m_ScaleWithWindow = false; this.m_HSlider = true; this.m_VSlider = true; this.m_IgnoreScrollWheelUntilClicked = false; this.m_EnableMouseInput = true; this.m_EnableSliderZoom = true; this.m_UpDirection = YDirection.Positive; this.m_DrawArea = new Rect(0f, 0f, 100f, 100f); this.m_Scale = new Vector2(1f, -1f); this.m_Translation = new Vector2(0f, 0f); this.m_LastShownAreaInsideMargins = new Rect(0f, 0f, 100f, 100f); this.m_MinimalGUI = false; }
private void DoPointingMovement() { switch (yDirection) { case YDirection.Up: yPositionDifference += Time.deltaTime * speed; break; case YDirection.Down: yPositionDifference -= Time.deltaTime * speed; break; default: throw new ArgumentOutOfRangeException(); } if (yPositionDifference >= maxYPositionDifference) { yDirection = YDirection.Down; } if (yPositionDifference <= -maxYPositionDifference) { yDirection = YDirection.Up; } if (transformToPointPosition != nullVector3) { transform.position = transformToPointPosition + new Vector3(0, GetComponent <SpriteRenderer>().size.y, 0) + transform.up * yPositionDifference; } }
public void UpdateMap(XDirection dirX, YDirection dirY) { switch (dirX) { case XDirection.None: LowerRigth.X = BatmanPosition.X; UpperLeft.X = BatmanPosition.X; break; case XDirection.Left: LowerRigth.X = BatmanPosition.X - 1; break; case XDirection.Right: UpperLeft.X = BatmanPosition.X + 1; break; } switch (dirY) { case YDirection.None: UpperLeft.Y = BatmanPosition.Y; LowerRigth.Y = BatmanPosition.Y; break; case YDirection.Up: LowerRigth.Y = BatmanPosition.Y - 1; break; case YDirection.Down: UpperLeft.Y = BatmanPosition.Y + 1; break; } }
public float?YObstructionCheck(YDirection direction, TileLocation[] vectors) { float?nullable1 = new float?(); switch (direction) { case YDirection.Up: float num1 = 0.0f; for (int index = 0; index < vectors.Length; ++index) { if (this.YCheckUp(vectors[index].Y)) { return(new float?(num1)); } } for (int index = 0; index < vectors.Length; ++index) { nullable1 = !this.tiles[vectors[index].Y - 1, vectors[index].X].Collision ? new float?() : new float?(this.tiles[vectors[index].Y - 1, vectors[index].X].BotBound); if (nullable1.HasValue) { float?nullable2 = nullable1; float num2 = num1; if (((double)nullable2.GetValueOrDefault() <= (double)num2 ? 0 : (nullable2.HasValue ? 1 : 0)) != 0) { num1 = nullable1.Value; } } } return(new float?(num1)); case YDirection.Down: float botBound = this.tiles[this.TileY, this.TileX].BotBound; for (int index = 0; index < vectors.Length; ++index) { if (this.YCheckDown(vectors[index].Y)) { return(new float?(botBound)); } } for (int index = 0; index < vectors.Length; ++index) { nullable1 = !this.tiles[vectors[index].Y + 1, vectors[index].X].Collision ? new float?() : new float?(this.tiles[vectors[index].Y + 1, vectors[index].X].TopBound); if (nullable1.HasValue) { float?nullable2 = nullable1; float num2 = botBound; if (((double)nullable2.GetValueOrDefault() >= (double)num2 ? 0 : (nullable2.HasValue ? 1 : 0)) != 0) { botBound = nullable1.Value; } } } return(new float?(botBound)); default: throw new Exception("Fool!"); } }
private void Awake() { yDirection = startingYDirection; onHurt = Harmony.Finder.OnHurt; onDodge = Harmony.Finder.OnDodge; onUnitMove = Harmony.Finder.OnUnitMove; onUnitDeath = Harmony.Finder.OnUnitDeath; if (transformToPoint != null) { transformToPointPosition = transformToPoint.position; } }
protected void GetHealthState(XDirection xDirection, YDirection yDirection) { if (this.health > 0) { return; } this.dead = true; this.position = this.map.PlayerSpawn; this.health = 100; this.Xmom = 0.0f; this.Ymom = 0.0f; }
public virtual void Update(TimeSpan gameTime) { this.prevDirections = this.currentDirections; this.GetDirections(); this.totalGameTime += (float)gameTime.TotalMilliseconds; this.xDirection = this.FindXDirection(); this.yDirection = this.FindYDirection(); this.textureDirection = this.FindTextureSDirection(); this.GetBounds(); this.GetMoveChanges(); this.xMove(); this.yMove(); this.ECC(); this.GetTileDamage(); this.GetActionState(); this.GotoState(); if (this.torsoTexture != null) { this.torsoTexture.Animate(); } if (this.legTexture != null) { this.legTexture.Animate(); } this.GetShade(); this.GetTextureChange(); if (this.attackTimer > 0) { --this.attackTimer; } if (this.stun > 0) { --this.stun; } if (this.damageCoolDown > 0) { --this.damageCoolDown; } else { this.previousAttacker = (Entity)null; } }
public Player(OcTree octree, string modelName, Vector3 position, Vector3 rotation, Vector3 scale, Vector2 maxSpeed, int maxLife, int attack) : base(octree, new AnimatedModel((GameModel)ModelManager.GetModel(modelName), position, rotation, scale, 0), maxSpeed, maxLife, attack) { _jump = false; _endJump = true; _lastPlayerState = State.Waiting; _playerState = State.Waiting; _lastPlayerAction = Action.None; _playerAction = Action.None; _lastPlayerXDirection = XDirection.Right; _playerXDirection = XDirection.Right; _lastPlayerYDirection = YDirection.None; _playerYDirection = YDirection.None; ((AnimatedModel)this.DModel).Animation.StartClip("Waiting", true); }
public TileType LocationCheck(TileLocation entityLocation, YDirection yDirection) { try { switch (yDirection) { case YDirection.Up: return(this.tiles[entityLocation.Y - 1, entityLocation.X].TileType); case YDirection.Down: return(this.tiles[entityLocation.Y + 1, entityLocation.X].TileType); default: return(TileType.Empty); } } catch (IndexOutOfRangeException ex) { return(TileType.Empty); } }
protected void GetYState(YDirection yDirection) { switch (yDirection) { case YDirection.Up: if (this.map.TileAt(this.TileBotSlight).Collision) { this.yState = Entity.YMoveStates.OnGround; break; } this.yState = Entity.YMoveStates.InAir; break; case YDirection.Down: if (this.map.TileAt(this.TileBotSlight).Collision) { this.yState = Entity.YMoveStates.OnGround; break; } this.yState = Entity.YMoveStates.InAir; break; } }
/// <summary> /// Constructor of the <c>Character</c> class. /// </summary> /// <param name="scene">Reference to the scene where the character moves.</param> /// <param name="model">Reference to the model that represents the character.</param> /// <param name="maxSpeed">Max speed of the character.</param> /// <param name="maxLife">Max life of the character.</param> /// <param name="attack">Attack of the character.</param> public Character(SceneRenderer scene, IDrawableModel model, Vector2 maxSpeed, int maxLife, int life, int attack) : base(scene, model, maxSpeed, true, true) { _visible = true; _life = life; _maxLife = maxLife; _attack = attack; _startStaircase = false; _climbStaircase = false; _finishStaircase = false; _startDownStaircase = false; _climbDownStaircase = false; _finishDownStaircase = false; _lastPlayerXDirection = XDirection.Right; _playerXDirection = XDirection.Right; _lastPlayerYDirection = YDirection.None; _playerYDirection = YDirection.None; }
/// <summary> /// Initializes a new instance of the <see cref="NormalMap"/> class. /// </summary> /// <param name="xDirection">The x direction.</param> /// <param name="yDirection">The y direction.</param> public NormalMap(XDirection xDirection, YDirection yDirection) { YDirection = yDirection; XDirection = xDirection; }
public GameEvent_MoveSingle(int commandTick, int APCost, Entity mover, XDirection x, YDirection y, FloorState currentFloor) : base(commandTick, APCost, mover) { this.X = x; this.Y = y; this.CurrentFloor = currentFloor; }
/// <summary> /// Animates the tiles using the supplied entrance mode, Y direction, Z direction and duration. /// </summary> /// <param name="mode">The entrance mode (Enter or Exit).</param> /// <param name="yDirection">The direction of the animation in the vertical axis (TopToBottom or BottomToTop)</param> /// <param name="zDirection">The direction of the animation in the depth axis (FrontToBack or BackToFront)</param> /// <param name="duration">The duration of the animation for each tile</param> private void AnimateTiles(EnterMode mode, YDirection yDirection, ZDirection zDirection, TimeSpan duration, Action callback) { // If the control has not been rendered or it's empty, cancel the animation if (this.ActualWidth <= 0 || this.ActualHeight <= 0 || this._positions == null || this._positions.Count <= 0) return; // Get the visible tiles for the current configuration // Tiles that are partially visible are also counted var visibleitems = this._positions.Where(x => x.Value.X + x.Key.ActualWidth >= 0 && x.Value.X <= this.ActualWidth && x.Value.Y + x.Key.ActualHeight >= 0 && x.Value.Y <= this.ActualHeight); // No visible tiles, do nothing if (visibleitems.Count() <= 0) return; // The Y coordinate of the lowest element is useful // when we animate from bottom to top double lowestY = visibleitems.Max(el => el.Value.Y); // Store the animations to group them in one Storyboard in the end var animations = new List<Timeline>(); foreach (var tilePosition in visibleitems) { // To make syntax lighter var tile = tilePosition.Key; var position = tilePosition.Value; var projection = tile.Projection as PlaneProjection; double rotationFrom, rotationTo, opacityTo; // Reset all children's opacity regardless of their animations if (mode == EnterMode.Exit) { tile.Opacity = 1; opacityTo = 0; rotationFrom = 0; rotationTo = zDirection == ZDirection.BackToFront ? -90 : 90; } else { tile.Opacity = 0; opacityTo = 1; rotationFrom = zDirection == ZDirection.BackToFront ? -90 : 90; rotationTo = 0; } // Used to determine begin time - depends if we're moving from bottom or from top double relativeY; if (yDirection == YDirection.BottomToTop) { // The lowest element should have relativeY == 0 relativeY = lowestY - position.Y; } else { relativeY = position.Y; } var easing = new QuadraticEase() { EasingMode = EasingMode.EaseInOut }; var rotationAnimation = new DoubleAnimation { From = rotationFrom, To = rotationTo, EasingFunction = easing }; rotationAnimation.Duration = duration; rotationAnimation.BeginTime = duration.Multiply(this.GetBeginTimeFactor(position.X, relativeY, mode)); rotationAnimation.SetTargetAndProperty(projection, PlaneProjection.RotationYProperty); var opacityAnimation = new DoubleAnimation { To = opacityTo, EasingFunction = easing }; // The opacity animation takes the last 60% of the rotation animation opacityAnimation.Duration = duration.Multiply(0.6); opacityAnimation.BeginTime = rotationAnimation.BeginTime; if (mode == EnterMode.Exit) opacityAnimation.BeginTime += duration - opacityAnimation.Duration.TimeSpan; opacityAnimation.SetTargetAndProperty(tile, UIElement.OpacityProperty); animations.Add(rotationAnimation); animations.Add(opacityAnimation); } // Begin all animations var sb = new Storyboard(); sb.Completed += (sender, args) => { if (callback != null) { callback(); } }; foreach (var a in animations) sb.Children.Add(a); sb.Begin(); }
public CommandStub_MoveSingleOrPrepareAttack(string moverEID, int x, int y) : base(moverEID) { this.X = (XDirection)x; this.Y = (YDirection)y; }
void Verticalinput() { if (currentY == YDirection.None) { if (jumpkeydown) { nextY = YDirection.Up; } if (blockkeydown) { nextY = YDirection.Down; } if(blockkeydown&&jumpkeydown){ nextY = YDirection.Special; } } if (currentY == YDirection.Up) { if(blockkeydown){ nextY = YDirection.Down; } if(jumpkeyup && !blockkey){ nextY = YDirection.None; } if(jumpkeyup && blockkey){ nextY = YDirection.Down; } } if (currentY == YDirection.Down) { if(jumpkeydown){ nextY = YDirection.Up; } if(blockkeyup && !jumpkey){ nextY = YDirection.None; } if(blockkeyup && jumpkey){ nextY = YDirection.Up; } } if (currentY == YDirection.Special) { if(jumpkeyup && !blockkeyup){ nextY = YDirection.Down; } if(jumpkeyup && !blockkeyup){ nextY = YDirection.Up; } if(jumpkeyup && blockkeyup){ nextY = YDirection.None; } } //Debug.Log ("Y:"+nextY); currentY = nextY; }
YDirection Verticalinput(YDirection y, bool ud, bool dd, bool u, bool d, bool uu, bool du) { if (y == YDirection.None) { if (ud) { return YDirection.Up; } if (dd) { return YDirection.Down; } if(dd&&ud){ return YDirection.Special; } } if (y == YDirection.Up) { if(dd){ return YDirection.Down; } if(uu && !d){ return YDirection.None; } if(uu && d){ return YDirection.Down; } } if (y == YDirection.Down) { if(ud){ return YDirection.Up; } if(du && !u){ return YDirection.None; } if(du && u){ return YDirection.Up; } } if (y == YDirection.Special) { if(uu && !du){ return YDirection.Down; } if(!uu && du){ return YDirection.Up; } if(uu && du){ return YDirection.None; } } return y; }
/// <summary> /// Animates the tiles using the supplied entrance mode, Y direction, Z direction and duration. /// </summary> /// <param name="mode">The entrance mode (Enter or Exit).</param> /// <param name="yDirection">The direction of the animation in the vertical axis (TopToBottom or BottomToTop)</param> /// <param name="zDirection">The direction of the animation in the depth axis (FrontToBack or BackToFront)</param> /// <param name="duration">The duration of the animation for each tile</param> public void AnimateTiles(EnterMode mode, YDirection yDirection, ZDirection zDirection, TimeSpan duration) { // If the control has not been rendered, cancel the animation if (ActualWidth <= 0 || ActualHeight <= 0) { return; } // If the control it's empty, after position calculation is ran, cancel the animation CalculateElementPositions(); if (_positions == null || _positions.Count <= 0) { return; } // Calculates start and end heights double startHeight = 0; double endHeight = ActualHeight; startHeight = 0; endHeight = _scrollViewer.ViewportHeight; // Get the visible tiles for the current configuration // Tiles that are partially visible are also counted var visibleTiles = _positions.Where(x => x.Value.Y + x.Key.ActualHeight >= startHeight && x.Value.Y <= startHeight + endHeight); // No visible tiles, do nothing var visibleCount = visibleTiles.Count(); if (visibleCount <= 0) { return; } // The Y coordinate of the lowest element is useful // when we animate from bottom to top double lowestY = visibleTiles.Max(el => el.Value.Y); // Store the animations to group them in one Storyboard in the end var animations = new List<Timeline>(); var lastAnimations = new List<Timeline>(); foreach (var tilePosition in visibleTiles) { var currentTileAnimationDuration = duration; bool isTileSelected = tilePosition.Key.DataContext == SelectedItem; if (isTileSelected) { currentTileAnimationDuration = currentTileAnimationDuration.Multiply(0.8d); } var tile = tilePosition.Key; var position = tilePosition.Value; var projection = tile.Projection as PlaneProjection; double rotationFrom, rotationTo, opacityTo; // Reset all children's opacity regardless of their animations if (mode == EnterMode.Exit) { tile.Opacity = 1; opacityTo = 0; rotationFrom = 0; rotationTo = zDirection == ZDirection.BackToFront ? -90 : 90; } else { tile.Opacity = 0; opacityTo = 1; rotationFrom = zDirection == ZDirection.BackToFront ? -90 : 90; rotationTo = 0; } // Used to determine begin time - depends if we're moving from bottom or from top double relativeY; if (yDirection == YDirection.BottomToTop) { // The lowest element should have relativeY == 0 relativeY = lowestY - position.Y; } else { relativeY = position.Y; } var easing = new QuadraticEase() { EasingMode = EasingMode.EaseInOut }; var rotationAnimation = new DoubleAnimation { From = rotationFrom, To = rotationTo, EasingFunction = easing }; rotationAnimation.Duration = currentTileAnimationDuration; if (isTileSelected) { //animate tile as it's lower than all others (so it will be later even it's last in the list) rotationAnimation.BeginTime = currentTileAnimationDuration.Multiply(GetBeginTimeFactor(position.X, lowestY * 1.2d, mode)); } else { rotationAnimation.BeginTime = currentTileAnimationDuration.Multiply(GetBeginTimeFactor(position.X, relativeY, mode)); } rotationAnimation.SetTargetAndProperty(projection, PlaneProjection.RotationYProperty); var opacityAnimation = new DoubleAnimation { To = opacityTo, EasingFunction = easing }; // The opacity animation takes the last 60% of the rotation animation opacityAnimation.Duration = currentTileAnimationDuration.Multiply(0.6); opacityAnimation.BeginTime = rotationAnimation.BeginTime; if (mode == EnterMode.Exit) opacityAnimation.BeginTime += currentTileAnimationDuration - opacityAnimation.Duration.TimeSpan; opacityAnimation.SetTargetAndProperty(tile, UIElement.OpacityProperty); animations.Add(rotationAnimation); animations.Add(opacityAnimation); } animations.AddRange(lastAnimations); // Begin all animations var sb = new Storyboard(); foreach (var a in animations) { sb.Children.Add(a); } sb.SpeedRatio = SpeedRatio; sb.Completed += sb_Completed; sb.Begin(); }
/// <summary> /// Animates the tiles using the supplied entrance mode, Y direction and Z direction, with a duration /// of 600 milliseconds per tile. /// </summary> /// <param name="mode">The entrance mode (Enter or Exit).</param> /// <param name="yDirection">The direction of the animation in the vertical axis (TopToBottom or BottomToTop)</param> /// <param name="zDirection">The direction of the animation in the depth axis (FrontToBack or BackToFront)</param> public void AnimateTiles(EnterMode mode, YDirection yDirection, ZDirection zDirection) { AnimateTiles(mode, yDirection, zDirection, TimeSpan.FromMilliseconds(600)); }
protected virtual void ChangeDirection(XDirection x, YDirection y) { curXDirection = x; curYDirection = y; rend.sprite = GetSpriteWithKey(y + "_" + x); }
/// <summary> /// Animates the tiles using the supplied entrance mode, Y direction and Z direction, with a duration /// of 600 milliseconds per tile. /// </summary> /// <param name="mode">The entrance mode (Enter or Exit).</param> /// <param name="yDirection">The direction of the animation in the vertical axis (TopToBottom or BottomToTop)</param> /// <param name="zDirection">The direction of the animation in the depth axis (FrontToBack or BackToFront)</param> public void AnimateTiles(EnterMode mode, YDirection yDirection, ZDirection zDirection, Action callback, int time = SpeedAnimation) { this.AnimateTiles(mode, yDirection, zDirection, TimeSpan.FromMilliseconds(time), callback); }