/// <summary> /// called when a collision event occures /// </summary> /// <param name="args"></param> /// <returns></returns> public virtual bool OnNewCollision(ICollisionInput args) { // check if the entity has any colliders if (_colliders != null) { // find which collider in the _colliders is colliding foreach (ICreateCollider i in _colliders) { // set _colliderThis and _collided with if (i.GetTag() == args.GetCollided()[0]) { _collidedThis = args.GetCollided()[0]; _collidedWith = args.GetCollided()[1]; _collidedThisUID = args.GetUID()[0]; _collidedWithUID = args.GetUID()[1]; } else if (i.GetTag() == args.GetCollided()[1]) { _collidedThis = args.GetCollided()[1]; _collidedWith = args.GetCollided()[0]; _collidedThisUID = args.GetUID()[1]; _collidedWithUID = args.GetUID()[0]; } _overlap = args.GetOverlap(); _cNormal = args.GetCNormal(); } } //return whether the entity should kill itself return(false); }
public override bool OnNewCollision(ICollisionInput args) { bool rtnValue = base.OnNewCollision(args); // on collision with HBoundary change facing direction in order to move the opposite direction if (_collidedWith == "HBoundary" && _collidedThis == "HostileB" || _collidedWith == "HBoundary" && _collidedThis == "HostileT") { _facingDirectionX *= -1; } // on collision with another entity change facing direction in order to move the opposite direction if (_collidedWith == "HostileB" && _collidedThis == "HostileB") { _facingDirectionX *= -1; } // on collision with Floor change floorCollide flag to true if (_collidedWith == "Floor" && _collidedThis == "HostileB") { _floorCollide = true; } // on collisio with the base of the player and the top of this entity remove this entity from the scene if (_collidedWith == "PlayerB" && _collidedThis == "HostileT") { rtnValue = true; } // Reset Collided with and this to null _collidedWith = null; _collidedThis = null; // return rtnValue return(rtnValue); }
public void OnNewCollision(object sender, ICollisionInput args) { Guid entity1 = args.GetEntityKeys()[0]; Guid entity2 = args.GetEntityKeys()[1]; if (entity1 == _guid || entity2 == _guid) { _components.OfType <Move>().First().Velocity *= -1; } }
public void OnNewCollision(object sender, ICollisionInput args) { // Check if this entity is the one colliding if (_uid == args.GetUID()[0] || _uid == args.GetUID()[1]) { // If entity is not flagged for the removal from the scene using _killSelf if (!_killSelf) { //set _killSelf to the result of the collision method in the mind this._killSelf = _mind.OnNewCollision(args); } } }
/// <summary> /// Receives collision event data, used to drive ball bounce behaviour /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void OnNewCollision(object sender, ICollisionInput args) { // SET 'entity1' to the first collider entity Guid entity1 = args.GetEntityKeys()[0]; // SET 'entity2' to the second collider entity Guid entity2 = args.GetEntityKeys()[1]; // IF one of the collider entities is the ball if (entity1 == _guid || entity2 == _guid) { // Flip the balls direction _facingDirectionX *= -1; // Increment the balls speed by 2 _components.OfType <Move>().First().Speed = new Vector2(_components.OfType <Move>().First().Speed.X + 2, _components.OfType <Move>().First().Speed.Y); } }
public override bool OnNewCollision(ICollisionInput args) { bool rtnValue = base.OnNewCollision(args); // if the player and CoinGold collide if (_collidedWith == "PlayerB" && _collidedThis == "CoinGold" || _collidedWith == "PlayerT" && _collidedThis == "CoinGold") { // remove the CoinGold from the secene rtnValue = true; } // Reset Collided with and this to null _collidedWith = null; _collidedThis = null; // return rtnValue return(rtnValue); }
// Handles new collisions args passed by entity public override bool OnNewCollision(ICollisionInput args) { // Run super rtnValue = base.OnNewCollision(args); // Run floor collision logic FloorCollision(); // On collision with Hostile Bottom collider(HosileB), or Saw collider if (_collidedWith == "HostileB" && _collidedThis == "PlayerT" || _collidedWith == "HostileB" && _collidedThis == "PlayerB" || _collidedWith == "Saw" && _collidedThis == "PlayerT" || _collidedWith == "Saw" && _collidedThis == "PlayerB") { // Run hostile collision logic HostileCollision(); } // Run ceiling collision logic CeilingCollision(); // Run boundary collision logic BoundaryCollision(); // Run coin collision logic CoinCollision(); // Run relic saw collision RelicSawCollision(); // Reset Collided with and this to null _collidedWith = null; _collidedThis = null; _overlap.X = 0; _overlap.Y = 0; _cNormal.X = 0; _cNormal.Y = 0; // return rtnValue return(rtnValue); }
public void OnNewCollision(object sender, ICollisionInput args) { }
// Handles new collisions args passed by entity public override bool OnNewCollision(ICollisionInput args) { // Run super bool rtnValue = base.OnNewCollision(args); // on collision with Floor change floorCollide flag to true if (_collidedWith == "Floor" && _collidedThis == "PlayerB") { _floorCollide = true; } // on collision with Hostile Bottom collider(HosileB), or Saw collider if (_collidedWith == "HostileB" && _collidedThis == "PlayerT" || _collidedWith == "HostileB" && _collidedThis == "PlayerB" || _collidedWith == "Saw" && _collidedThis == "PlayerT" || _collidedWith == "Saw" && _collidedThis == "PlayerB") { // set return value to true to remove the player from the scene rtnValue = true; // reset floor collision flag statuses _inAir = true; _floorCollide = false; _onFloor = false; // lower players score value when having to respawn, cannot go below 0 if (_score > 0) { _score -= 200; } if (_score < 0) { _score = 0; } } // on collision between the ceiling and the player top collider if (_collidedWith == "Ceiling" && _collidedThis == "PlayerT") { // set jump value to 0 _jump = 0; } // on collision with the Bounday collider and the player while moving right if (_collidedWith == "Boundary" && _collidedThis == "PlayerM" && _facingDirectionX == 1) { // set rightCollide flag to true _rightCollide = true; } // on collision with the Bounday collider and the player while moving left if (_collidedWith == "Boundary" && _collidedThis == "PlayerM" && _facingDirectionX == -1) { // set leftCollide flag to true _leftCollide = true; } // on Collision with a CoinGold collider and the player if (_collidedWith == "CoinGold" && _collidedThis == "PlayerB" || _collidedWith == "CoinGold" && _collidedThis == "PlayerT") { // add points to the player score and out put score to the console _score += 100; Console.WriteLine("Player Score: " + _score); } // on Collision with a RelicSaw collider and the player if (_collidedWith == "RelicSaw" && _collidedThis == "PlayerB" || _collidedWith == "RelicSaw" && _collidedThis == "PlayerT") { // add points to the player score and out put score to the console _score += 500; Console.WriteLine("Player Score: " + _score); Console.WriteLine("Bone Saw Relic Aquired"); } // Reset Collided with and this to null _collidedWith = null; _collidedThis = null; // return rtnValue return(rtnValue); }