public void DropTrigger() { Body.mIgnoresGravity = false; Body.mIsKinematic = false; CollisionManager.RemoveObjectFromAreas(trigger); trigger = null; }
public override void OnGainTrigger(Entity player) { base.OnGainTrigger(player); sightbox = new Sightbox(owner, new CustomAABB(owner.Position, Vector2.one * auraRadius, Vector2.zero)); sightbox.UpdatePosition(); Apply(player); }
public static void SightCollision(Sightbox obj1, PhysicsBody obj2) { if (obj1.mAABB.Overlaps(obj2.mAABB) && !obj1.mEntitiesInSight.Contains(obj2.mEntity)) { obj1.mEntitiesInSight.Add(obj2.mEntity); } }
public override void Spawn(Vector2 spawnPoint) { base.Spawn(spawnPoint); Renderer.SetSprite(Resources.Load <Sprite>("Sprites/FallingRock") as Sprite); //Vector2i tilePos = mMap.GetMapTileAtPoint(pos); sizeDown = Map.CheckEmptySpacesBelow(Map.GetMapTileAtPoint(spawnPoint)); if (sizeDown == 0) { mToRemove = true; } trigger = new Sightbox(this, new CustomAABB(Position, new Vector2(MapManager.cTileSize / 2, (sizeDown * MapManager.cTileSize / 2)), new Vector2(0, -(sizeDown * MapManager.cTileSize / 2) - (MapManager.cTileSize / 2)))); trigger.UpdatePosition(); if (sizeDown <= 0) { isTriggered = true; } }
public Enemy(EnemyPrototype proto) : base(proto) { prototype = proto; ExpValue = proto.expValue; mEnemyType = prototype.enemyType; mMovingSpeed = proto.movementSpeed; jumpHeight = proto.jumpHeight; mCollidesWith.Add(EntityType.Player); mCollidesWith.Add(EntityType.Obstacle); mCollidesWith.Add(EntityType.Platform); Body.mIgnoresGravity = proto.ignoreGravity; HurtBox = new Hurtbox(this, new CustomAABB(Position, prototype.bodySize, new Vector2(0, prototype.bodySize.y))); HurtBox.UpdatePosition(); sight = new Sightbox(this, new CustomAABB(Position, new Vector2(prototype.sightRange, prototype.sightRange), new Vector2(0, prototype.bodySize.y))); sight.UpdatePosition(); ScaleStatsToLevel(); mHealth = new Health(this, prototype.health); mAttackManager = new AttackManager(this); //Debug.Log("Melee Attacks: " + prototype.meleeAttacks.Count); foreach (MeleeAttackPrototype meleeAttack in prototype.meleeAttacks) { MeleeAttack melee = new MeleeAttack(this, meleeAttack); mAttackManager.meleeAttacks.Add(melee); //Debug.Log("Adding Slime melee attack"); } foreach (RangedAttackPrototype rangedAttack in prototype.rangedAttacks) { mAttackManager.rangedAttacks.Add(new RangedAttack(this, rangedAttack)); } }