/// <param name="desc">The description data (i.e. healthpoints, strength).</param> public KamidroneAI(ICanyonShooterGame game, EnemyDescription desc) : base(game, "Enemy-KamidroneAI") { EnemyNr = EnemiesCreated++; this.game = game; // Physics Config ConnectedToXpa = true; ContactGroup = ContactGroup.Enemies; InfluencedByGravity = false; InfoMessage(string.Format("Created at: {0}", desc.RelativeSpawnLocation)); currentHitpoints = desc.MaxHitpoints; LocalPosition = desc.RelativeSpawnLocation; // System typeDesc = game.Content.Load <EnemyTypeDescription>("Content\\Enemies\\" + desc.Type); SetModel(typeDesc.Model); // Initiate AI-System: AI = new AIStateMachine(game, this); AI.DebugAI = false; // Add States to Machine: AI.AddState(new Patrol()); // Init-State AI.AddState(new FlyToWaypoint(desc.SegmentId)); AI.AddState(new FlyToPlayer()); // SquadronFormations if (desc.SquadronCount > 1) //Enemy-Squadron erzeugen. { // Create EnemyFormation and join it EnemyFormation formation = new EnemyFormation(game, LocalPosition, desc.SegmentId, desc.Speed, typeDesc.Formation); JoinFormation(formation); desc.SquadronCount = 1; int count = typeDesc.Formation.Count - 1; // dieser enemy hat sich bereits selbst hinzugefügt. for (int i = 0; i < count; i++) { // Versezte den nächsten Enemy in Richtung des Canyons Vector3 canyonDirection = game.World.Level.Cache[desc.SegmentId].ADir; canyonDirection.Normalize(); desc.RelativeSpawnLocation = desc.RelativeSpawnLocation + canyonDirection * 100; // Nächsten Enemy im Squadron erzeugen: KamidroneAI enemyForFormation = new KamidroneAI(game, desc); //enemyFollowing.FollowEnemy(this); // follow ME! enemyForFormation.JoinFormation(formation); game.World.AddObject(enemyForFormation); } } }
public void UpdateFormation(EnemyFormation formation) { if (formation == null) { return; } LocalPosition = formation.GetPosition(EnemyNr); LocalRotation = formation.GetRotation(EnemyNr); }
public void JoinFormation(EnemyFormation formation) { if (formation == null) { return; } AI.AddState(new FlyInFormation(formation)); if (formation.RegisterEnemy(EnemyNr)) { IsInFormation = true; } else { IsInFormation = false; } }
/// <param name="desc">The description data (i.e. healthpoints, strength).</param> public EnemyAI2Flo(ICanyonShooterGame game, EnemyDescription desc) : base(game, "Enemy-AI2") { EnemyNr = EnemiesCreated++; this.game = game; // Physics Config ConnectedToXpa = true; ContactGroup = ContactGroup.Enemies; InfluencedByGravity = false; InfoMessage(string.Format("Created at: {0}", desc.RelativeSpawnLocation)); currentHitpoints = desc.MaxHitpoints; LocalPosition = desc.RelativeSpawnLocation; // System typeDesc = game.Content.Load <EnemyTypeDescription>("Content\\Enemies\\" + desc.Type); currentHitpoints = typeDesc.MaxHitpoints; SetModel(typeDesc.Model); // Initiate AI-System: AI = new AIStateMachine(game, this); AI.DebugAI = false; // Add States to Machine: AI.AddState(new AI2Patrol()); // Init-State AI.AddState(new AI2FlyToWaypoint(desc.SegmentId)); AI.AddState(new AI2FlyToPlayer()); // SquadronFormations if (desc.SquadronCount > 1) //Enemy-Squadron erzeugen. { // Sample Formation //// TODO: Move this to the Description later! //List<Vector3> formationPositions = new List<Vector3>(); //formationPositions.Add(new Vector3(0,0,0)); //formationPositions.Add(new Vector3(30,0,0)); //formationPositions.Add(new Vector3(-30,0,0)); //formationPositions.Add(new Vector3(0,0,30)); // Create EnemyFormation and join it EnemyFormation formation = new EnemyFormation(game, LocalPosition, desc.SegmentId, desc.Speed, typeDesc.Formation); JoinFormation(formation); desc.SquadronCount = 1; int count = typeDesc.Formation.Count - 1; // dieser enemy hat sich bereits selbst hinzugefügt. for (int i = 0; i < count; i++) { // Versezte den nächsten Enemy in Richtung des Canyons Vector3 canyonDirection = game.World.Level.Cache[desc.SegmentId].ADir; canyonDirection.Normalize(); desc.RelativeSpawnLocation = desc.RelativeSpawnLocation + canyonDirection * 100; // Nächsten Enemy im Squadron erzeugen: EnemyAI2Flo enemyForFormation = new EnemyAI2Flo(game, desc); //enemyFollowing.FollowEnemy(this); // follow ME! enemyForFormation.JoinFormation(formation); game.World.AddObject(enemyForFormation); } } itemChance = desc.ItemChance; itemList = desc.ItemList; if (game.Graphics.ShadowMappingSupported) { game.World.Sky.Sunlight.ShadowMapLow.Scene.AddDrawable(this); game.World.Sky.Sunlight.ShadowMapHigh.Scene.AddDrawable(this); } }