private bool collideOrOffscreenCheck(Level level, Glider jellyfish) { return(jellyfish.Position.X + jellyfish.Collider.Right > level.Bounds.Right || jellyfish.Position.X + jellyfish.Collider.Left < level.Bounds.Left || jellyfish.Position.Y + jellyfish.Collider.Top < level.Bounds.Top || Collide.Check(jellyfish, level.Tracker.Entities[typeof(Solid)])); }
public override void Update() { base.Update(); var actors = Scene.Tracker.GetEntities <Actor>(); _currentButtonState = false; foreach (var actor in actors) { if (Collide.Check(actor, _button)) { _currentButtonState = true; break; } } if (_currentButtonState != _previousButtonState) { SendOutSignals(_currentButtonState); } int target = _currentButtonState ? 2 : -2; _button.Image.Position.Y = Calc.Approach(_button.Image.Position.Y, target, 40f * Engine.DeltaTime); _previousButtonState = _currentButtonState; }
public override void Update() { base.Update(); CrystalStaticSpinner murderSpinner = null; if (killCircle == null && CollideCheckConnections(ref murderSpinner)) { if (ActiveCompanion != null) { ActiveCompanion.DetachFromPlayer(); } StartKillCircle(murderSpinner); } connectionLineOffset += Engine.DeltaTime * connectionLineSpeed; if (connectionLineOffset > Math.PI * 2.0f) { connectionLineOffset -= (float)Math.PI * 2.0f; } if (killCircle != null) { if (Scene.OnInterval(0.05f)) { foreach (Companion companion in nearestCompanions) { if (manualResets.Contains(companion)) { continue; } float dir = Calc.Random.NextFloat((float)Math.PI * 2f); Vector2 towardsCompanion = (companion.Position - killCircle.Position).SafeNormalize() * (killCircle.Collider as Circle).Radius; SceneAs <Level>().ParticlesFG.Emit(requiresDash ? P_Burst : P_BurstNoDash, 1, killCircle.Position + towardsCompanion, Vector2.Zero, dir); } } (killCircle.Collider as Circle).Radius += killCircleExpansionSpeed * Engine.DeltaTime; foreach (Companion companion in nearestCompanions) { if (!manualResets.Contains(companion) && Collide.Check(companion, killCircle)) { companion.Reset(true); if (manualResets.Count == nearestCompanions.Length) { killCircle.RemoveSelf(); killCircle = null; ResetCompanions(); break; } } } } }
public bool CollideCheck(int tag, Vector2 at) { #if DEBUG if (Scene == null) { throw new Exception("Can't collide check an Entity against a tag list when it is not a member of Scene"); } #endif return(Collide.Check(this, Scene[tag], at)); }
public bool Check(Entity other) { if (MInput.Keyboard.Pressed(Keys.Space)) { return(Collide.Check(other, this)); } else { return(false); } }
public virtual bool LaserBlockingCheck(Laserbeam beam) { Collider origCollider = Collider; Collider = GetLaserBlockingCollider(beam); bool colliding = Collide.Check(beam, this); Collider = origCollider; return(colliding); }
public bool CollideCheck <T>() where T : Entity { #if DEBUG if (Scene == null) { throw new Exception("Can't collide check an Entity against tracked Entites when it is not a member of Scene"); } else if (Scene.Tracker.Entities.ContainsKey(typeof(T)) == false) { throw new Exception("Can't collide check an Entity against an untracked Entity type"); } #endif return(Collide.Check(this, Scene.Tracker.Entities[typeof(T)])); }
public override void Update() { base.Update(); bool foundConveyor = false; foreach (Conveyor conveyor in Scene.Tracker.GetEntities <Conveyor>()) { if (!conveyor.IsBrokenDown && Collide.Check(conveyor, Entity, conveyor.Position - Vector2.UnitY)) { foundConveyor = true; Move(conveyor.IsMovingLeft ? -Conveyor.ConveyorMoveSpeed: Conveyor.ConveyorMoveSpeed); } } IsOnConveyor = foundConveyor; }
public Entity CollideFirstOutside(int tag, Vector2 at) { #if DEBUG if (Scene == null) { throw new Exception("Can't collide check an Entity against tracked Entites when it is not a member of Scene"); } #endif foreach (Entity entity in Scene[tag]) { if (Collide.Check(this, entity) == false && Collide.Check(this, entity, at) == true) { return(entity); } } return(null); }
public bool CollideCheckOutside <T>(Vector2 at) where T : Entity { #if DEBUG if (Scene == null) { throw new Exception("Can't collide check an Entity against tracked Entites when it is not a member of Scene"); } else if (Scene.Tracker.Entities.ContainsKey(typeof(T)) == false) { throw new Exception("Can't collide check an Entity against an untracked Entity type"); } #endif foreach (Entity entity in Scene.Tracker.Entities[typeof(T)]) { if (Collide.Check(this, entity) == false && Collide.Check(this, entity, at) == true) { return(true); } } return(false); }
public bool CollideCheckByComponent <T>() where T : Component { #if DEBUG if (Scene == null) { throw new Exception("Can't collide check an Entity against tracked Entites when it is not a member of Scene"); } else if (Scene.Tracker.Entities.ContainsKey(typeof(T)) == false) { throw new Exception("Can't collide check an Entity against an untracked Entity type"); } #endif foreach (Component c in Scene.Tracker.Components[typeof(T)]) { if (Collide.Check(this, c.Entity) == true) { return(true); } } return(false); }
public T CollideFirstOutsideByComponent <T>(Vector2 at) where T : Component { #if DEBUG if (Scene == null) { throw new Exception("Can't collide check an Entity against tracked Entites when it is not a member of Scene"); } else if (Scene.Tracker.Entities.ContainsKey(typeof(T)) == false) { throw new Exception("Can't collide check an Entity against an untracked Entity type"); } #endif foreach (Component component in Scene.Tracker.Components[typeof(T)]) { if (Collide.Check(this, component.Entity) == false && Collide.Check(this, component.Entity, at) == true) { return(component as T); } } return(null); }
public List <T> CollideAllByComponent <T>() where T : Component { #if DEBUG if (Scene == null) { throw new Exception("Can't collide check an Entity against tracked Entites when it is not a member of Scene"); } else if (Scene.Tracker.Entities.ContainsKey(typeof(T)) == false) { throw new Exception("Can't collide check an Entity against an untracked Entity type"); } #endif List <T> list = new List <T>(); foreach (Component component in Scene.Tracker.Components[typeof(T)]) { if (Collide.Check(this, component.Entity) == true) { list.Add(component as T); } } return(list); }
public bool CollideCheck(Entity other, Vector2 at) { return(Collide.Check(this, other, at)); }
public bool CollideCheckOutSide(Entity other, Vector2 at) { return(!Collide.Check(this, other) && Collide.Check(this, other, at)); }
public override void Update() { base.Update(); switch (StateMachine.State) { default: break; case StIdle: if (Collide.Check(Game1.Player, DetectAreaCollider)) { StateMachine.State = StJump; } break; case StJump: // init jump if (!Jumping) { JumpTarget = Game1.Player.Position; JumpOrigin = Center; float distance = Vector2.Distance(JumpTarget, JumpOrigin); HorizontalDir = Vector2.Normalize(JumpTarget - JumpOrigin); Acceleration = Vector2.One * (distance / JUMP_DURATION); VerticalVelocity = -9.8f * JUMP_DURATION / 2; // vy = -aT/2 Jumping = true; } // update horizontal velocity Velocity = HorizontalDir * Acceleration * Engine.DeltaTime; // update horizontal position if (!CollideCheck(GAccess.SolidTag, new Vector2(X + Velocity.X, Y))) { X += Velocity.X; } if (!CollideCheck(GAccess.SolidTag, new Vector2(X, Y + Velocity.Y))) { Y += Velocity.Y; } //X += Velocity.X; //Y += Velocity.Y; // update vertical velocity VerticalVelocity += 9.8f * Engine.DeltaTime; // update vertical position Z += VerticalVelocity; // if landed then change state if (Z > 0) { Z = 0; Jumping = false; Velocity = Vector2.Zero; if (Engine.TotalTime - lastEnergyAtkTime > ENERGY_ATK_RECHARGE) { StateMachine.State = StEnergyAtk; } else { StateMachine.State = StJump; } } // project vertical Z to 2D if (Z != 0) { if (!CollideCheck(GAccess.SolidTag, new Vector2(X, Y + VerticalVelocity))) { Y += VerticalVelocity; } } break; case StEnergyAtk: if (ZaletosBalls.Balls.Count == 0 && ZaletosBalls.Init) { ZaletosBalls.Recharge(); } else if (!ZaletosBalls.Init) { if (!ZaletosBalls.Init && Engine.TotalTime - lastShotTime > SHOOT_DELAY) { lastShotTime = Engine.TotalTime; ZaletosBalls.Shoot(Game1.Player.Position); } if (ZaletosBalls.Balls.Count == 0) { lastEnergyAtkTime = Engine.TotalTime; StateMachine.State = StJump; } } break; case StDead: if (ZaletosBalls.Balls.Count != 0) { ZaletosBalls.Clear(); } Sprite.Play("dead_0"); break; } }
public bool CollideCheck(Entity other) { return(Collide.Check(this, other)); }