private void AddDirectAttackEnemy(int variety) { var dae = (PackedScene)ResourceLoader.Load("res://Components/DirectAttackEnemy.tscn"); DirectAttackEnemy daeInstance = (DirectAttackEnemy)dae.Instance(); daeInstance.SetVariety(variety); daeInstance.AddToGroup("enemies"); AddChild(daeInstance); }
public override void _Process(float delta) { switch (Phase) { // Slide down from the top. case MovementPhase.JustEntered: if (this.Position.y < 100) { this.Translate(positionDifference * moveSpeed * delta); moveSpeed -= 0.005f; } else { oldPosition = this.Position; moveSpeed = game.Boss1MoveSpeed; Phase = MovementPhase.MovingInCircle; } break; // Move in increasingly smaller circles. case MovementPhase.MovingInCircle: var newPoint = PointOnCircle(currentRadius, currentAngle, playerPosition); // FIXME - get this to work //LookAt(PointOnCircle(currentRadius, currentAngle - 10, playerPosition)); Translate((newPoint - oldPosition)); // Continue to move in a circle. currentAngle += movingClockwise ? moveSpeed * delta : moveSpeed * delta * -1; // And shrink the circle based on how long we've been in this phase. if (currentRadius > minimumRadiusLimit) { currentRadius -= shrinkSpeed * delta; } // Count up and then shoot fly's at the player! if (shootProjectileTimer < game.Boss1ShootStartingTimer) { shootProjectileTimer += delta; } else { if (shootProjectileLimit > game.Boss1ShootMinimumTime) { shootProjectileLimit -= 0.3f; } shootProjectileTimer = 0.0f; var aSprite = this.GetNode <AnimatedSprite>("Sprite"); aSprite.Play("attacking2"); aSprite.Playing = true; var dae = (PackedScene)ResourceLoader.Load("res://Components/DirectAttackEnemy.tscn"); DirectAttackEnemy daeInstance = (DirectAttackEnemy)dae.Instance(); this.GetParent().AddChild(daeInstance); var temp = this.Position; daeInstance.SetStartingPosition(temp); daeInstance.SetVariety(3); } oldPosition = newPoint; break; // Back up and change direction. case MovementPhase.Hit: currentRadius = originalRadius; newPoint = PointOnCircle(currentRadius, currentAngle, playerPosition); Translate((newPoint - oldPosition)); oldPosition = newPoint; movingClockwise = !movingClockwise; shootProjectileTimer = 0.0f; DamageToTake = 0; moveSpeed += 4.0f; Phase = MovementPhase.MovingInCircle; break; } if (HitCoolDownTimer > 0.0f) { HitCoolDownTimer -= delta; } else { if ((Area.GetOverlappingAreas().Count) > 0 && (DamageToTake > 0)) { Phase = MovementPhase.Hit; } } if (HitAnimationTimer > 0.0f) { var sprite = this.GetNode <AnimatedSprite>("Sprite"); sprite.SelfModulate = new Color(0.5f - HitAnimationTimer, 0.5f - HitAnimationTimer, 0.5f - HitAnimationTimer); HitAnimationTimer -= delta; } else { HitAnimationTimer = 0.0f; var sprite = this.GetNode <AnimatedSprite>("Sprite"); sprite.SelfModulate = new Color(1, 1, 1); } }