//========================================================================================= /// <summary> /// Constructor. Creates the behaviour. A valid control character MUST be passed in. /// </summary> /// <param name="i"> /// Importance of the behaviour to this character. Behaviour scores are scaled by this. /// </param> /// <param name="c"> Character the behaviour is controlling. </param> /// <param name="b"> Behaviour set the AIBehaviour belongs to. </param> //========================================================================================= public AI_Decluster( float i , Character c , AIBehaviourSet b ) : base(i , c , b) { // Get and save the character type: m_character_type = Type.GetType("NinjaGame.Character"); }
//========================================================================================= /// <summary> /// Constructor. Creates the behaviour. A valid control character MUST be passed in. /// </summary> /// <param name="i"> /// Importance of the behaviour to this character. Behaviour scores are scaled by this. /// </param> /// <param name="c"> Character the behaviour is controlling. </param> /// <param name="b"> Behaviour set the AIBehaviour belongs to. </param> //========================================================================================= public AI_Pursue_Jump_Gap( float i , Character c , AIBehaviourSet b ) : base(i , c , b) { // Get the ninja type: m_ninja_type = Type.GetType("NinjaGame.Ninja"); }
//========================================================================================= /// <summary> /// Constructor. Creates the behaviour. A valid control character MUST be passed in. /// </summary> /// <param name="i"> /// Importance of the behaviour to this character. Behaviour scores are scaled by this. /// </param> /// <param name="c"> Character the behaviour is controlling. </param> /// <param name="b"> Behaviour set the AIBehaviour belongs to. </param> //========================================================================================= public AI_Rest( float i , Character c , AIBehaviourSet b ) : base(i , c , b) { // Redo the time multiplier for increasing rest need: m_time_multiply = ( 1.0f - m_rest_randomness ) + (float) Core.Random.NextDouble() * m_rest_randomness; }
//========================================================================================= /// <summary> /// Constructor. Creates the behaviour. A valid control character MUST be passed in. /// </summary> /// <param name="i"> /// Importance of the behaviour to this character. Behaviour scores are scaled by this. /// </param> /// <param name="c"> Character the behaviour is controlling. </param> /// <param name="b"> Behaviour set the AIBehaviour belongs to. </param> //========================================================================================= public AI_Throw_Shuriken( float i , Character c , AIBehaviourSet b ) : base(i , c , b) { // Get and save this character types: m_ninja_type = Type.GetType("NinjaGame.Ninja"); // Complain if neither can be found: #if DEBUG if ( m_ninja_type == null ) throw new Exception("No ninja type exists"); #endif }
//========================================================================================= /// <summary> /// Constructor. Creates the behaviour. A valid control character MUST be passed in. /// </summary> /// <param name="i"> /// Importance of the behaviour to this character. Behaviour scores are scaled by this. /// </param> /// <param name="c"> Character the behaviour is controlling. </param> /// <param name="b"> Behaviour set the AIBehaviour belongs to. </param> //========================================================================================= public AI_Patrol( float i , Character c , AIBehaviourSet b ) : base(i , c , b) { // Pick a random direction to patrol in: m_patrol_right = ( new Random().Next() & 1 ) == 1; // Give either left or right a big score to start off with: if ( m_patrol_right ) { m_score_right = 1000; } else { m_score_left = 1000; } }
//========================================================================================= /// <summary> /// Constructor. Creates the behaviour. A valid control character MUST be passed in. /// </summary> /// <param name="importance"> /// Importance of the behaviour to this character. Behaviour scores are scaled by this. /// </param> /// <param name="control_character"> Character the behaviour is controlling. </param> /// <param name="behaviour_set"> Behaviour set the AIBehaviour belongs to. </param> //========================================================================================= public AIBehaviour( float importance , Character control_character , AIBehaviourSet behaviour_set ) { // On windows debug if the control character is null then throw an exception: #if WINDOWS_DEBUG if ( control_character == null ) { throw new Exception("AIBehaviour must have a valid control character !!!"); } #endif // On windows debug if the behaviour set is null then throw an exception: #if WINDOWS_DEBUG if ( behaviour_set == null ) { throw new Exception("AIBehaviour must be part of a valid AIBeaviourSet!!!"); } #endif // Save importance: m_importance = importance; // Save the control character: m_control_character = control_character; // Save behaviour set: m_behaviour_set = behaviour_set; // Save the name of the behaviour: m_name = GetType().Name; }
//========================================================================================= /// <summary> /// Constructor. Creates the behaviour. A valid control character MUST be passed in. /// </summary> /// <param name="i"> /// Importance of the behaviour to this character. Behaviour scores are scaled by this. /// </param> /// <param name="c"> Character the behaviour is controlling. </param> /// <param name="b"> Behaviour set the AIBehaviour belongs to. </param> //========================================================================================= public AI_Turn_Around( float i , Character c , AIBehaviourSet b ) : base(i , c , b) { }
//========================================================================================= /// <summary> /// Constructor. Creates the behaviour. A valid control character MUST be passed in. /// </summary> /// <param name="i"> /// Importance of the behaviour to this character. Behaviour scores are scaled by this. /// </param> /// <param name="c"> Character the behaviour is controlling. </param> /// <param name="b"> Behaviour set the AIBehaviour belongs to. </param> //========================================================================================= public AI_Pursue_Move_Around_Platform( float i , Character c , AIBehaviourSet b ) : base(i , c , b) { }
//========================================================================================= /// <summary> /// Constructor. Creates the behaviour. A valid control character MUST be passed in. /// </summary> /// <param name="i"> /// Importance of the behaviour to this character. Behaviour scores are scaled by this. /// </param> /// <param name="c"> Character the behaviour is controlling. </param> /// <param name="b"> Behaviour set the AIBehaviour belongs to. </param> //========================================================================================= public AI_Pursue_Wall_Clear( float i , Character c , AIBehaviourSet b ) : base(i , c , b) { }
//========================================================================================= /// <summary> /// Constructor. Creates the behaviour. A valid control character MUST be passed in. /// </summary> /// <param name="i"> /// Importance of the behaviour to this character. Behaviour scores are scaled by this. /// </param> /// <param name="c"> Character the behaviour is controlling. </param> /// <param name="b"> Behaviour set the AIBehaviour belongs to. </param> //========================================================================================= public AI_Sight( float i , Character c , AIBehaviourSet b ) : base(i , c , b) { // Save this for later use m_ninja_type = Type.GetType("NinjaGame.Ninja"); }
//========================================================================================= /// <summary> /// Constructor. Creates the Object. /// </summary> //========================================================================================= public EnemyNinja() { // Save this type: m_player_ninja_type = Type.GetType("NinjaGame.PlayerNinja"); // Throw a wobbler if it is not there in debug: #if DEBUG if ( m_player_ninja_type == null ) throw new Exception("Class missing. EnemyNinja requires PlayerNinja class !!!"); #endif // Create the behaviour set: m_behaviours = new AIBehaviourSet(this); // Select the behaviours and their importance: m_behaviours.AddBehaviour( "AI_Rest" , 1.5f ); m_behaviours.AddBehaviour( "AI_Patrol" , 30 ); m_behaviours.AddBehaviour( "AI_Sight" , 60 ); m_behaviours.AddBehaviour( "AI_Pursue" , 40 ); m_behaviours.AddBehaviour( "AI_Pursue_Jump_Gap" , 800.0f ); m_behaviours.AddBehaviour( "AI_Pursue_Wall_Run" , 0.00008f ); m_behaviours.AddBehaviour( "AI_Pursue_Platform_Jump" , 10.0f ); m_behaviours.AddBehaviour( "AI_Pursue_Move_Around_Platform" , 0.03f ); m_behaviours.AddBehaviour( "AI_Decluster" , 0.02f ); m_behaviours.AddBehaviour( "AI_Turn_Around" , 20.1f ); m_behaviours.AddBehaviour( "AI_Pursue_Wall_Jump" , 30.0f ); m_behaviours.AddBehaviour( "AI_Pursue_Wall_Clear" , 200.0f ); m_behaviours.AddBehaviour( "AI_Attack" , 0.65f ); m_behaviours.AddBehaviour( "AI_Throw_Shuriken" , 0.5f ); // Set the smoothness of behaviour change: m_behaviours.BehaviourSmooth = 0.75f; m_behaviours.BehaviourHoldTime = 0.20f; // Settings for this type of character JumpForce = 12; TopSpeed = 9; ShurikenSpeed = 600.0f; ShurikenDamage = 25.0f; ShurikenGravity = 0; AttackDamage = 50.0f; // Set default depth: Depth = 6000; // Set shuriken texture: see if cached first though if ( s_cached_shuriken_texture != null ) { // Have cache: use ShurikenTexture = s_cached_shuriken_texture; } else { // Ain't got cache: load ShurikenTexture = Core.Graphics.LoadTexture("Graphics\\Objects\\EnemyShuriken"); } }