internal void GetCollidedTiles(Node node, List<Node> collidedNodes) { foreach (Room room in this.Dungeon.Rooms) { room.GetCollidedBlocks(node, collidedNodes); } }
public void BloodCellCollides(Node node1, Node node2) { if (node1.Touching.Bottom) { this.OnFloor = true; this.Velocity.Y = 0; } }
private bool isAlreadyInCollisionList(Node node1, Node node2) { foreach(Collision collision in Collisions) { if ((collision.Node2 == node1 && collision.Node1 == node2) || (collision.Node1 == node1 && collision.Node2 == node2)) return true; } return false; }
public Player(Layer bulletLayer) : base(CharacterType.PLAYER) { this.BulletLayer = bulletLayer; this.Weapon = new Weapon(bulletLayer); this.LoadTexture("player"); this.AddChild(this.Weapon); }
public Collision(Node node1, Node node2, Action<Node, Node> callback, Func<Node, Node, bool> checker) { if (DirtyNode1 == null || DirtyNode2 == null) { DirtyNode1 = new Node(); DirtyNode2 = new Node(); } this.Node1 = node1; this.Node2 = node2; this.Callback = callback; this.Checker = checker; this.node1PositionDiff = Vector2.Zero; this.node2PositionDiff = Vector2.Zero; this.node1VelocityDiff = Vector2.Zero; this.node2VelocityDiff = Vector2.Zero; }
public void addCollision(Node node, string collideGroup, Action<Node, Node> callback, Func<Node, Node, bool> checker) { List<Node> collidedNodes = new List<Node>(); if (this.IsLevelCollision(collideGroup)) { this.GetCollidedTiles(node, collidedNodes); } else { QuadTree.retrieve(collidedNodes, node); } foreach (Node collideNode in collidedNodes) { if (collideNode.IsMemberOfCollisionGroup(collideGroup)) this.addCollision(node, collideNode, callback, checker); } }
internal void GetCollidedTiles(Node node, List<Node> collidedNodes) { int xMin = (int)Math.Floor(node.Position.X / Tilemap.tileWidth); int xMax = (int)Math.Ceiling((node.Position.X + node.Width) / Tilemap.tileWidth); int yMin = (int)Math.Floor(node.Position.Y / Tilemap.tileHeight); int yMax = (int)Math.Ceiling((node.Position.Y + node.Height) / Tilemap.tileHeight); xMin = Math.Max(0, xMin - 1); xMax = Math.Min(Width, xMax + 1); yMin = Math.Max(0, yMin - 1); yMax = Math.Min(Height, yMax + 1); for (var x = xMin; x < xMax; x++) { for (var y = yMin; y < yMax; y++) { if(this._map[x,y] != null) collidedNodes.Add(this._map[x, y]); } } }
public void insert(Node node) { if (!node.HasCollisionGroups() || !node.Active || !node.Collidable) return; if(!node.GetBoundingBox().Intersects(this.bounds)) return; if(nodes[0] != null) { int index = getIndex(node); if(index != -1) { nodes[index].insert(node); return; } } objects.Add(node); if(objects.Count > MAX_OBJECTS && level < MAX_LEVELS) { if(nodes[0] == null) split(); int i = 0; while(i < objects.Count) { int index = getIndex(objects.ElementAt(i)); if (index != -1) { Node nodeToMove = objects.ElementAt(i); nodes[index].insert(nodeToMove); objects.RemoveAt(i); } else i++; } } }
public object Clone() { Node clone = new Node(); clone.Position = new Vector2(Position.X, Position.Y); clone.Velocity = new Vector2(Velocity.X, Velocity.Y); clone.Width = Width; clone.Height = Height; clone.Parent = Parent; return clone; }
public void AddChild(Node child) { Children.Add(child); child.Parent = this; }
public static void Collide(Node node, string collideGroup, Action<Node, Node> callback) { Core.CollisionSolver.addCollision(node, collideGroup, callback, null); }
private void GetCollidedTiles(Node node, List<Node> collidedNodes) { CollisionSolver.Level.GetCollidedTiles(node, collidedNodes); }
private void CharacterCollision(Node bullet, Node characterNode) { Character character = (Character)characterNode; if (this.Shooter.Type == CharacterType.PLAYER && character.Type == CharacterType.ENEMY) { character.Hit(this); this.Deactivate(); } else if (this.Shooter.Type == CharacterType.ENEMY && character.Type == CharacterType.PLAYER) { character.Hit(this); this.Deactivate(); } }
public List<Node> retrieve(List<Node> returnObjects, Node node) { int index = getIndex(node); if (index != -1 && nodes[0] != null) { nodes[index].retrieve(returnObjects, node); } returnObjects.AddRange(objects); return returnObjects; }
public static void Show(Node node, int damage, Color color) { }
public static void Show(Node node, int damage) { DamageText text = DamageIndicator.Pool.New(); text.Position = node.WorldPosition; text.Activate(); }
private void Collision(Node player, Node tile) { if (player.Touching.Bottom) { onFloor = true; airVelocityX = 0; Velocity.Y = 0; } if (player.Touching.Left) { onWallLeft = true; Velocity.X = 0; } }
internal void GetCollidedTiles(Node node, List<Node> collidedNodes) { foreach (TileLayer layer in this.Layers) { layer.GetCollidedTiles(node, collidedNodes); } }
private bool PlayerEndCollision(Node player, Node end) { if (GameManager.Input.GetInputState(PlayerIndex.One).Y < -0.5) { this.Load(); } return false; }
public void Clone(Node node) { node.Position = this.Position; node.Velocity = this.Velocity; node.Width = this.Width; node.Height = this.Height; node.Parent = this.Parent; }
public void RemoveChild(Node child) { if (!Children.Remove(child)) throw new Exception("Tried to remove child but gave an error"); }
public bool BeingCaptured(Node player, Node capturePoint) { if ((capturePoint as CapturePoint).owner == this) return false; GamePadState state = GamePad.GetState(this.index); if (state.Triggers.Right > 0.5 && state.Triggers.Left > 0.5 && this.onfloor) { (capturePoint as CapturePoint).startCapturing(this); (capturePoint as CapturePoint).isCollidingPlayer = true; image.PlayAnimation("CAPTURING"); this.captureParticles.Position = this.Position; this.captureParticles.Start(); this.Velocity = Vector2.Zero; } return false; }
private void TilemapCollision(Node bullet, Node tile) { if (this.Facing == Facing.Left) this.ExplosionParticles.Position = new Vector2(tile.WorldPosition.X + tile.Width, this.WorldPosition.Y); else this.ExplosionParticles.Position = tile.WorldPosition; this.ExplosionParticles.Explode(); this.Deactivate(); this.ParticleEngine.Stop(); }
private void TilemapCollision(Node bomb, Node tilemap) { this.Velocity = Vector2.Zero; stuckToAWall = true; }
private void addCollision(Node node1, Node node2, Action<Node, Node> callback, Func<Node, Node, bool> checker) { if (!isAlreadyInCollisionList(node1, node2) && node1 != node2) Collisions.Add(new Collision(node1, node2, callback, checker)); }
public static void Collide(Node node, string collideGroup, Action<Node, Node> callback, Func<Node, Node, bool> checker) { Core.CollisionSolver.addCollision(node, collideGroup, callback, checker); }
public void Collision(Node player, Node collidingTile) { if (!onfloor || (speedY > 50 && (!player.Touching.Left && !player.Touching.Right)))//check with prevspeed { soundEffectLand.Play(0.5f, 0, 0); this.dirtyParticles.Explode(); } if (player.Touching.Bottom) { onfloor = true; speedY = 0; speedX = 0; // CollisionState = "bottom"; } if (player.Touching.Left) { if (!onfloor) { CollisionState = "left"; speedX = 0; } } if (player.Touching.Right) { if (!onfloor) { CollisionState = "right"; speedX = 0; } } if (player.Touching.Top) { speedY = 0; } }
private int getIndex(Node node) { BoundingRectangle nodeRect = node.GetBoundingBox(); int index = -1; float verticleMidPoint = bounds.X + (bounds.Width / 2); float horizontalMidPoint = bounds.Y + (bounds.Height / 2); bool topQuadrant = nodeRect.Y < horizontalMidPoint && nodeRect.Y + nodeRect.Height < horizontalMidPoint; bool bottomQuadrant = nodeRect.Y > horizontalMidPoint; if (nodeRect.X < verticleMidPoint && nodeRect.X + nodeRect.Width < verticleMidPoint) { if (topQuadrant) index = 0; else if (bottomQuadrant) index = 3; } else if (nodeRect.X > verticleMidPoint) { if (topQuadrant) index = 1; else if (bottomQuadrant) index = 2; } return index; }
public Activity(Node node, int duration) { this.Node = node; this.Duration = duration; this.Time = 0; }
public static void Collide(Node node, string collideGroup) { Core.CollisionSolver.addCollision(node, collideGroup, null, null); }