Exemplo n.º 1
0
		void mainGameThread()
		{
			IList rulesAndEffects=_GameData[_effects] as IList;

			Conditional stack=new Conditional();
			stack[_Game]=_GameData;
      List<Conditional> wrappedEffects=wrapGameEffects();
			
			stack[_effects]=wrappedEffects;
			stack[_target]=null;
			stack[_rootl]=_GameData;
			string curName="";
      Debug.Log(string.Format("effects : {0}",wrappedEffects.Count));
			try
			{

			
      while(runThread)
			{
          int ii=0;
				while(ii<rulesAndEffects.Count)
				{
            object obj =rulesAndEffects[ii];
            ii++;
					Conditional eff=obj as Conditional;
						curName=eff["__name"] as string;
					if(!eff.hasTag(EXECUTE_PREFIX)&&!eff.hasTag(EXECUTE_POSTFIX))
					{
						Condition cnd=eff[_condition] as Condition;
						//Debug.Log(cnd);
						//Monitor.Enter(gameLock);
						if(cnd.isFulfilled(stack,stack[_Game] as Conditional))
						{
							//Debug.Log(cnd);
								lock(gameLock)
								{
							Operation op=new Operation(Operation.Commands.NEW);
							Conditional nstack=op.createStack(stack, eff);
              int oneff=rulesAndEffects.Count;
              op.executeList(eff[_commands], nstack);
                if(rulesAndEffects.Count!=oneff)
                {
                  stack[_effects]=wrapGameEffects();
                  Debug.Log("added trules");
                }
							if(nstack.hasTag(TAG_ABORT))
							{
								Debug.Log("GameObject Overlapped");
								return;//gameover? I guess
							}
								}
						}

						//Monitor.Exit(gameLock);
					}
				}
			}

			}
			catch (System.Exception ex)
			{
				Debug.Log(ex);
				Debug.Log(curName);

				// I WILL LOG THE EXCEPTION object "EX" here ! but ex.StackTrace is truncated!
          }
      
    }