Esempio n. 1
0
    public void enchant(June june, EnchantmentFinishedCallback callback)
    {
        this.june     = june;
        this.callback = callback;
        this.junes.Push(june);
        this.enchantmentsRunning.Push(true);
        this.callbacks.Push(callback);

        StartCoroutine(enchantAnimation());
    }
Esempio n. 2
0
    // This is about the most horrible way to do this, but Stacks don't allow me to remove an arbirtrary element. I mean, seriously?
    public void disenchant(string name)
    {
        Stack tempj = new Stack();
        Stack tempe = new Stack();
        Stack tempc = new Stack();
        June  thejune;
        int   count = junes.Count;
        bool  found = false;

        // Lock the stacks so that no one else modifies them
        lock (junes.SyncRoot) {
            lock (enchantmentsRunning.SyncRoot) {
                lock (callbacks.SyncRoot) {
                    // Find the right june, pushing non-matching ones onto temporary stacks
                    for (int i = 0; i < count; i++)
                    {
                        thejune = (June)junes.Pop();
                        if (thejune.getFileName().Equals(name))
                        {
                            june = thejune;
                            enchantmentsRunning.Pop();
                            is_enchanted = false;
                            callback     = (EnchantmentFinishedCallback)callbacks.Pop();
                            found        = true;
                            break;
                        }
                        tempj.Push(thejune);
                        tempe.Push(enchantmentsRunning.Pop());
                        tempc.Push(callbacks.Pop());
                    }
                    // Put items on the temporary stacks back in place
                    count = tempj.Count;
                    for (int i = 0; i < count; i++)
                    {
                        junes.Push(tempj.Pop());
                        enchantmentsRunning.Push(tempe.Pop());
                        callbacks.Push(tempc.Pop());
                    }
                    if (found)
                    {
                        // Put the matching june at the top of the stack
                        junes.Push(june);
                        enchantmentsRunning.Push(is_enchanted);
                        callbacks.Push(callback);
                    }
                }
            }
        }
        if (found)
        {
            june.Stop();
        }
    }
Esempio n. 3
0
 // This is about the most horrible way to do this, but Stacks don't allow me to remove an arbirtrary element. I mean, seriously?
 public void disenchant(string name)
 {
     Stack tempj = new Stack();
     Stack tempe = new Stack();
     Stack tempc = new Stack();
     June thejune;
     int count = junes.Count;
     bool found = false;
     // Lock the stacks so that no one else modifies them
     lock (junes.SyncRoot) {
     lock (enchantmentsRunning.SyncRoot) {
     lock (callbacks.SyncRoot) {
         // Find the right june, pushing non-matching ones onto temporary stacks
         for (int i=0; i<count; i++) {
             thejune = (June) junes.Pop();
             if (thejune.getFileName().Equals(name)) {
                 june = thejune;
                 enchantmentsRunning.Pop();
                 is_enchanted = false;
                 callback = (EnchantmentFinishedCallback) callbacks.Pop();
                 found = true;
                 break;
             }
             tempj.Push(thejune);
             tempe.Push(enchantmentsRunning.Pop());
             tempc.Push(callbacks.Pop());
         }
         // Put items on the temporary stacks back in place
         count = tempj.Count;
         for (int i=0; i<count; i++) {
             junes.Push(tempj.Pop());
             enchantmentsRunning.Push(tempe.Pop());
             callbacks.Push(tempc.Pop());
         }
         if (found) {
             // Put the matching june at the top of the stack
             junes.Push(june);
             enchantmentsRunning.Push(is_enchanted);
             callbacks.Push(callback);
         }
     }}}
     if (found)
         june.Stop();
 }
Esempio n. 4
0
 public void setCallback(EnchantmentFinishedCallback callback)
 {
     this.callback = callback;
 }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        if (gameObject.GetComponent <Text3D>() != null)
        {
            gameObject.GetComponent <Text3D>().text = id;
        }

        ////////////////////////////////
//      if (june.isStopped()) {
//          if (!isEnchanted()) {
//              disenchantAnimation();
//          }
//          if (callback != null) {
//              callback(gameObject);
//              if (!isEnchanted())
//                  callback = null;
//              if (june.wasSuccessful()) {
//                  if(EnchantmentEnded != null)
//                      EnchantmentEnded(gameObject, june.getFileName());
//              } else {
//                  if(EnchantmentFailed != null)
//                      EnchantmentFailed(gameObject, june.getFileName());
//              }
//          }
//      }
        ////////////////////////////////

        if (june != null && !isEnchanted())
        {
            //ProgramLogger.LogKV("enchantments", hasRunningEnchantment()+"");
            if (!hasRunningEnchantment())
            {
                disenchantAnimation();
            }

            if (callback != null)
            {
                callback(gameObject);
                //if (!hasRunningEnchantment())
                //    callback = null;

                if (june.wasSuccessful())
                {
                    if (EnchantmentEnded != null)
                    {
                        EnchantmentEnded(gameObject, june.getFileName());
                    }
                }
                else
                {
                    if (EnchantmentFailed != null)
                    {
                        EnchantmentFailed(gameObject, june.getFileName());
                    }
                }
            }

            junes.Pop();
            enchantmentsRunning.Pop();
            callbacks.Pop();
            if (junes.Count > 0)
            {
                june         = (June)junes.Peek();
                is_enchanted = (bool)enchantmentsRunning.Peek();
                callback     = (EnchantmentFinishedCallback)callbacks.Peek();
            }
            else
            {
                june           = null;
                is_enchanted   = false;
                callback       = null;
                newEnchantment = true;
            }
        }

//      if(!isEnchanted())
//      {
//          disenchantAnimation();
//
//          if(callback != null)
//          {
//              callback(gameObject);
//              callback = null;
//
//              if(june.wasSuccessful())
//              {
//                  if(EnchantmentEnded != null)
//                      EnchantmentEnded(gameObject, june.getFileName());
//              } else {
//
//                  if(EnchantmentFailed != null)
//                  {
//                      EnchantmentFailed(gameObject, june.getFileName());
//                  }
//              }
//          }
//      }
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if(gameObject.GetComponent<Text3D>() != null)
        {
            gameObject.GetComponent<Text3D>().text = id;
        }

        ////////////////////////////////
        // 		if (june.isStopped()) {
        // 		    if (!isEnchanted()) {
        // 		        disenchantAnimation();
        // 		    }
        // 		    if (callback != null) {
        // 		        callback(gameObject);
        // 		        if (!isEnchanted())
        // 		            callback = null;
        // 		        if (june.wasSuccessful()) {
        // 		            if(EnchantmentEnded != null)
        // 						EnchantmentEnded(gameObject, june.getFileName());
        // 				} else {
        // 					if(EnchantmentFailed != null)
        // 						EnchantmentFailed(gameObject, june.getFileName());
        // 				}
        // 		    }
        // 		}
        ////////////////////////////////

        if(june != null && !isEnchanted())
        {
            //ProgramLogger.LogKV("enchantments", hasRunningEnchantment()+"");
            if (!hasRunningEnchantment())
                disenchantAnimation();

            if(callback != null)
            {
                callback(gameObject);
                //if (!hasRunningEnchantment())
                //    callback = null;

                if(june.wasSuccessful())
                {
                    if(EnchantmentEnded != null)
                        EnchantmentEnded(gameObject, june.getFileName());
                } else {

                    if(EnchantmentFailed != null)
                    {
                        EnchantmentFailed(gameObject, june.getFileName());
                    }
                }
            }

            junes.Pop();
            enchantmentsRunning.Pop();
            callbacks.Pop();
            if (junes.Count > 0) {
                june = (June) junes.Peek();
                is_enchanted = (bool) enchantmentsRunning.Peek();
                callback = (EnchantmentFinishedCallback) callbacks.Peek();
            } else {
                june = null;
                is_enchanted = false;
                callback = null;
                newEnchantment = true;
            }
        }

        // 		if(!isEnchanted())
        // 		{
        // 			disenchantAnimation();
        //
        // 			if(callback != null)
        // 			{
        // 				callback(gameObject);
        // 				callback = null;
        //
        // 				if(june.wasSuccessful())
        // 				{
        // 					if(EnchantmentEnded != null)
        // 						EnchantmentEnded(gameObject, june.getFileName());
        // 				} else {
        //
        // 					if(EnchantmentFailed != null)
        // 					{
        // 						EnchantmentFailed(gameObject, june.getFileName());
        // 					}
        // 				}
        // 			}
        // 		}
    }
Esempio n. 7
0
 public void setCallback( EnchantmentFinishedCallback callback)
 {
     this.callback = callback;
 }
Esempio n. 8
0
    public void enchant(June june, EnchantmentFinishedCallback callback)
    {
        this.june = june;
        this.callback = callback;
        this.junes.Push(june);
        this.enchantmentsRunning.Push(true);
        this.callbacks.Push(callback);

        StartCoroutine(enchantAnimation());
    }