protected override void LoadContent() { base.LoadContent(); //Wichtig, base muss vorher aufgerufen werden, //damit die GameObject-Klasse das Model lädt #region Helicopter animation hack modelAnimationPart = this.Model.GetMesh("Rotor"); if (modelAnimationPart != null) { FxSound = game.Sounds.CreateSound("Heli"); FxSound.Loop = true; FxSound.Parent = this; modelAnimationPart.PlayRotationAnimation(); } #endregion #region Init WeaponManager and add Weapons if (weapons == null) { weapons = new WeaponManager(game, Model, WeaponHolderType.Enemy); foreach (string weapon in typeDesc.Weapons) { weapons.AddWeapon((WeaponType)Enum.Parse(typeof(WeaponType), weapon, true)); // weapons.SwitchUp(false); } AI.AddState(new AI2AttackPlayer(weapons, 2)); } #endregion }
public TowerAI(ICanyonShooterGame game, EnemyDescription desc) : base(game, "Enemy-TankAI") { this.game = game; id = createdTanks++; // Set the tank model SetModel(desc.Model); LocalScale = new Vector3(4f, 4f, 4f); LocalPosition = desc.RelativeSpawnLocation; dir = new Vector3(0, 0, -1); // Physics Config ConnectedToXpa = true; this.Static = true; ContactGroup = ContactGroup.Enemies; LocalPosition = desc.RelativeSpawnLocation; // Initialize AI-States of TowerAI AIStates = new AIStateMachine(game, this); AIStates.AddState(new TowerAIObserving(game.World.Players[0])); AIStates.AddState(new TowerAIAttackPlayer(game.World.Players[0])); AIStates.DebugAI = false; }
/// <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); } } }
void Awake() { Behaviour = new AIStateMachine(this); m_state = new AIStateZombie(this); Behaviour.AddState(m_state); Behaviour.ChangeState(m_state); }
public override void Enter(AIStateMachine stateMachine, Action SuccessCallback, Action FailureCallback) { base.Enter(stateMachine, SuccessCallback, FailureCallback); target = GameObject.Find("Store").transform; moveState = stateMachine.AddState <MoveState>(); moveState.SetTarget(target); stateMachine.OnComplete += Success; }
protected override void Begin() { Behaviour = new AIStateMachine(this); AIStateCompanion state = new AIStateCompanion(this); state.target = followTarget; state.minRange = minFollowRange; state.maxRange = maxFollowRange; state.chaseRange = chaseRange; state.attackRange = attackRange; Behaviour.AddState(state); Behaviour.ChangeState(state); }
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); } }