Esempio n. 1
0
 public AICharacter(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     var typeName = (string)info.GetValue(aiTypeSerializationName, typeof(string));
     var type = Type.GetType(typeName);
     intelligence = (AI)Activator.CreateInstance(type, new object[] { info, context});
     this.intelligence.ControlledCharacter = this;
     var senseMethodName = (string)info.GetValue(sensingSerializationName, typeof(string));
     SensePg = senseMethodName.ToDelegate<AI.SensingAlgorythms, AI.SensingMethod>();
     perceptionDistance = (int)info.GetValue(perceptionDistanceSerializationName, typeof(int));
     squaredPerceptionDistance =  (int)info.GetValue(squaredPerceptionDistanceSerializationName, typeof(int));
 }
Esempio n. 2
0
 public AICharacter( string name, 
                     int currentPf,
                     int maximumPf,
                     int hunger,
                     AI intelligence, 
                     int perceptionDistance,
                     AI.SensingMethod sensingMethod = null,
                     Stats? stats = null,
                     Armor wornArmor = null,
                     Shield embracedShield = null,
                     Weapon handledWeapon = null,
                     Backpack backpack = null,
                     God god = null,
                     bool unblockable = false,
                     string symbol = "C",
                     Color? color = null,
                     string description = "A creature of the world", 
                     Coord position = new Coord(),
                     Allied hostile = Allied.Enemy)
     : base( name, 
             currentPf,
             maximumPf,
             hunger,
             stats == null ? new Stats(StatsBuilder.RandomStats()) : (Stats)stats,
             wornArmor,
             embracedShield, 
             handledWeapon, 
             backpack == null ? new Backpack() : backpack,
             god,
             unblockable,
             symbol,
             color == null 
                 ? (hostile == Allied.Enemy ? Color.Red : Color.Green)
                 : (Color)color,
             description,
             position)
 {
     this.intelligence = intelligence;
     this.SensePg = sensingMethod == null ? AI.SensingAlgorythms.AllAround : sensingMethod;
     this.intelligence.ControlledCharacter = this;
     this.PerceptionDistance = perceptionDistance;
     this.AlliedTo = hostile;
 }