public override void Update(ref GameTime gameTime) { base.Update(ref gameTime); // Collide with walls, remove if (CollidingWithBoundries) { LifeTime = 0; } foreach (Creature creature in Game1.WindowManager.GetGameplayWindow().CurrentLevel.Creatures) { // If creature is owner, skip if (creature == Owner) { continue; } // If it hits a creature, deal damage and add a burning effect if (HitBox.Intersects(creature.HitBox)) { creature.TakeDamage(50); creature.AddEffect(new Effects.Burning(10)); LifeTime = 0; } } }
public override void Update(ref GameTime gameTime) { base.Update(ref gameTime); // If colliding with walls, remove if (CollidingWithBoundries) { LifeTime = 0; } foreach (Creature creature in Game1.WindowManager.GetGameplayWindow().CurrentLevel.Creatures) { // If creature is owner, skip if (creature == Owner) { continue; } // Deal massive damage if it hits a creature if (HitBox.Intersects(creature.HitBox)) { creature.TakeDamage(100); LifeTime = 0; } } }
public override void Update(ref GameTime gameTime) { base.Update(ref gameTime); // Collide with walls, get removed if (CollidingWithBoundries) { LifeTime = 0; } foreach (Creature creature in Game1.WindowManager.GetGameplayWindow().CurrentLevel.Creatures) { // If creature is owner, skip if (creature == Owner) { continue; } // If it hits a creature, deal damage to the creature and heal the owner if (HitBox.Intersects(creature.HitBox)) { creature.TakeDamage(20); ((Creature)Owner).AddHealth(50); LifeTime = 0; } } }
public void CheckHit(NPC npc) { if (HitBox.Intersects(npc.Hitbox) && ticks % 10 == 0) { npc.life -= damage; npc.HitEffect(0, damage); } }
public override void Update(ref GameTime gameTime) { base.Update(ref gameTime); // Animate the projectile Sprite.Animate(0, 4); // If hits a wall, then remove if (CollidingWithBoundries) { LifeTime = 0; } // Distance to the nearest non-owner creature float proximity = float.MaxValue; // New distance to the nearest non-owner creature float distance; // Checks all players foreach (Creature creature in Game1.WindowManager.GetGameplayWindow().CurrentLevel.Creatures) { // Skip if creature is owner if (creature == Owner) { continue; } // If it hits a creature deal massive damage and remove the ball if (HitBox.Intersects(creature.HitBox)) { creature.TakeDamage(15000); LifeTime = 0; } // Calculate distance distance = Vector2.Distance(creature.Position, Position); // Check if another creature is closer and change who the ball follows if (distance < proximity) { following = creature; } // Normalise velocity based on difference of position and angles Velocity = Vector2.Normalize(following.Position - Position) * Speed; } }
public void mouseInput(Vector2 pos, bool pressed) { if (HitBox.Intersects(new Rectangle((int)pos.X, (int)pos.Y, 1, 1))) { Hovering(); if (pressed) { Clicked(); } } else { Transparency = 1f; } }
public void collectableCollisionCheck() { Collectable c = new Collectable(); { foreach (Collectable i in world.getCollectables()) { colCollision = HitBox.Intersects(i.HitBox); if (colCollision) { c = i; break; } } } if (colCollision) { c.isPickedUp = true; if (c.getType() == Collectable.CollectableType.HEALTH) { if ((this.health + c.healthValue) > 100) { this.health = 100; } else { this.health += c.healthValue; } } else if (c.getType() == Collectable.CollectableType.LOVE) { if (!isAdded) { this.happiness += c.happinessValue; world.getCompanion().getFed(); isAdded = true; } } else { Console.WriteLine("Something went awry. Type is {0}", c.getType()); } } }
public void entityCollisionCheck() { this.hitBox = new Rectangle((int)(nextPosition.X + hitBoxOffset.X), (int)(nextPosition.Y + hitBoxOffset.Y), (int)size.X, (int)size.Y); foreach (var i in world.getObstacles()) { entCollision = HitBox.Intersects(i.HitBox); if (entCollision) { break; } } if (entCollision) { nextPosition = CurrentPosition; if (direction == Direction.UP) { moveBackwards(); } else if (direction == Direction.DOWN) { moveForwards(); } else if (direction == Direction.RIGHT) { moveLeft(); } else if (direction == Direction.LEFT) { moveRight(); } this.hitBox = new Rectangle((int)(CurrentPosition.X + hitBoxOffset.X) - 1, (int)(CurrentPosition.Y + hitBoxOffset.Y), (int)size.X, (int)size.Y); } else { CurrentPosition = nextPosition; } }
public override void Update(ref GameTime gameTime) { base.Update(ref gameTime); Sprite.Animate(0, 5); if (CollidingWithBoundries) { LifeTime = 0; } foreach (Creature creature in Game1.WindowManager.GetGameplayWindow().CurrentLevel.Creatures) { if (creature == Owner) { continue; } if (HitBox.Intersects(creature.HitBox)) { creature.TakeDamage(damage); creature.AddEffect(new Effects.Burning(3)); LifeTime = 0; } } }
public bool IsCollision(Entity <int> gameEntity) { return(HitBox.Intersects(gameEntity.HitBox)); }
public virtual bool IsColliding(GameObject g) { return(HitBox.Intersects(g.HitBox)); }
public void GetValues() { if (!mem.HookProcess()) { return; } GameState gameState = mem.GetGameState(); bool isInGame = CheckInGame(gameState); bool isInGameWorld = CheckInGameWorld(gameState); bool isStartingGame = CheckStartingNewGame(gameState); if (!isInGameWorld) { notInGame = DateTime.Now; } LogValues(); if (settings.RainbowDash && isInGameWorld) { mem.ActivateRainbowDash(); } if (Model != null && currentSplit < settings.Splits.Count) { bool shouldSplit = false; OriSplit split = settings.Splits[currentSplit]; if (split.Field == "Start Game") { shouldSplit = isStartingGame; } else if (split.Field == "In Game") { shouldSplit = isInGame && notInGame.AddSeconds(1) > DateTime.Now; } else if (split.Field == "In Menu") { shouldSplit = !isInGame; } else if (split.Field == "Hitbox" || split.Field == "End of Forlorn Escape" || split.Field == "End of Horu Escape" || split.Field == "Spirit Tree Reached") { HitBox ori = new HitBox(mem.GetCameraTargetPosition(), 0.68f, 1.15f, true); HitBox hitBox = new HitBox(split.Value); shouldSplit = hitBox.Intersects(ori); } else if (isInGameWorld && DateTime.Now.AddSeconds(-1) > notInGame) { switch (split.Field) { case "Map %": decimal map = mem.GetTotalMapCompletion(); decimal splitMap; if (decimal.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitMap)) { shouldSplit = map >= splitMap; } break; case "Valley 100%": case "Grotto 100%": case "Swamp 100%": case "Ginso 100%": case "Forlorn 100%": case "Horu 100%": case "Glades 100%": case "Sorrow 100%": case "Black Root 100%": string areaName = split.Field.Substring(0, split.Field.Length - 5); List <Area> areas = mem.GetMapCompletion(); for (int i = 0; i < areas.Count; i++) { Area area = areas[i]; if (area.Name.IndexOf(areaName, StringComparison.OrdinalIgnoreCase) >= 0) { shouldSplit = area.Progress > (decimal)99.99; break; } } break; case "Soul Flame": case "Spirit Flame": case "Wall Jump": case "Charge Flame": case "Dash": case "Double Jump": case "Bash": case "Stomp": case "Light Grenade": case "Glide": case "Climb": case "Charge Jump": shouldSplit = mem.GetAbility(split.Field); break; case "Ability": shouldSplit = mem.GetAbility(split.Value); break; case "Mist Lifted": case "Clean Water": case "Wind Restored": case "Gumo Free": case "Warmth Returned": case "Darkness Lifted": shouldSplit = mem.GetEvent(split.Field); break; case "Gumon Seal": case "Sunstone": case "Water Vein": shouldSplit = mem.GetKey(split.Field); break; case "Ginso Tree Entered": case "Forlorn Ruins Entered": case "Mount Horu Entered": case "End Game": List <Scene> scenes = mem.GetScenes(); for (int i = 0; i < scenes.Count; i++) { Scene scene = scenes[i]; if (scene.State == SceneState.Loaded) { switch (scene.Name) { case "ginsoEntranceIntro": shouldSplit = split.Field == "Ginso Tree Entered"; break; case "forlornRuinsGetNightberry": shouldSplit = split.Field == "Forlorn Ruins Entered"; break; case "mountHoruHubMid": shouldSplit = split.Field == "Mount Horu Entered"; break; } } else if (scene.State == SceneState.Loading) { switch (scene.Name) { case "creditsScreen": shouldSplit = split.Field == "End Game"; break; } } } break; case "Health Cells": int maxHP = mem.GetCurrentHPMax(); int splitMaxHP; if (int.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitMaxHP)) { shouldSplit = maxHP >= splitMaxHP; } break; case "Current Health": int curHP = mem.GetCurrentHP(); float splitCurHP; if (float.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitCurHP)) { shouldSplit = curHP == (int)(splitCurHP * 4); } break; case "Energy Cells": float maxEN = mem.GetCurrentENMax(); int splitMaxEN; if (int.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitMaxEN)) { shouldSplit = maxEN >= splitMaxEN; } break; case "Current Energy": float curEN = mem.GetCurrentEN(); float splitCurEN; if (float.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitCurEN)) { shouldSplit = Math.Abs(curEN - splitCurEN) < 0.1f; } break; case "Ability Cells": int cells = mem.GetAbilityCells(); int splitCells; if (int.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitCells)) { shouldSplit = cells >= splitCells; } break; case "Level": int lvl = mem.GetCurrentLevel(); int splitLvl; if (int.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitLvl)) { shouldSplit = lvl >= splitLvl; } break; case "Key Stones": int keystones = mem.GetKeyStones(); int splitKeys; if (int.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitKeys)) { shouldSplit = keystones == splitKeys; } break; } } HandleSplit(shouldSplit, split); } }
public void Update(List <FallingItems> items, List <Texture2D> textures, Viewport viewport, Random random, Keys keyLeft, Keys keyRight, int numberOfItems, SoundEffect sound) { Random itemRandomizer = new Random(); KeyboardState keyboard = Keyboard.GetState(); if (keyboard.IsKeyDown(keyLeft)) { Mx -= 1.5; degrees -= 2.5f; } else if (keyboard.IsKeyDown(keyRight)) { Mx += 1.5; degrees += 2.5f; } if (position.X + texture.Width >= viewport.Width + 50) { Mx -= 1.6; degrees -= 4; } else if (position.X < 0) { Mx += 1.6; degrees += 4; } Mx *= slowDown; degrees *= (float)slowDown; position.X += (float)(Mx); for (int i = 0; i < items.Count; i++) { FallingItems item = items[i]; if (HitBox.Intersects(item.HitBox)) { if (i <= numberOfItems - numberOfEnemies) { //Score += item.ScoreValue; //TotalScore += item.ScoreValue; Score += 2; TotalScore += 2; item.position.Y = -100; item.position.X = random.Next(0, viewport.Width - item.texture.Width); item.texture = textures[itemRandomizer.Next(0, 7)]; } else { //Score += item.ScoreValue; //TotalScore += item.ScoreValue; Score += -10; TotalScore += -10; item.position.Y = -100; item.position.X = random.Next(0, viewport.Width - item.texture.Width); item.texture = textures[itemRandomizer.Next(8, 11)]; } } item.position.Y += (float)item.FallingSpeed; item.FallingSpeed += 0.05; if (item.position.Y + item.texture.Height > viewport.Height + 100) { //item.position.Y = 0; item.position.X = random.Next(0, viewport.Width - texture.Width); item.position.Y = -100; item.FallingSpeed = 0; item.position.X = random.Next(0, viewport.Width - texture.Width); } } if (Score > 25) { numberOfEnemies++; Score = 0; } else if (TotalScore < 0) { numberOfEnemies--; TotalScore = 0; } if (keyboard.IsKeyDown(Keys.Left) || keyboard.IsKeyDown(Keys.Right)) { sound.Play(); //https://www.youtube.com/watch?v=9yEM_OjzfMo for hitting bad character.//// while (true) { } } }
public void UpdateValues() { if (this.InvokeRequired) { this.Invoke((Action)UpdateValues); } else { bool tasEnabled = this.Width == 650 || (Memory.GetTASState() & 1) != 0; if (this.Width < 650 && tasEnabled) { this.Width = 650; this.Height = 235; lblCurrentInput.Visible = true; lblNextInput.Visible = true; lblTASStates.Visible = true; } else { lblCurrentInput.Text = Memory.GetTASCurrentInput(); lblNextInput.Text = Memory.GetTASNextInput(); lblTASStates.Text = Memory.GetTASExtraInfo(); } GameState gameState = Memory.GetGameState(); bool isInGameWorld = CheckInGameWorld(gameState); bool isStartingGame = CheckStartingNewGame(gameState); PointF currentSpeed = Memory.CurrentSpeed(); PointF pos = tasEnabled && Memory.HasTAS() ? Memory.GetTASOriPositon() : Memory.GetCameraTargetPosition(); HitBox ori = new HitBox(pos, 0.68f, 1.15f, true); HitBox hitBox = new HitBox("145,580,20,40"); HitBox hitBox2 = new HitBox("170,580,130,140"); bool inFinal = hitBox.Intersects(ori) || hitBox2.Intersects(ori); if (extraFast && Math.Abs(Memory.WaterSpeed() - 9f) > 0.1f && !inFinal) { goingFast = true; Memory.SetSpeed(24f, 85f, 39f, 12f, 70f, 70f, 9f, 60f, 200f, 5f, 16f, 90f, 180f); } else if ((!extraFast || inFinal) && goingFast) { goingFast = false; Memory.SetSpeed(11.6667f, 60f, 26f, 6f, 56.568f, 40f, 6f, 38f, 100f, 3f, 8f, 50f, 100f); } List <Area> areas = Memory.GetMapCompletion(); decimal total = 0; Area currentArea = default(Area); for (int i = 0; i < areas.Count; i++) { Area area = areas[i]; total += area.Progress; if (area.Current) { currentArea = area; } } if (areas.Count > 0) { total /= areas.Count; } List <Scene> scenes = Memory.GetScenes(); string currentScene = string.Empty; for (int i = 0; i < scenes.Count; i++) { Scene scene = scenes[i]; if (scene.Active) { currentScene = scene.Name; break; } } PointF cursor = Memory.GetCursorPosition(); lblArea.Text = "Area: " + (string.IsNullOrEmpty(currentArea.Name) ? "N/A" : currentArea.Name + " - " + currentArea.Progress.ToString("0.00") + "%"); lblMap.Text = "Total: " + total.ToString("0.00") + "% Scene: " + currentScene; lblPos.Text = "Pos: " + pos.X.ToString("R") + ", " + pos.Y.ToString("R") + " Cursor: " + cursor.X.ToString("0.000") + ", " + cursor.Y.ToString("0.000"); lblSpeed.Text = (extraFast ? "Insane Speed: " : "Speed: ") + currentSpeed.X.ToString("0.000") + ", " + currentSpeed.Y.ToString("0.000") + " (" + Math.Sqrt(currentSpeed.X * currentSpeed.X + currentSpeed.Y * currentSpeed.Y).ToString("0.000") + ")"; if (isInGameWorld) { int level = Memory.GetCurrentLevel(); int xp = Memory.GetExperience(); lblLevel.Text = "Level: " + level.ToString(); lblHP.Text = "HP: " + ((double)Memory.GetCurrentHP() / 4).ToString("0.##") + " / " + Memory.GetCurrentHPMax().ToString(); lblEN.Text = "EN: " + Memory.GetCurrentEN().ToString("0.##") + " / " + ((int)Memory.GetCurrentENMax()).ToString(); lblAbility.Text = "Ability: " + Memory.GetAbilityCells().ToString() + " / 33"; lblXP.Text = "XP: " + xp.ToString() + " / " + GetXP(level); lblKeys.Text = "Keys: " + Memory.GetKeyStones(); } else { lblLevel.Text = "Level: N/A"; lblHP.Text = "HP: N/A"; lblEN.Text = "EN: N/A"; lblAbility.Text = "Ability: N/A"; lblXP.Text = "XP: N/A"; lblKeys.Text = "Keys: N/A"; } } }
public override int Update(GameTime gameTime, Vector2 screen) { //Moving Wiggle = true; double angle = 0; Vector2 delta = Position - Game1.Bob.Position; Vector2 delta2 = Position - Game1.Steve.Position; if (!Game1.Bob.Alive) { angle = Math.Atan2(delta2.Y, delta2.X); } else if (!Game1.Steve.Alive) { angle = Math.Atan2(delta.Y, delta.X); } else if (delta.Length() < delta2.Length()) { angle = Math.Atan2(delta.Y, delta.X); } else { angle = Math.Atan2(delta2.Y, delta2.X); } Rotation = (float)(angle - 90 * Math.PI / 180); Acceleration += new Vector2((float)Math.Cos(Rotation - Math.PI / 2), (float)Math.Sin(Rotation - Math.PI / 2)); Acceleration.Normalize(); Acceleration *= 0.05f; Wiggle = true; //stop at walls: if (Position.X > screen.X) { Velocity.X = 0; Position.X = screen.X; } if (Position.X < 0) { Velocity.X = 0; Position.X = 0; } if (Position.Y > screen.Y) { Velocity.Y = 0; Position.Y = screen.Y; } if (Position.Y < 0) { Velocity.Y = 0; Position.Y = 0; } //taking damage and dying: for (int i = 0; i < Game1.Lasers.Count; i++) { if (Game1.Lasers[i].HitBox.Intersects(HitBox)) { Health--; Game1.Lasers.RemoveAt(i); if (Health <= 0) { return(1); } } } //Killing: if (HitBox.Intersects(Game1.Bob.HitBox)) { Game1.Bob.Alive = false; } if (HitBox.Intersects(Game1.Steve.HitBox)) { Game1.Steve.Alive = false; } return(base.Update(gameTime)); }
public Boolean CollideDoor(Rectangle door) { return(HitBox.Intersects(door)); }