Пример #1
0
    public void SetData(Hashtable ht)
    {
        this.needed = (AIConditionNeeded)System.Enum.Parse(typeof(AIConditionNeeded), (string)ht["needed"]);
        if(ht.ContainsKey("variables"))
        {
            int count = int.Parse((string)ht["variables"]);
            this.variableKey = new string[count];
            this.variableValue = new string[count];
            this.checkType = new bool[count];
        }
        if(ht.ContainsKey("numbervariables"))
        {
            int count = int.Parse((string)ht["numbervariables"]);
            this.numberVarKey = new string[count];
            this.numberVarValue = new float[count];
            this.numberCheckType = new bool[count];
            this.numberValueCheck = new ValueCheck[count];
        }

        if(ht.ContainsKey(XMLHandler.NODES))
        {
            ArrayList s = ht[XMLHandler.NODES] as ArrayList;
            foreach(Hashtable ht2 in s)
            {
                if(ht2[XMLHandler.NODE_NAME] as string == VariableCondition.VARIABLEKEY)
                {
                    int j = int.Parse((string)ht2["id"]);
                    this.variableKey[j] = ht2[XMLHandler.CONTENT] as string;
                    this.checkType[j] = bool.Parse((string)ht2["type"]);
                }
                else if(ht2[XMLHandler.NODE_NAME] as string == VariableCondition.VARIABLEVALUE)
                {
                    int j = int.Parse((string)ht2["id"]);
                    this.variableValue[j] = ht2[XMLHandler.CONTENT] as string;
                }
                else if(ht2[XMLHandler.NODE_NAME] as string == VariableCondition.NUMBERVARIABLE)
                {
                    int j = int.Parse((string)ht2["id"]);
                    this.numberVarKey[j] = ht2[XMLHandler.CONTENT] as string;
                    this.numberVarValue[j] = float.Parse((string)ht2["value"]);
                    this.numberCheckType[j] = bool.Parse((string)ht2["type"]);
                    this.numberValueCheck[j] = (ValueCheck)System.Enum.Parse(
                            typeof(ValueCheck), (string)ht2["check"]);
                }
            }
        }
    }
Пример #2
0
 private bool CheckRequirements(Combatant c, bool doCheck, StatusRequirement[] req, AIConditionNeeded needed)
 {
     bool check = false;
     if(doCheck)
     {
         check = true;
         bool any = false;
         for(int i=0; i<req.Length; i++)
         {
             if(req[i].CheckRequirement(c))
             {
                 any = true;
             }
             else if(AIConditionNeeded.ALL.Equals(needed))
             {
                 check = false;
                 break;
             }
         }
         if(AIConditionNeeded.ONE.Equals(needed) && !any &&
             req.Length > 0)
         {
             check = false;
         }
     }
     return check;
 }