public override void run() { if (seen) { if ((target.position - actor.position).Length() < 700) { pathFindBehavior.run(); shotcooldown--; if (shotcooldown <= 0 && pathFindBehavior.canSee && actor.anim != actor.octoball) { // makes shots occur at .5 to 1.5 shotrate // Shoot actor.anim = actor.octoball; } } else { seen = false; } } else { if ((target.position - actor.position).Length() < 700 && actor.world.hasLineOfSight(actor.position, target.position, true)) { seen = true; } } }
public override void run() { if (seen) { if ((target.position - actor.position).Length() < Constants.SPIKON_BEHAVIOR_FOLLOWDIST) { pathFindBehavior.run(); } else { seen = false; } } else { if ((target.position - actor.position).Length() < Constants.SPIKON_BEHAVIOR_FOLLOWDIST && actor.world.hasLineOfSight(actor.position, target.position, true)) { seen = true; } } int beams = 30; float increment = (float)Math.PI * 2 / beams; World.ModifyTile mod = delegate(Tile tile) { tile.changeGlow(-0.009f, -0.009f, -0.009f); tile.val += 0.01f; if (tile.val > 1.0f) { tile.val = 1.0f; } }; // using the same vectors every time caused hard-edges / pixelation on tiles. // chooses a random starting point so using different rays. float offset = (float)actor.world.tileEngine.randGen.NextDouble() * 2 * (float)Math.PI; for (float x = 0; x < Math.PI * 2; x += increment) { Vector2 dir = new Vector2((float)Math.Cos(x + offset), (float)Math.Sin(x + offset)); // Tile under player was getting all rays applied to it, while each adjacent // tile got 1/4 of the rays applied to them (approx), so by pushing center to // the adjacent tile 1/4 of the time the tile under the player shouldn't be // disproportionately bright. if (x > Math.PI * 0.5f) { actor.world.castRay(actor.position + Tile.size * dir, dir, mod); } else { actor.world.castRay(actor.position, dir, mod); } } }
public override void run() { lockCooldown--; //Follow if (seen) { if (target != null && (target.position - actor.position).Length() < 300.0f) { pathFindBehavior.run(); if (lockCooldown <= 0) { determineWalkDirection(); } } acidPitCooldown--; chargeCooldown--; if (target != null && acidPitCooldown <= 0) { acidPitCooldown = acidPitDelay; // Fire acid pits Vector2 v = (target.position - (actor.position)); v.Normalize(); double angle = Math.Atan2((double)v.Y, (double)v.X); for (double i = -Math.PI / 2; i <= Math.PI / 2; i += Math.PI / 12) { double newAngle = angle + i; Vector2 offset = acidPitDist * new Vector2((float)Math.Cos(newAngle), (float)Math.Sin(newAngle)); actor.world.addActor(new DeathTileBall((actor.world as GameWorld), actor.position, new Vector2(0f, 0f), target.position + offset)); } } if (chargeCooldown <= 0) { // Charge attack Vector2 impulse = (target.position - actor.position); impulse.Normalize(); actor.addImpulse(impulse * 500); chargeCooldown = chargeDelay; } } else if (!seen && actor.world.hasLineOfSight(actor.position, target.position, false)) { seen = true; } else { seen = false; } }
public override void run() { if (seen) { if ((target.position - actor.position).Length() < 700) { if ((target.position - actor.position).Length() < 150) { actor.frictionCoefficient = .95f; } else { if (actor.frictionCoefficient == .95f) { actor.frictionCoefficient = Constants.WIZBLOB_FRICTION; } } pathFindBehavior.run(); shotcooldown--; if (shotcooldown <= 0) { // makes shots occur at .5 to 1.5 shotrate shotcooldown = shotrate; lockCooldown = 24; // Shoot actor.anim = ((WizBlob)actor).shootFireblobAnimation[currentDirection]; } } else { seen = false; } } else { if ((target.position - actor.position).Length() < 700 && actor.world.hasLineOfSight(actor.position, target.position, true)) { seen = true; } } // Change direction of floating animation if (lockCooldown <= 0) { determineDirectionAnimation(); } else { lockCooldown--; } }
public override void run() { if (!added) { (actor.world as GameWorld).blobCount++; added = true; } if (seen) { if ((target.position - actor.position).Length() < Constants.BLOB_BEHAVIOR_FOLLOWDIST) { pathFindBehavior.run(); if (oldDamage != (actor as GigaBlob).life.life) { bool addedActor = false; oldDamage = (actor as GigaBlob).life.life; Actor a = null; if ((actor.world as GameWorld).blobCount < Constants.MAX_WORLD_BLOBS) { while (a == null || addedActor == false) { Vector2 blobpos = 100 * (new Vector2((float)actor.world.tileEngine.randGen.NextDouble() - .5f, (float)actor.world.tileEngine.randGen.NextDouble() - .5f)); a = actor.world.actorFactory.createActor(actor.world.actorFactory.getActorId("Blob"), actor.position + blobpos, blobpos, (actor as GigaBlob).color); addedActor = actor.world.addActor(a); } } if (a != null) { actor.world.tileEngine.audioComponent.playSound(a.audioSet[actor.world.tileEngine.randGen.Next(4, 6)], false); } } } else { seen = false; } } else { if ((target.position - actor.position).Length() < Constants.BLOB_BEHAVIOR_FOLLOWDIST && actor.world.hasLineOfSight(actor.position, target.position, true)) { seen = true; actor.anim = new Animation(0, 3, 8f + (float)actor.world.tileEngine.randGen.NextDouble(), true); } } }
public override void run() { if (seen) { // Within attack distance if ((target.position - charger.position).Length() < Constants.CHARGER_BEHAVIOR_ATTACKDIST) { dmgDone = false; charger.anim = chargerAttackAnim; } // Within follow distance else if ((target.position - charger.position).Length() < Constants.CHARGER_BEHAVIOR_FOLLOWDIST) { charger.anim = chargerNorm; pathFindBehavior.run(); cloneCooldown--; // If max chargers hasn't been met, fork if (cloneCooldown <= 0.0f && ChargerBehavior.current_chargers < Constants.CHARGER_MAX_GLOBAL_NUMBER) { Charger c = (Charger)charger.world.actorFactory.createActor(charger.world.actorFactory.getActorId("Charger"), charger.position, null); if (c != null) { ChargerBehavior.current_chargers++; charger.world.addActor(c); } cloneCooldown = Constants.CHARGER_CLONE_RATE; } } else { seen = false; } } else { if ((target.position - charger.position).Length() < Constants.CHARGER_BEHAVIOR_FOLLOWDIST && charger.world.hasLineOfSight(charger.position, target.position, true)) { seen = true; } } }
public override void run() { // GLOWING int beams = 300; float increment = (float)Math.PI * 2 / beams; if (Vector2.Distance(actor.position, (actor.world as GameWorld).player.position) < 700) { for (float x = 0; x < Math.PI * 2; x += increment) { actor.world.castRay(actor.position, new Vector2((float)Math.Cos(x), (float)Math.Sin(x)), blobColor[colorSwap % 6]); } } // Control how fast the color changes if (count % 20 == 0) { colorSwap++; } count++; // Do the same pathfinding as blob if (seen) { if ((target.position - actor.position).Length() < Constants.BLOB_BEHAVIOR_FOLLOWDIST) { pathFindBehavior.run(); } else { seen = false; } } else { if ((target.position - actor.position).Length() < Constants.BLOB_BEHAVIOR_FOLLOWDIST && actor.world.hasLineOfSight(actor.position, target.position, true)) { seen = true; actor.anim = new Animation(0, 3, 8f + (float)actor.world.tileEngine.randGen.NextDouble(), true); } } }
public override void run() { if (!added) { (actor.world as GameWorld).blobCount++; added = true; } if (seen) { // Within follow distance if ((target.position - actor.position).Length() < Constants.BLOB_BEHAVIOR_FOLLOWDIST) { pathFindBehavior.run(); if (fork) { shotcooldown--; if (shotcooldown <= 0 && pathFindBehavior.canSee && (actor.world as GameWorld).blobCount < Constants.MAX_WORLD_BLOBS) { // makes shots occur at .5 to 1.5 shotrate shotcooldown = shotrate + (float)(actor.world.tileEngine.randGen.NextDouble() * shotrate); // Shoot shootBehavior.run(); } } } else { seen = false; } } else { if ((target.position - actor.position).Length() < Constants.BLOB_BEHAVIOR_FOLLOWDIST && actor.world.hasLineOfSight(actor.position, target.position, true)) { seen = true; actor.anim = new Animation(0, 3, 8f + (float)actor.world.tileEngine.randGen.NextDouble(), true); } } }
private Vector2 chargeForce; // Force to use while charging public MrHammerBehavior(Actor actor, Actor target) : base(actor) { this.actor = actor; this.target = target; this.pathFindBehavior = new PathfindBehavior(actor, target, Constants.MRHAMMER_PATHFIND); this.shotCooldown = 0; this.lockCooldown = 0; this.chargeCount = 480; this.chargeTimeOut = 0; this.isCharging = false; // Define animation actions // Hammer attack Animation.Action beginSmash = (frame) => { actor.world.tileEngine.audioComponent.playSound(actor.audioSet[0], false); }; Animation.Action smash = (frame) => { //Spawn explosions // Outer Outer Ring for (int i = 0; i < 30; i++) { Vector2 rotated = Vector2.Transform(new Vector2(0f, 4f), Matrix.CreateRotationZ(MathHelper.ToRadians(12 * i))); actor.world.addActor(new Explosion(actor.world as GameWorld, actor.position + rotated * (actor.size / 3 + 5), rotated * 4f)); } // Outer Ring for (int i = 0; i < 18; i++) { Vector2 rotated = Vector2.Transform(new Vector2(0f, 3f), Matrix.CreateRotationZ(MathHelper.ToRadians(20 * i))); actor.world.addActor(new Explosion(actor.world as GameWorld, actor.position + rotated * (actor.size / 3 + 5), rotated * 4f)); } // Inner Ring for (int i = 0; i < 9; i++) { Vector2 rotated = Vector2.Transform(new Vector2(0f, 2f), Matrix.CreateRotationZ(MathHelper.ToRadians(40 * i))); actor.world.addActor(new Explosion(actor.world as GameWorld, actor.position + rotated * (actor.size / 3 + 5), rotated * 4f)); } //Determine which actors are hit foreach (Actor a in actor.getConeAround(100, new Vector2(0, 0), 360, null)) { ILife liveAct = a as ILife; Vector2 impulse = new Vector2(); impulse = a.position - this.actor.position; impulse.Normalize(); impulse *= Constants.MRHAMMER_KNOCKBACK; if (a.collisionimmunitymask != Actor.ActorCategory.enemy) { if (liveAct != null) { liveAct.life.life -= Constants.MRHAMMER_HAMMER_DAMAGE; } } a.addImpulse(impulse); } // Play explosion sound AudioSet temp = actor.world.tileEngine.resourceComponent.getAudioSet("020_FirePillar"); actor.world.tileEngine.audioComponent.playSound(temp[0], false); }; // Charge attack Animation.Action castStunWarning = frame => { actor.world.addActor(new StunWarning(actor.world as GameWorld, target.position, new Vector2(0, 0))); }; Animation.Action castCircle = frame => { // Ring of Icy Stun int randomHole = (actor.world as GameWorld).tileEngine.randGen.Next(0, 9); for (int i = 0; i < 9; i++) { // Spawn ice ball unless it's the one being left out Vector2 rotated = Vector2.Transform(new Vector2(0f, 2f), Matrix.CreateRotationZ(MathHelper.ToRadians(40 * i))); if (i != randomHole) { actor.world.addActor(new MagicPrimary(actor.world as GameWorld, target.position + rotated * (actor.size / 3 + 8), rotated * 4f)); } } // Initiate charge pathFindBehavior.run(); isCharging = true; chargeForce = actor.force / 2; }; // Add actions to the hammer animation int animNum = 0; foreach (Animation a in ((MrHammer)actor).smashAnimation) { switch (animNum) { case 0: a.addFrameAct(163, smash); break; case 1: a.addFrameAct(85, smash); break; case 2: a.addFrameAct(124, smash); break; case 3: a.addFrameAct(46, smash); break; } a.addBeginAct(beginSmash); animNum++; } // Add actions to the casting animation foreach (Animation a in ((MrHammer)actor).castCircleAnimation) { a.addBeginAct(castStunWarning); a.addEndAct(castCircle); } }
public override void run() { shotCooldown--; chargeCount--; chargeTimeOut--; if (seen && (actor.world as GameWorld).hammerTriggered) { // Within follow distance if ((target.position - actor.position).Length() < Constants.MRHAMMER_FOLLOWDIST && !isCharging) { // Within charge distance if ((target.position - actor.position).Length() < Constants.MRHAMMER_CHARGEDIST && shotCooldown <= 0) { // Within melee distance if ((target.position - actor.position).Length() < Constants.MRHAMMER_ATTACKDIST && shotCooldown <= 0) { // Hammer attack actor.anim = ((MrHammer)actor).smashAnimation[currentDirection]; shotCooldown = 40; lockCooldown = 40; actor.world.tileEngine.audioComponent.playSound(actor.audioSet[0], false); ((MrHammer)actor).mass = float.MaxValue; } else { // Spawn stun circle and charge if (chargeCount <= 0 && (target.position - actor.position).Length() > Constants.MRHAMMER_MIN_CHARGE) { actor.anim = ((MrHammer)actor).castCircleAnimation[currentDirection]; shotCooldown = 25; lockCooldown = 25; chargeCount = Constants.MRHAMMER_CHARGE_COUNT; chargeTimeOut = Constants.MRHAMMER_CHARGE_TIMEOUT; } else { pathFindBehavior.run(); } } } else { pathFindBehavior.run(); } } else if (isCharging) { // Check speed of Mr Hammer and stop him from charging if (((MrHammer)actor).velocity.Length() < .4f || chargeTimeOut <= 0) { // Restore normal friction isCharging = false; ((MrHammer)actor).frictionCoefficient = Constants.MRHAMMER_FRICTION; } else { // Lower friction and apply force for charge ((MrHammer)actor).frictionCoefficient = .0001f; actor.force = chargeForce; } } else { seen = false; } } else { if ((target.position - actor.position).Length() < Constants.MRHAMMER_FOLLOWDIST && actor.world.hasLineOfSight(actor.position, target.position, true)) { seen = true; } } // Reset Mr Hammer's mass to normal and determine walking animation if (lockCooldown <= 0) { if (((MrHammer)actor).mass == float.MaxValue) { ((MrHammer)actor).mass = Constants.MRHAMMER_MASS; } determineDirectionAnimation(); } else { lockCooldown--; } //Glow int beams = 300; float increment = (float)Math.PI * 2 / beams; for (float x = 0; x < Math.PI * 2; x += increment) { actor.world.castRay(((MrHammer)actor).position, new Vector2((float)Math.Cos(x), (float)Math.Sin(x)), new Color(.3f, 0, 0)); } }