public override void Update(Character[] c, int ID, Map map) { me = c[ID]; if (jobFrame < 0f) { float r = Rand.GetRandomFloat(0f, 1f); if (r < 0.6f) { job = JOB_MELEE_CHASE; jobFrame = Rand.GetRandomFloat(2f, 4f); FindTarg(c); } else if (r < 0.8f) { job = JOB_AVOID; jobFrame = Rand.GetRandomFloat(1f, 2f); FindTarg(c); } else { job = JOB_IDLE; jobFrame = Rand.GetRandomFloat(.5f, 1f); } } base.Update(c, ID, map); }
public override void Update(float gameTime, Map map, ParticleManager pMan, Character[] c) { if (HitManager.CheckHit(this, c, pMan)) frame = 0f; Trajectory.Y = (float)Math.Sin((double)frame * 13.0) * 150f; if (map.CheckParticleCol(Location)) { this.frame = 0f; pMan.MakeExplosion(Location, 1f); } pMan.AddParticle(new Fire(Location, -Trajectory / 8f, .5f, Rand.GetRandomInt(0, 4))); pMan.AddParticle(new Smoke(Location, Rand.GetRandomVector2(-20f, 20f, -50f, 10f) - Trajectory / 10f, 1f, .8f, .6f, 1f, .5f, Rand.GetRandomInt(0, 4))); pMan.AddParticle(new Heat(Location, Rand.GetRandomVector2(-20f, 20f, -50f, -10f), Rand.GetRandomFloat(.5f, 2f))); base.Update(gameTime, map, pMan, c); }
public HUD(SpriteBatch _sprite, Texture2D _spritesTex, Texture2D _nullTex, Character[] _character, Map _map) { sprite = _sprite; spritesTex = _spritesTex; character = _character; map = _map; nullTex = _nullTex; scoreDraw = new ScoreDraw(sprite, spritesTex); }
public virtual void Update(Character[] c, int ID, Map map) { me = c[ID]; me.KeyLeft = false; me.KeyRight = false; me.KeyUp = false; me.KeyDown = false; me.KeyAttack = false; me.KeySecondary = false; me.KeyJump = false; jobFrame -= Game1.FrameTime; DoJob(c, ID); }
/// <summary> /// Update all active particles. /// </summary> /// <param name="frameTime">Time delta that has elpased since the last udpate</param> /// <param name="map">The game map</param> /// <param name="c">The characters array</param> public void UpdateParticles(float frameTime, Map map, Character[] c) { for (int i = 0; i < particle.Length; i++) { if (particle[i] != null) { particle[i].Update(frameTime, map, this, c); if (!particle[i].Exists) { particle[i] = null; } } } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// /// We'll instantiate our stuff, load character definitions. /// /// /// </summary> protected override void Initialize() { Rand.random = new Random(); map = new Map(); netPlay = new NetPlay(); screenSize.X = 800f; screenSize.Y = 600f; charDef[(int)CharacterDefinitions.Guy] = new CharDef("chars/guy", CharacterDefinitions.Guy); charDef[(int)CharacterDefinitions.Zombie] = new CharDef("chars/zombie", CharacterDefinitions.Zombie); charDef[(int)CharacterDefinitions.Wraith] = new CharDef("chars/wraith", CharacterDefinitions.Wraith); charDef[(int)CharacterDefinitions.Carlos] = new CharDef("chars/carlos", CharacterDefinitions.Carlos); Sound.Initialize(); Music.Initialize(); QuakeManager.Init(); base.Initialize(); store = new Store(); settings = new Settings(); store.GetDevice(); }
public MapScript(Map map) { this.map = map; Flags = new MapFlags(32); Lines = new MapScriptLine[128]; }
public virtual void Update(float gameTime, Map map, ParticleManager pMan, Character[] c) { Location += Trajectory * gameTime; frame -= gameTime; if (frame < 0.0f) KillMe(); }
public override void Update(float gameTime, Map map, ParticleManager pMan, Character[] c) { if (frame < 0.5f) { if (Trajectory.Y < -10.0f) Trajectory.Y += gameTime * 500.0f; if (Trajectory.X < -10.0f) Trajectory.X += gameTime * 150.0f; if (Trajectory.X > 10.0f) Trajectory.X -= gameTime * 150.0f; } base.Update(gameTime, map, pMan, c); }
private void CheckXCol(Map map, Vector2 pLoc) { if (Trajectory.X + ColMove > 0f) if (map.CheckCol(new Vector2(Loc.X + 25f, Loc.Y - 15f))) Loc.X = pLoc.X; if (Trajectory.X + ColMove < 0f) if (map.CheckCol(new Vector2(Loc.X - 25f, Loc.Y - 15f))) Loc.X = pLoc.X; }
public void Update(Map map, ParticleManager pMan, Character[] c) { if (Ai != null) Ai.Update(c, ID, map); PressedKey = PressedKeys.None; if (KeyAttack) { PressedKey = PressedKeys.Attack; if (KeyUp) PressedKey = PressedKeys.Lower; if (KeyDown) PressedKey = PressedKeys.Upper; } if (KeySecondary) { PressedKey = PressedKeys.Secondary; if (KeyUp) PressedKey = PressedKeys.SecUp; if (KeyDown) PressedKey = PressedKeys.SecDown; } if (PressedKey > PressedKeys.None) { if (GotoGoal[(int)PressedKey] > -1) { SetFrame(GotoGoal[(int)PressedKey]); if (KeyLeft) Face = CharDir.Left; if (KeyRight) Face = CharDir.Right; PressedKey = PressedKeys.None; for (int i = 0; i < GotoGoal.Length; i++) GotoGoal[i] = -1; frame = 0f; } } if (StunFrame > 0f) StunFrame -= Game1.FrameTime; #region Update Dying if (DyingFrame > -1f) { DyingFrame += Game1.FrameTime; } #endregion #region Update Animation if (DyingFrame < 0f) { Animation animation = charDef.GetAnimation(Anim); KeyFrame keyframe = animation.GetKeyFrame(AnimFrame); frame += Game1.FrameTime * 30.0f; if (frame > (float)keyframe.Duration) { int pframe = AnimFrame; script.DoScript(Anim, AnimFrame); CheckTrig(pMan); frame -= (float)keyframe.Duration; if (AnimFrame == pframe) AnimFrame++; keyframe = animation.GetKeyFrame(AnimFrame); if (AnimFrame >= animation.getKeyFrameArray().Length) AnimFrame = 0; } if (keyframe.FrameRef < 0) AnimFrame = 0; if (AnimName == "jhit") { if (Trajectory.Y > -100f) SetAnim("jmid"); } } #endregion #region Collison w/ other characters for (int i = 0; i < c.Length; i++) { if (i != ID) { if (c[i] != null) { if (!ethereal && !c[i].ethereal) { if (Loc.X > c[i].Loc.X - 90f * c[i].Scale && Loc.X < c[i].Loc.X + 90f * c[i].Scale && Loc.Y > c[i].Loc.Y - 120f * c[i].Scale && Loc.Y < c[i].Loc.Y + 10f * c[i].Scale) { float dif = (float)Math.Abs(Loc.X - c[i].Loc.X); dif = 180f * c[i].Scale - dif; dif *= 2f; if (Loc.X < c[i].Loc.X) { ColMove = -dif; c[i].ColMove = dif; } else { ColMove = dif; c[i].ColMove = -dif; } } } } } } if (ColMove > 0f) { ColMove -= 400f * Game1.FrameTime; if (ColMove < 0f) ColMove = 0f; } if (ColMove < 0f) { ColMove += 400f * Game1.FrameTime; if (ColMove > 0f) ColMove = 0f; } #endregion #region Update loc by trajectory Vector2 pLoc = new Vector2(Loc.X, Loc.Y); if (State == CharState.Grounded || (State == CharState.Air && Floating)) { if (Trajectory.X > 0f) { Trajectory.X -= Game1.Friction * Game1.FrameTime; if (Trajectory.X < 0f) Trajectory.X = 0f; } if (Trajectory.X < 0f) { Trajectory.X += Game1.Friction * Game1.FrameTime; if (Trajectory.X > 0f) Trajectory.X = 0f; } } Loc.X += Trajectory.X * Game1.FrameTime; Loc.X += ColMove * Game1.FrameTime; if (State == CharState.Air) { Loc.Y += Trajectory.Y * Game1.FrameTime; } #endregion #region Collision detection if (State == CharState.Air) { #region Air State if (Floating) { Trajectory.Y += Game1.FrameTime * Game1.Gravity * 0.5f; if (Trajectory.Y > 100f) Trajectory.Y = 100f; if (Trajectory.Y < -100f) Trajectory.Y = -100f; } else Trajectory.Y += Game1.FrameTime * Game1.Gravity; CheckXCol(map, pLoc); #region Land on ledge if (Trajectory.Y > 0.0f) { for (int i = 0; i < 16; i++) { if (map.GetLedgeTotalNodes(i) > 1) { int ts = map.GetLedgeSec(i, pLoc.X); int s = map.GetLedgeSec(i, Loc.X); float fY; float tfY; if (s > -1 && ts > -1) { tfY = map.GetLedgeYLoc(i, s, pLoc.X); fY = map.GetLedgeYLoc(i, s, Loc.X); if (pLoc.Y <= tfY && Loc.Y >= fY) { if (Trajectory.Y > 0.0f) { Loc.Y = fY; ledgeAttach = i; Land(); } } else if (map.GetLedgeFlags(i) == (int)LedgeFlags.Solid && Loc.Y >= fY) { Loc.Y = fY; ledgeAttach = i; Land(); } } } } } #endregion #region Land on col if (State == CharState.Air) { if (Trajectory.Y > 0f) { if (map.CheckCol(new Vector2(Loc.X, Loc.Y + 15f))) { Loc.Y = (float)((int)((Loc.Y + 15f) / 64f) * 64); Land(); } } } #endregion #endregion } else if (State == CharState.Grounded) { #region Grounded State if (ledgeAttach > -1) { if (map.GetLedgeSec(ledgeAttach, Loc.X) == -1) { FallOff(); } else { Loc.Y = map.GetLedgeYLoc(ledgeAttach, map.GetLedgeSec(ledgeAttach, Loc.X), Loc.X); } } else { if (!map.CheckCol(new Vector2(Loc.X, Loc.Y + 15f))) FallOff(); } CheckXCol(map, pLoc); #endregion } #endregion #region Key input if (AnimName == "idle" || AnimName == "run" || (State == CharState.Grounded && CanCancel)) { if (AnimName == "idle" || AnimName == "run") { if (KeyLeft) { SetAnim("run"); Trajectory.X = -Speed; Face = CharDir.Left; } else if (KeyRight) { SetAnim("run"); Trajectory.X = Speed; Face = CharDir.Right; } else { SetAnim("idle"); } } if (KeyAttack) { SetAnim("attack"); } if (KeySecondary) { SetAnim("second"); } if (KeyJump) { SetAnim("jump"); } if (RightAnalog.X > 0.2f || RightAnalog.X < -0.2f) { SetAnim("roll"); if (AnimName == "roll") { if (RightAnalog.X > 0f) Face = CharDir.Right; else Face = CharDir.Left; } } } if (AnimName == "fly" || (State == CharState.Air && CanCancel)) { if (KeyLeft) { Face = CharDir.Left; if (Trajectory.X > -Speed) Trajectory.X -= 500f * Game1.FrameTime; } if (KeyRight) { Face = CharDir.Right; if (Trajectory.X < Speed) Trajectory.X += 500f * Game1.FrameTime; } if (KeySecondary) { SetAnim("fsecond"); } if (KeyAttack) { SetAnim("fattack"); } } #endregion }