public Drone(float x, float y, int hits) { X = x; Y = y; mySprite = new Spritemap<string>(Assets.GFX_DRONE, 32, 38); mySprite.CenterOrigin(); mySprite.Add("open", new int[] { 0, 1, 2, 3, 4 }, new float[] { 6f, 6f, 6f, 6f, 24f }); mySprite.Anim("open").NoRepeat(); mySprite.Anim("open").OnComplete = this.PlayShineAnim; mySprite.Add("shine", new int[] { 5, 6, 7, 8, 9, 10, 11 }, new float[] { 3f }); mySprite.Anim("shine").NoRepeat(); mySprite.Anim("shine").OnComplete = this.ChargeUpLaser; mySprite.Add("charge", new int[] { 12, 13 }, new float[] { 8f }); mySprite.Add("fire", new int[] { 14, 15 }, new float[] { 1f }); mySprite.Add("dead", new int[] { 16, 17, 18, 19, 20 }, new float[] { 10f, 4f, 4f, 4f, 4f }); mySprite.Anim("dead").NoRepeat(); mySprite.Anim("dead").OnComplete = this.StopShaking; mySprite.Play("open"); mySprite.FlippedX = Rand.Bool; Image ghostShadow = new Image(Assets.GFX_SHADOW); ghostShadow.CenterOrigin(); ghostShadow.OriginY -= 25; ghostShadow.Alpha = 0.5f; AddGraphic(ghostShadow); AddGraphic(mySprite); MaxChargeTime = Rand.Float(60.0f, 240.0f); AddCollider(new BoxCollider(32, 38, 2)); Collider.CenterOrigin(); }
public Enemy_Soldier(float x, float y) : base(x, y) { Layer = -500; this.MaxHP = scene.stage.MaxHP / 4; this.CurrentHP = this.MaxHP; SetHitbox(33, 40, ColliderTags.EnemyUnit); Hitbox.SetPosition(28, 27); spritemap.Add(Animation.Death1, scene.GetAnimationString(0, 21), 4).NoRepeat(); spritemap.Add(Animation.Death2, "22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 31", 4).NoRepeat(); spritemap.Add(Animation.Death3, scene.GetAnimationString(33, 41), 4).NoRepeat(); spritemap.Add(Animation.Death4, scene.GetAnimationString(42, 52), 4).NoRepeat(); spritemap.Add(Animation.Death5, scene.GetAnimationString(53, 67), 4).NoRepeat(); spritemap.Add(Animation.Death6, scene.GetAnimationString(68, 80), 4).NoRepeat(); spritemap.Add(Animation.Death7, scene.GetAnimationString(81, 95), 4).NoRepeat(); spritemap.Add(Animation.Throw, scene.GetAnimationString(115, 129), 4).NoRepeat(); spritemap.Add(Animation.Idle, scene.GetAnimationString(96, 102), 5); spritemap.Add(Animation.Run, scene.GetAnimationString(103, 114), 4); spritemap.Play(Animation.Run); AddGraphic(spritemap); scene.Add(this); scene.enemyList.Add(this); runtime = (int)spritemap.Anim(Animation.Run).TotalDuration *scene.random.Next(3, 12); }
public override void Update() { cooldown--; if (cooldown == 0 && spritemap.CurrentAnim == Animation.Idle) { spritemap.Play(Animation.Shoot); sound.Play(); cooldown = (int)spritemap.Anim(Animation.Shoot).TotalDuration; scene.Add(new Explosions(scene.random.Next(50, 801), scene.random.Next(520, 750), Explosions.ExplosionType.shell_normal, 60, false)); } else if (cooldown == 0 && spritemap.CurrentAnim == Animation.Shoot) { spritemap.Play(Animation.Idle); cooldown = scene.random.Next(60 * 2, 60 * 3); } base.Update(); }
public override void Update() { cooldown--; if (cooldown == 0) { if (spritemap.CurrentAnim == Animation.Idle) { spritemap.Play(Animation.Shoot); sound.Play(); cooldown = (int)spritemap.Anim(Animation.Shoot).TotalDuration; } else if (spritemap.CurrentAnim == Animation.Shoot) { spritemap.Play(Animation.Idle); cooldown = scene.random.Next(3 * 60, 5 * 60); } } base.Update(); }
public Drone(float x, float y, int hits) { X = x; Y = y; mySprite = new Spritemap <string>(Assets.GFX_DRONE, 32, 38); mySprite.CenterOrigin(); mySprite.Add("open", new int[] { 0, 1, 2, 3, 4 }, new float[] { 6f, 6f, 6f, 6f, 24f }); mySprite.Anim("open").NoRepeat(); mySprite.Anim("open").OnComplete = this.PlayShineAnim; mySprite.Add("shine", new int[] { 5, 6, 7, 8, 9, 10, 11 }, new float[] { 3f }); mySprite.Anim("shine").NoRepeat(); mySprite.Anim("shine").OnComplete = this.ChargeUpLaser; mySprite.Add("charge", new int[] { 12, 13 }, new float[] { 8f }); mySprite.Add("fire", new int[] { 14, 15 }, new float[] { 1f }); mySprite.Add("dead", new int[] { 16, 17, 18, 19, 20 }, new float[] { 10f, 4f, 4f, 4f, 4f }); mySprite.Anim("dead").NoRepeat(); mySprite.Anim("dead").OnComplete = this.StopShaking; mySprite.Play("open"); mySprite.FlippedX = Rand.Bool; Image ghostShadow = new Image(Assets.GFX_SHADOW); ghostShadow.CenterOrigin(); ghostShadow.OriginY -= 25; ghostShadow.Alpha = 0.5f; AddGraphic(ghostShadow); AddGraphic(mySprite); MaxChargeTime = Rand.Float(60.0f, 240.0f); AddCollider(new BoxCollider(32, 38, 2)); Collider.CenterOrigin(); }
public override void Update() { base.Update(); if (CurrentActivity == 0) { //nada } if (CurrentActivity == 1) { // charging laser if (ChargeTime < MaxChargeTime) { ChargeTime++; //update anim mySprite.Anim("charge").Speed((ChargeTime / (MaxChargeTime)) * 4); // drift towards player Vector2 VectorToPlayer = new Vector2(Global.theGhost.X - X, Global.theGhost.Y - Y); if (VectorToPlayer.Length > 500) { // teleport to player X = Rand.Float(Global.theGhost.X - 400, Global.theGhost.X + 400); Y = Rand.Float(Global.theGhost.Y - 400, Global.theGhost.Y + 400); } VectorToPlayer.Normalize(); X += VectorToPlayer.X * 0.5f; Y += VectorToPlayer.Y * 0.5f; } else { FireLaser(); } } if (CurrentActivity == 2) { // firing laser if (CurrentFireTime < MaxFireTime) { CurrentFireTime++; // create laser particles, aim at player, then tween angle displacement slowly float ProgressThroughFire = CurrentFireTime / MaxFireTime; Vector2 VectorToPlayer = new Vector2(TargetPos.X - X, TargetPos.Y - Y); float AngleToPlayer = (float)Math.Atan2(VectorToPlayer.Y, VectorToPlayer.X); AngleToPlayer *= (float)(180.0 / Math.PI); if (FireDir) { AngleToPlayer += (-15) + (ProgressThroughFire * 30); } else { AngleToPlayer -= (-15) + (ProgressThroughFire * 30); } AngleToPlayer *= (float)(Math.PI / 180.0); Laser newLaser = new Laser(X, Y, (float)Math.Cos(AngleToPlayer) * 7, (float)Math.Sin(AngleToPlayer) * 7); this.Scene.Add(newLaser); } else { ChargeUpLaser(); } } if (CurrentActivity == 3) { RemoveColliders(Collider); mySprite.Play("dead"); return; } if (Collider.Overlap(X, Y, 1)) { // Hit by star, die // spawn music note & particles Hits--; if (Hits <= 0) { this.Scene.Add(new Note(X, Y)); int maxSpawn = 1 + ((int)Global.Score / 200); for (int i = 0; i < maxSpawn; i++) { this.Scene.Add(new Drone(Rand.Float(Global.theGhost.X - 400, Global.theGhost.X + 400), Rand.Float(Global.theGhost.Y - 400, Global.theGhost.Y + 400), maxSpawn * 2)); } CurrentActivity = 3; mySprite.OriginY -= 14; Layer = 10; mySprite.ShakeX = 3; Sound bip = new Sound(Assets.SFX_HURT); bip.Volume = 0.9f; bip.Pitch = Rand.Float(0.8f, 1.2f); bip.Play(); } } }
public override void Update() { if (this.Timer % 20 == 0) { InfoText.String = "Cost: " + FormatNumber(this.cost) + "\nDeals Player damage " + this.magnitude + " times per second" + "\nLevel: " + (level > 0 ? "" + level : "locked") + "\nDuration: " + this.duration / 60 + "\nCooldown: " + ((cooldown > 0) ? (cooldown / 60 / 60 + "m") + (cooldown / 60 % 60) + "s" : "0") + "\nTotal Cooldown: " + (TotalCooldown / 60 / 60 + "m") + (TotalCooldown / 60 % 60) + "\n\nTo use press 2."; //Console.WriteLine("CD: " + this.cooldown); } if (cooldown > 0) { cooldown--; } if (Input.KeyPressed(Key.Num2)) { if (cooldown == 0 && level > 0) { //cooldown = TotalCooldown; activated = true; } } if (cooldown == 0) { runtime--; if (spritemap.CurrentAnim == Animation.Dead && level > 0) { spritemap.Play(Animation.Activating); runtime = (int)spritemap.Anim(Animation.Activating).TotalDuration; } if (spritemap.CurrentAnim == Animation.Activating && runtime == 0) { spritemap.Play(Animation.Idle); } if (spritemap.CurrentAnim == Animation.Idle && activated) { Shooting.Play(); spritemap.Play(Animation.Shoot); cooldown = TotalCooldown; } } else { if (activated) { if (scene.enemyList.Count != 0) { scene.enemyList[scene.random.Next(0, scene.enemyList.Count)].GetDamage(scene.player.GetPlayerAttackDamageByLevel(scene.player.level) * magnitude / 60); } duration--; } if (duration <= 0) { Shooting.Stop(); dying.Play(); spritemap.Play(Animation.Deactivating); activated = false; this.duration = 30 * 60; } } base.Update(); }