public CharacterOriginAnimation(int charIndex, int animIndex, RenderTime animTime, int loops) { AnimationIndex = animIndex; FrameLength = animTime; TotalLoops = loops; CharIndex = charIndex; }
public NormalMoveAnimation(Loc2D tileLoc, int animIndex, RenderTime animTime, int loops) { AnimationIndex = animIndex; FrameLength = animTime; TotalLoops = loops; StartLoc = new Loc2D(tileLoc.X, tileLoc.Y); }
public OverlayMoveAnimation(int animIndex, RenderTime animTime, int loops, byte transparency) { AnimationIndex = animIndex; FrameLength = animTime; TotalLoops = loops; Alpha = (byte)(255 - transparency); }
public BeamMoveAnimation(Loc2D startLoc, int animIndex, RenderTime animTime, Maps.Direction8 dir, int distance, RenderTime lastingTime) { StartLoc = startLoc; AnimationIndex = animIndex; FrameLength = animTime; Direction = dir; TotalDistance = distance; LastingTime = lastingTime; }
public TileAnim(TileAnim oldTileAnim) { Frames = new List<TileTexture>(); for (int i = 0; i < oldTileAnim.Frames.Count; i++) { Frames.Add(oldTileAnim.Frames[i]); } FrameLength = oldTileAnim.FrameLength; }
public ArrowMoveAnimation(Loc2D startLoc, int animIndex, RenderTime animTime, Maps.Direction8 dir, int distance, int speed) { StartLoc = startLoc; AnimationIndex = animIndex; FrameLength = animTime; Direction = dir; TotalWaves = distance; TotalDistance = distance*TextureManager.TILE_SIZE; TravelSpeed = speed; }
public ItemThrowMoveAnimation(Loc2D startLoc, Loc2D endLoc, int animIndex, RenderTime animTime, int speed, bool dropDown) { StartLoc = startLoc; EndLoc = endLoc; AnimationIndex = animIndex; FrameLength = animTime; Loc2D diffLoc = startLoc-endLoc; TotalDistance = (int)(TextureManager.TILE_SIZE*Math.Sqrt(Math.Pow(diffLoc.X,2) + Math.Pow(diffLoc.Y,2))); TravelSpeed = speed; DropDown = dropDown; }
public FountainEmitter(Loc2D startLoc, int animIndex, int grainsPerBurst, RenderTime burstTime, int bursts, RenderTime animTime, int startDistance, int speed, RenderTime totalTime) { StartLoc = startLoc; AnimationIndex = animIndex; FrameLength = animTime; TotalTime = totalTime; GrainsPerBurst = grainsPerBurst; BurstTime = burstTime; TotalBursts = bursts; StartDistance = startDistance; Speed = speed; }
//float scale; //float scaleSpeed; //float rotation; //float rotationSpeed; public ParticleAnimation(int animationIndex, RenderTime frameLength, Loc2D newPosition, Loc2D newSpeed, Loc2D newAcceleration, Color4 newAlpha, Color4 newAlphaSpeed, RenderTime newMaxTime) { AnimationIndex = animationIndex; FrameLength = frameLength; MapLoc = newPosition; StartLoc = MapLoc; Speed = newSpeed; StartSpeed = Speed; Acceleration = newAcceleration; Color = newAlpha; ColorChange = newAlphaSpeed; TotalTime = newMaxTime; }
/// <summary> /// Called when it is time to setup the next frame. Add you game logic here. /// </summary> /// <param name="e">Contains timing information for framerate independent logic.</param> protected override void OnUpdateFrame(FrameEventArgs e) { base.OnUpdateFrame(e); if (Editors.MainPanel.GameNeedWait) { Editors.MainPanel.GameWaiting = true; while (Editors.MainPanel.GameNeedWait) Thread.Sleep(100); Editors.MainPanel.GameWaiting = false; } if (GameLoaded == GameLoadState.Closing) Close(); else if (GameLoaded == GameLoadState.PostLoading) GameLoaded = GameLoadState.Finalizing; else if (GameLoaded == GameLoadState.Finalizing) { Graphics.TextureManager.PostInit(); Logic.Gameplay.MenuManager.Init(); Logic.Gameplay.Processor.Init(); Logic.Display.Screen.Init(); Logic.Gameplay.Processor.Restart(); Logic.Display.Screen.ProcessTaskQueue(true); GameLoaded = GameLoadState.Loaded; while (!Editors.MainPanel.EditorLoaded) { Thread.Sleep(100); } } else if (GameLoaded == GameLoadState.Loaded) { try { Graphics.TextureManager.Update(); RenderTime elapsedTime = new RenderTime((int)(e.Time * Graphics.TextureManager.FPS_CAP * 1000)); //set this frame's input Logic.Gameplay.Input input = new Logic.Gameplay.Input(Keyboard, Mouse); Logic.Gameplay.Processor.SetFrameInput(input, elapsedTime, (int)Math.Round(UpdateFrequency)); Logic.Display.Screen.Process(elapsedTime); errorCount--; } catch (Exception ex) { Logs.Logger.LogError(ex); errorCount += 2; } } }
public void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; RenderTime totalTime = ITEM_ACTION_TIME[(int)Action]; if (ActionTime >= totalTime && Action != ItemAnimType.None) { ActionDone = true; } else { switch (Action) { case ItemAnimType.None: { MapHeight = 0; MapLoc = StartLoc; break; } case ItemAnimType.Drop: { MapHeight = DrawHelper.GetArc(TextureManager.TILE_SIZE / 4, totalTime.Ticks, ActionTime.Ticks); MapHeight += TextureManager.TILE_SIZE * (totalTime - ActionTime).Ticks / 2 / totalTime.Ticks; Loc2D mapDiff = (EndLoc - StartLoc) * TextureManager.TILE_SIZE; mapDiff = new Loc2D(mapDiff.X * ActionTime.Ticks / totalTime.Ticks, mapDiff.Y * ActionTime.Ticks / totalTime.Ticks); MapLoc = mapDiff + StartLoc * TextureManager.TILE_SIZE; } break; case ItemAnimType.Bounce: { MapHeight = DrawHelper.GetArc(TextureManager.TILE_SIZE / 2, totalTime.Ticks, ActionTime.Ticks); Loc2D mapDiff = (EndLoc - StartLoc) * TextureManager.TILE_SIZE; mapDiff = new Loc2D(mapDiff.X * ActionTime.Ticks / totalTime.Ticks, mapDiff.Y * ActionTime.Ticks / totalTime.Ticks); MapLoc = mapDiff + StartLoc * TextureManager.TILE_SIZE; } break; case ItemAnimType.Deflect: { MapHeight = DrawHelper.GetArc(TextureManager.TILE_SIZE / 2, totalTime.Ticks, ActionTime.Ticks); MapHeight += TextureManager.TILE_SIZE * (totalTime.Ticks - ActionTime.Ticks) / 2 / totalTime.Ticks; Loc2D mapDiff = (EndLoc - StartLoc) * TextureManager.TILE_SIZE; mapDiff = new Loc2D(mapDiff.X * ActionTime.Ticks / totalTime.Ticks, mapDiff.Y * ActionTime.Ticks / totalTime.Ticks); MapLoc = mapDiff + StartLoc * TextureManager.TILE_SIZE; } break; } } }
public virtual void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; FrameTime += elapsedTime; if (FrameTime >= FrameLength) { FrameTime = FrameTime - FrameLength; Frame++; } if (Frame >= TextureManager.GetSpellSheet(TextureManager.SpellAnimType.Spell, AnimationIndex).TotalFrames) { Loops++; Frame = 0; } if (Loops >= TotalLoops) { ActionDone = true; } }
public virtual void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; FrameTime += elapsedTime; if (FrameTime >= FrameLength) { FrameTime = FrameTime - FrameLength; Frame++; } if (Frame >= TextureManager.GetItemSheet(AnimationIndex).TotalFrames) { Frame = 0; } Distance = ActionTime.ToMillisecs() * TravelSpeed; if (Distance >= TotalDistance) { ActionDone = true; } else { MapHeight = DrawHelper.GetArc(TotalDistance, TotalDistance, Distance); if (DropDown) { MapHeight += TextureManager.TILE_SIZE * (TotalDistance - Distance) / TotalDistance / 2; } else { MapHeight += TextureManager.TILE_SIZE / 2; } Loc2D mapDiff = (EndLoc - StartLoc) * TextureManager.TILE_SIZE; mapDiff = new Loc2D(mapDiff.X * Distance / TotalDistance, mapDiff.Y * Distance / TotalDistance); MapLoc = mapDiff + StartLoc * TextureManager.TILE_SIZE; } }
public Wait(RenderTime time) { this.time = time; }
public void ProcessDelay(RenderTime time) { foreach (KeyValuePair<int, ResultBranch> entry in branches) { entry.Value.Delay -= time; if (entry.Value.Delay < RenderTime.Zero) entry.Value.Delay = RenderTime.Zero; } }
public virtual void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; FrameTime += elapsedTime; if (FrameTime >= FrameLength) { FrameTime = FrameTime - FrameLength; Frame++; } if (Frame >= TextureManager.GetSpellSheet(TextureManager.SpellAnimType.Spell, AnimationIndex).TotalFrames) { Frame = 0; } MapLoc = StartLoc + Speed * ActionTime.ToMillisecs() / 1000; Speed = StartSpeed + Acceleration * ActionTime.ToMillisecs() / 1000; if (ActionTime >= TotalTime) { ActionDone = true; } }
public static void Process(RenderTime elapsedTime) { if (DebugSpeed == GameSpeed.Pause) { return; } else if (DebugSpeed == GameSpeed.Instant) { ForceReady(); ProcessActions(elapsedTime); } else { int speedFactor = 1000; speedFactor = (int)(speedFactor * Math.Pow(2, (int)DebugSpeed)); RenderTime newElapsed = elapsedTime * speedFactor / 1000; ProcessActions(newElapsed); } //if actions are ready for queue, get a new result ProcessTaskQueue(true); //update actions at 0 time ProcessActions(new RenderTime()); }
public static void SetFrameInput(Input input, RenderTime elapsedTime, int ups) { if (input == CurrentInput) { InputTime += elapsedTime; } else { InputTime = RenderTime.FromMillisecs(0); } PrevInput = CurrentInput; CurrentInput = input; Display.Screen.UpdatesPerSecond = ups; ProcessMeta(); }
public void Process(RenderTime elapsedTime) { if (Dead) return; if (CurrentAction == ActionType.Idle) { if (MovementSpeed < 0) { elapsedTime /= 2; } else if (MovementSpeed > 0) { elapsedTime *= 2; } } ActionTime += elapsedTime; RenderTime totalActionTime = GetActionTime(CharData, CharDir, CurrentAction); RenderTime totalPassTime = GetPassTime(CharData, CharDir, CurrentAction); if (ActionTime >= totalPassTime) ActionDone = true; if (ActionTime >= totalActionTime) { if (ActionLoop) { ActionTime = ActionTime % totalActionTime; } else { switch (CurrentAction) { case ActionType.None: { ActionTime = RenderTime.Zero; CurrentAction = ActionType.Idle; } break; case ActionType.Idle: { if (totalActionTime > RenderTime.Zero) ActionTime = ActionTime % totalActionTime; else ActionTime = RenderTime.Zero; } break; default: { ActionTime = RenderTime.Zero; CurrentAction = ActionType.None; } break; } } } CharFrameType = FrameType.Idle; CharFrame = 0; TileOffset = new Loc2D(); drawOffset = new Loc2D(); opacity = 255; MapHeight = 0; if (CurrentAction == ActionType.Idle) { CharFrameType = FrameType.Idle; int totalFrames = TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(CharFrameType, CharDir); if (totalFrames > 0) CharFrame = (ActionTime.Ticks / IDLE_FRAME_LENGTH.Ticks) % totalFrames; TileOffset = new Loc2D(); MapHeight = 0; } else if (CurrentAction == ActionType.Walk) { CharFrameType = FrameType.Walk; int totalFrames = TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(CharFrameType, CharDir); if (totalFrames > 0) CharFrame = ((ActionTime + PrevActionTime).Ticks / WALK_FRAME_LENGTH.Ticks) % totalFrames; if (!MoveInPlace) { if (ActionTime.Ticks <= totalPassTime.Ticks) Operations.MoveInDirection8(ref TileOffset, CharDir, ActionTime.Ticks * Graphics.TextureManager.TILE_SIZE / totalPassTime.Ticks); } } else if (CurrentAction == ActionType.Attack) { CharFrameType = FrameType.Attack; int totalFrames = TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(CharFrameType, CharDir); if (totalFrames > 0) CharFrame = (ActionTime.Ticks * totalFrames / totalActionTime.Ticks); if (!MoveInPlace) { int pullback_distance = Graphics.TextureManager.TILE_SIZE / 8; int farthest_distance = Graphics.TextureManager.TILE_SIZE * 3 / 4; int hold_point = totalActionTime.Ticks / 8; int rush_point = totalActionTime.Ticks * 2 / 8; int hit_point = totalActionTime.Ticks * 4 / 8; int return_point = totalActionTime.Ticks * 6 / 8; if (ActionTime.Ticks <= hold_point) Operations.MoveInDirection8(ref drawOffset, CharDir, -ActionTime.Ticks * pullback_distance / rush_point); else if (ActionTime.Ticks <= rush_point) Operations.MoveInDirection8(ref drawOffset, CharDir, -pullback_distance); else if (ActionTime.Ticks <= hit_point) Operations.MoveInDirection8(ref drawOffset, CharDir, (ActionTime.Ticks - rush_point) * (farthest_distance + pullback_distance) / (hit_point - rush_point) - pullback_distance); else if (ActionTime.Ticks <= return_point) Operations.MoveInDirection8(ref drawOffset, CharDir, farthest_distance); else Operations.MoveInDirection8(ref drawOffset, CharDir, ((totalActionTime.Ticks - hit_point) - (ActionTime.Ticks - hit_point)) * farthest_distance / (totalActionTime.Ticks - hit_point)); } } else if (CurrentAction == ActionType.AttackArm) { CharFrameType = FrameType.AttackArm; int totalFrames = TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(CharFrameType, CharDir); if (totalFrames > 0) CharFrame = (ActionTime.Ticks * totalFrames / totalActionTime.Ticks); if (!MoveInPlace) { int pullback_distance = Graphics.TextureManager.TILE_SIZE / 8; int farthest_distance = Graphics.TextureManager.TILE_SIZE * 3 / 4; int hold_point = totalActionTime.Ticks / 8; int rush_point = totalActionTime.Ticks * 2 / 8; int hit_point = totalActionTime.Ticks * 4 / 8; int return_point = totalActionTime.Ticks * 6 / 8; if (ActionTime.Ticks <= hold_point) Operations.MoveInDirection8(ref drawOffset, CharDir, -ActionTime.Ticks * pullback_distance / rush_point); else if (ActionTime.Ticks <= rush_point) Operations.MoveInDirection8(ref drawOffset, CharDir, -pullback_distance); else if (ActionTime.Ticks <= hit_point) Operations.MoveInDirection8(ref drawOffset, CharDir, (ActionTime.Ticks - rush_point) * (farthest_distance + pullback_distance) / (hit_point - rush_point) - pullback_distance); else if (ActionTime.Ticks <= return_point) Operations.MoveInDirection8(ref drawOffset, CharDir, farthest_distance); else Operations.MoveInDirection8(ref drawOffset, CharDir, ((totalActionTime.Ticks - hit_point) - (ActionTime.Ticks - hit_point)) * farthest_distance / (totalActionTime.Ticks - hit_point)); } } else if (CurrentAction == ActionType.AltAttack) { CharFrameType = FrameType.AltAttack; int totalFrames = TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(CharFrameType, CharDir); CharFrame = (ActionTime.Ticks * totalFrames / totalActionTime.Ticks); if (!MoveInPlace) { int pullback_distance = Graphics.TextureManager.TILE_SIZE / 8; int farthest_distance = Graphics.TextureManager.TILE_SIZE * 3 / 4; int hold_point = totalActionTime.Ticks / 8; int rush_point = totalActionTime.Ticks * 2 / 8; int hit_point = totalActionTime.Ticks * 4 / 8; int return_point = totalActionTime.Ticks * 6 / 8; if (ActionTime.Ticks <= hold_point) Operations.MoveInDirection8(ref drawOffset, CharDir, -ActionTime.Ticks * pullback_distance / rush_point); else if (ActionTime.Ticks <= rush_point) Operations.MoveInDirection8(ref drawOffset, CharDir, -pullback_distance); else if (ActionTime.Ticks <= hit_point) Operations.MoveInDirection8(ref drawOffset, CharDir, (ActionTime.Ticks - rush_point) * (farthest_distance + pullback_distance) / (hit_point - rush_point) - pullback_distance); else if (ActionTime.Ticks <= return_point) Operations.MoveInDirection8(ref drawOffset, CharDir, farthest_distance); else Operations.MoveInDirection8(ref drawOffset, CharDir, ((totalActionTime.Ticks - hit_point) - (ActionTime.Ticks - hit_point)) * farthest_distance / (totalActionTime.Ticks - hit_point)); } } else if (CurrentAction == ActionType.SpAttack) { CharFrameType = FrameType.SpAttack; int totalFrames = TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(CharFrameType, CharDir); CharFrame = (ActionTime.Ticks * totalFrames / totalActionTime.Ticks); } else if (CurrentAction == ActionType.SpAttackShoot) { CharFrameType = FrameType.SpAttackShoot; int totalFrames = TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(CharFrameType, CharDir); CharFrame = (ActionTime.Ticks * totalFrames / totalActionTime.Ticks); if (!MoveInPlace) { int pullback_distance = Graphics.TextureManager.TILE_SIZE / 8; int farthest_distance = Graphics.TextureManager.TILE_SIZE / 8; int hold_point = totalActionTime.Ticks / 8; int rush_point = totalActionTime.Ticks * 3 / 8; int hit_point = totalActionTime.Ticks * 4 / 8; int return_point = totalActionTime.Ticks * 7 / 8; if (ActionTime.Ticks <= hold_point) Operations.MoveInDirection8(ref drawOffset, CharDir, -ActionTime.Ticks * pullback_distance / rush_point); else if (ActionTime.Ticks <= rush_point) Operations.MoveInDirection8(ref drawOffset, CharDir, -pullback_distance); else if (ActionTime.Ticks <= hit_point) Operations.MoveInDirection8(ref drawOffset, CharDir, (ActionTime.Ticks - rush_point) * (farthest_distance + pullback_distance) / (hit_point - rush_point) - pullback_distance); else if (ActionTime.Ticks <= return_point) Operations.MoveInDirection8(ref drawOffset, CharDir, farthest_distance); else Operations.MoveInDirection8(ref drawOffset, CharDir, ((totalActionTime.Ticks - hit_point) - (ActionTime.Ticks - hit_point)) * farthest_distance / (totalActionTime.Ticks - hit_point)); } } else if (CurrentAction == ActionType.SpAttackCharge) { CharFrameType = FrameType.SpAttackCharge; int totalFrames = TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(CharFrameType, CharDir); if (totalFrames > 0) CharFrame = totalFrames - 1; if (!MoveInPlace) { if (ActionTime.Ticks / 40 % 2 == 0) Operations.MoveInDirection8(ref drawOffset, Operations.AddDir(CharDir, Direction8.Left), 1); } } else if (CurrentAction == ActionType.Sleeping) { CharFrameType = FrameType.Sleep; int frameCount = TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(CharFrameType, Direction8.Down); CharFrame = (ActionTime.Ticks * frameCount / totalActionTime.Ticks); } else if (CurrentAction == ActionType.Hurt) { CharFrameType = FrameType.Hurt; CharFrame = 0; if (!MoveInPlace) { if ((ActionTime.Ticks * 3 / totalActionTime.Ticks) % 2 == 0) Operations.MoveInDirection8(ref drawOffset, Operations.ReverseDir(CharDir), 1); } } else if (CurrentAction == ActionType.Defeated) { CharFrameType = FrameType.Hurt; CharFrame = 0; if ((ActionTime.Ticks * 6 / totalActionTime.Ticks) % 2 == 0) Operations.MoveInDirection8(ref drawOffset, Operations.ReverseDir(CharDir), 1); if ((ActionTime.Ticks * 2 / totalActionTime.Ticks) > 0) opacity = 128; } //else if (CurrentAction == ActionType.Jump) //{ // CharFrame = (ActionTime * TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(FrameType.AltAttack, CharDir) / FrameLength); // if (ActionData1 > 1 || ActionData1 == 0) // { // Operations.MoveInDirection8(ref tileOffset, CharDir, ActionTime * ActionData1 * Graphics.TextureManager.TILE_SIZE / FrameLength); // } // else // { // int moveDist = ActionTime * 2 * Graphics.TextureManager.TILE_SIZE / FrameLength; // if (moveDist > Graphics.TextureManager.TILE_SIZE) moveDist = Graphics.TextureManager.TILE_SIZE; // Operations.MoveInDirection8(ref tileOffset, CharDir, moveDist); // } //} //else if (CurrentAction == ActionType.JumpHit) //{ // int phaseTotal = (FrameLength / 2); // int phaseTime = ActionTime % phaseTotal; // if (ActionTime < FrameLength / 2) // { // CharFrame = (phaseTime * TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(FrameType.AltAttack, CharDir) / phaseTotal); // if (ActionData1 > 1 || ActionData1 == 0) // { // Operations.MoveInDirection8(ref drawOffset, CharDir, phaseTime * ActionData1 * Graphics.TextureManager.TILE_SIZE / phaseTotal); // } // else // { // int moveDist = phaseTime * 2 * Graphics.TextureManager.TILE_SIZE / phaseTotal; // if (moveDist > Graphics.TextureManager.TILE_SIZE) moveDist = Graphics.TextureManager.TILE_SIZE; // Operations.MoveInDirection8(ref drawOffset, CharDir, moveDist); // } // MapHeight = phaseTime * Graphics.TextureManager.TILE_SIZE / phaseTotal; // } // else // { // CharFrame = (phaseTime * TextureManager.GetSpriteSheet(CharData.Species, CharData.Form, CharData.Shiny, CharData.Gender).FrameData.GetFrameCount(FrameType.AltAttack, CharDir) / phaseTotal); // Operations.MoveInDirection8(ref drawOffset, CharDir, ActionData1 * Graphics.TextureManager.TILE_SIZE - phaseTime * ActionData1 * Graphics.TextureManager.TILE_SIZE / phaseTotal); // MapHeight = (phaseTotal - phaseTime) * Graphics.TextureManager.TILE_SIZE / phaseTotal; // } //} else if (CurrentAction == ActionType.Deflect) { CharFrameType = FrameType.Hurt; CharFrame = 0; TileOffset = new Loc2D(); Operations.MoveInDirection8(ref TileOffset, CharDir, ActionTime.Ticks * Graphics.TextureManager.TILE_SIZE / totalActionTime.Ticks); MapHeight = DrawHelper.GetArc(TextureManager.TILE_SIZE / 2, totalActionTime.Ticks, ActionTime.Ticks); } else if (CurrentAction == ActionType.Knockback) { CharFrameType = FrameType.Hurt; CharFrame = 0; TileOffset = new Loc2D(); Operations.MoveInDirection8(ref TileOffset, Operations.ReverseDir(CharDir), ActionTime.Ticks * Graphics.TextureManager.TILE_SIZE / totalActionTime.Ticks); MapHeight = 0; } else { CharFrameType = FrameType.Idle; CharFrame = 0; TileOffset = new Loc2D(); MapHeight = 0; } }
public TileAnim() { Frames = new List<TileTexture>(); FrameLength = RenderTime.FromMillisecs(1); }
public void Load(BinaryReader reader) { FrameLength = RenderTime.FromMillisecs(reader.ReadInt32()); int frameCount = reader.ReadInt32(); for (int j = 0; j < frameCount; j++) { TileTexture layer = new TileTexture(); layer.Texture.X = reader.ReadInt32(); layer.Texture.Y = reader.ReadInt32(); layer.Sheet = reader.ReadInt32(); Frames.Add(layer); } }
public void Load(XmlReader reader) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "AnimType": { AnimType = reader.ReadString().ToEnum<Logic.Display.MoveAnimationType>(); break; } case "AnimIndex": { AnimIndex = reader.ReadString().ToInt(); break; } case "FrameLength": { FrameLength = RenderTime.FromMillisecs(reader.ReadString().ToInt()); break; } case "Anim1": { Anim1 = reader.ReadString().ToInt(); break; } case "Anim2": { Anim2 = reader.ReadString().ToInt(); break; } case "Anim3": { Anim3 = reader.ReadString().ToInt(); break; } } } } }
public TileAnim(Loc2D texture, int sheet) { Frames = new List<TileTexture>(); Frames.Add(new TileTexture(texture, sheet)); FrameLength = RenderTime.FromMillisecs(1); }
public virtual void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; FrameTime += elapsedTime; if (FrameTime >= FrameLength) { FrameTime = FrameTime - FrameLength; Frame++; } if (Frame >= TextureManager.GetSpellSheet(TextureManager.SpellAnimType.Arrow, AnimationIndex).TotalFrames) { Frame = 0; } Distance = ActionTime.ToMillisecs() * TravelSpeed / 1000; if (Distance >= TotalDistance) { ActionDone = true; } else { Loc2D mapLoc = new Loc2D(StartLoc.X * TextureManager.TILE_SIZE, StartLoc.Y * TextureManager.TILE_SIZE); Operations.MoveInDirection8(ref mapLoc, Direction, Distance); MapLoc = mapLoc; } }
public virtual void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; CurrentBurstTime += elapsedTime; if (CurrentBurstTime >= BurstTime) { CurrentBurstTime -= BurstTime; for (int i = 0; i < GrainsPerBurst; i++) { double angle = Logic.Display.Screen.Rand.NextDouble() * MathHelper.TwoPi; Loc2D particleSpeed = new Loc2D((int)(Math.Cos(angle) * Speed), (int)(Math.Sin(angle) * Speed)); int dist = Logic.Display.Screen.Rand.Next(StartDistance + 1); Loc2D startDelta = new Loc2D((int)(Math.Cos(angle) * dist), (int)(Math.Sin(angle) * dist)); Display.Screen.Effects[Screen.EffectPriority.None].Add(new ParticleAnimation(AnimationIndex, FrameLength, StartLoc + startDelta, particleSpeed, new Loc2D(), Color4.White, Color4.Gray, TotalTime )); } Bursts++; } if (Bursts >= TotalBursts) { ActionDone = true; } }
public virtual void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; if (ActionTime >= TOTAL_ANIM_TIME) { ActionDone = true; } else { MapHeight = ActionTime.Ticks * TextureManager.TILE_SIZE * 6 / TOTAL_ANIM_TIME.Ticks; if (MapHeight > TextureManager.TILE_SIZE) MapHeight = TextureManager.TILE_SIZE; } }
public void ProcessDelay(RenderTime time) { for (int i = 0; i < BranchCount; i++) { branches[i].Delay -= time; if (branches[i].Delay < RenderTime.Zero) branches[i].Delay = RenderTime.Zero; } }
public static void ProcessActions(RenderTime elapsedTime) { TotalTick += (ulong)elapsedTime.Ticks; outContainer.ProcessDelay(elapsedTime); //update music if (NextSong != null) { MusicFadeTime -= elapsedTime; if (MusicFadeTime.Ticks <= 0) { AudioManager.BGM.Stop(); if (System.IO.File.Exists(NextSong)) { Song = NextSong; AudioManager.BGM.SetBGM(Song); AudioManager.BGM.Play(); NextSong = null; } else { Song = ""; } } else { AudioManager.BGM.SetVolume((float)MusicFadeTime.Ticks / (float)MUSIC_FADE_TOTAL.Ticks); } } //update fade if (CurrentFade != FadeType.None) { FadeTime -= elapsedTime; if (FadeTime.Ticks <= 0) { CurrentFade = FadeType.None; } } //update the player foreach (PlayerSprite player in Players) { player.Process(elapsedTime); } //update Items foreach (ItemAnim item in Items) { item.Process(elapsedTime); } //update Npcs foreach (NpcSprite npc in Npcs) { npc.Process(elapsedTime); } for (int n = (int)EffectPriority.Ground; n <= (int)EffectPriority.Overlay; n++) { for (int i = Effects[(EffectPriority)n].Count - 1; i >= 0; i--) { Effects[(EffectPriority)n][i].Process(elapsedTime); if (Effects[(EffectPriority)n][i].ActionDone) Effects[(EffectPriority)n].RemoveAt(i); } } for (int i = Emitters.Count - 1; i >= 0; i--) { Emitters[i].Process(elapsedTime); if (Emitters[i].ActionDone) Emitters.RemoveAt(i); } //update the camera, reliant on the player CamOffset = FocusedCharacter.TileOffset; }
public virtual void Process(RenderTime elapsedTime) { ActionTime += elapsedTime; FrameTime += elapsedTime; if (Distance >= TotalDistance) { TimeSinceArrival += elapsedTime; } if (FrameTime >= FrameLength) { FrameTime = FrameTime - FrameLength; Frame++; } if (Frame >= TextureManager.GetSpellSheet(TextureManager.SpellAnimType.Beam, AnimationIndex).TotalFrames) { Frame = 0; if (Distance < TotalDistance) { Distance++; } } if (TimeSinceArrival >= LastingTime) { ActionDone = true; } }