Ejemplo n.º 1
0
        public static void StartWatch(object idleObject, TimeSpan timeout, EventHandler <TimeoutEventArgs> handler, object data)
        {
            if (idleObject == null)
            {
                throw new ArgumentNullException("idleObject");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            if (timeout == TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("timeout");
            }

            lock (syncRoot)
            {
                if (items.ContainsKey(idleObject))
                {
                    log.WarnFormat("An item with the same key ({0}) has already been added.", idleObject);
                }
                items[idleObject] = new IdleItem(idleObject, timeout, handler, data);
                if (timerStoped)
                {
                    timer.Change(timerPeriod, timerPeriod);
                    timerStoped = false;
                    log.DebugFormat("Timer started.");
                }
            }
            log.DebugFormat("Start watch idle object: {0}, timeout: {1}", idleObject, timeout);
        }
Ejemplo n.º 2
0
    void ect()
    {
        try
        {
            Item = Items[CurrentItem];
            Item.gameObject.SetActive(true);
            IdleItem.OnDeath += CheckDeath;
        }
        catch (IndexOutOfRangeException)
        {
            CurrentItem = 0;
            return;
        }

        for (int i = 0; i < Items.Length; i++)
        {
            if (i != CurrentItem)
            {
                Items[i].gameObject.SetActive(false);
            }
        }
        if (CurrentItem != 0)
        {
            PrevItemButton.SetActive(true);
        }
        else
        {
            PrevItemButton.SetActive(false);
        }
        if (CurrentItem != Items.Length - 1 && MaxLevelUnlocked > CurrentItem)
        {
            NextItemButton.SetActive(true);
        }
        else
        {
            NextItemButton.SetActive(false);
        }
        if (TouchScript.TouchedObject == NextItemButton)
        {
            CurrentItem++;
            TouchScript.TouchedObject = null;
            if (OnLevelChange != null)
            {
                OnLevelChange();
            }
        }
        else if (TouchScript.TouchedObject == PrevItemButton)
        {
            CurrentItem--;
            TouchScript.TouchedObject = null;
            if (OnLevelChange != null)
            {
                OnLevelChange();
            }
        }
        if (OnEct != null)
        {
            OnEct();
        }
    }
Ejemplo n.º 3
0
        public static void StartWatch(string id, TimeSpan timeout, EventHandler <TimeoutEventArgs> handler, object data)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            if (timeout == TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("timeout");
            }

            lock (locker)
            {
                if (items.ContainsKey(id))
                {
                    log.WarnFormat("An item with the same key ({0}) has already been added.", id);
                }
                items[id] = new IdleItem(id, timeout, handler, data);
            }
            log.DebugFormat("Start watch idle object: {0}, timeout: {1}", id, timeout);
        }
Ejemplo n.º 4
0
 void OverrideInitilize(IdleItem Item, IdleItem Base, int TimesGenerated)
 {
     Item.Toughness  = Base.Toughness * TimesGenerated * Armor;
     Item.InitialHP  = Base.InitialHP * (Health * TimesGenerated);
     Item.HP         = Item.InitialHP;
     Item.PriceScore = Base.PriceScore * (Score * TimesGenerated);
     Item.Price      = Base.Price * (TimesGenerated * Price);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Обработчик события изменения текущего элемента в источнике данных заявок простоев сервисов
        /// </summary>
        private void idleItemBindingSource_CurrentChanged(object sender, EventArgs e)
        {
            var selectedItem = ((BindingSource)sender).Current as IdleItem;

            if (selectedItem != null)
            {
                SelectedIdleItem = selectedItem;
            }
        }
Ejemplo n.º 6
0
 void MakeNewItem()
 {
     if (Returnable && Main.MaxLevelUnlocked < Main.Items.Length)
     {
         return;
     }
     IdleItem[] TempItems = new IdleItem[Main.Items.Length];
     System.Array.Copy(Main.Items, TempItems, Main.Items.Length);
     Main.Items = new IdleItem[TempItems.Length + 1];
     System.Array.Copy(TempItems, Main.Items, TempItems.Length);
     Main.Items[Main.Items.Length - 1] = (IdleItem)Instantiate(Main.Items[Main.Items.Length - 2], Main.Items[Main.Items.Length - 2].transform.position, Main.Items[Main.Items.Length - 2].transform.rotation);
     if (Returnable)
     {
         GeneratedItems++;
     }
     OverrideInitilize(Main.Items[Main.Items.Length - 1], Main.Items[Main.Items.Length - 2], GeneratedItems);
 }
Ejemplo n.º 7
0
 void Load()
 {
     if (GeneratedItems > 0)
     {
         IdleItem[] TempItems = new IdleItem[Main.Items.Length];
         System.Array.Copy(Main.Items, TempItems, Main.Items.Length);
         Main.Items = new IdleItem[InitialLength + GeneratedItems];
         System.Array.Copy(TempItems, Main.Items, TempItems.Length);
         for (int i = InitialLength; i < InitialLength + GeneratedItems; i++)
         {
             Main.Items[i]            = (IdleItem)Instantiate(Main.Items[i - 1], Main.Items[i - 1].transform.position, Main.Items[i - 1].transform.rotation);
             Main.Items[i].InitialHP  = saver.LoadDecimal(i.ToString() + "HP");
             Main.Items[i].HP         = Main.Items[i].InitialHP;
             Main.Items[i].Toughness  = saver.LoadDecimal(i.ToString() + "Armor");
             Main.Items[i].PriceScore = saver.LoadDecimal(i.ToString() + "PS");
             Main.Items[i].Price      = saver.LoadDecimal(i.ToString() + "Price");
         }
     }
 }
Ejemplo n.º 8
0
        public static void StartWatch(object idleObject, TimeSpan timeout, EventHandler<TimeoutEventArgs> handler, object data)
        {
            if (idleObject == null) throw new ArgumentNullException("idleObject");
            if (handler == null) throw new ArgumentNullException("handler");
            if (timeout == TimeSpan.Zero) throw new ArgumentOutOfRangeException("timeout");

            lock (syncRoot)
            {
                if (items.ContainsKey(idleObject))
                {
                    log.WarnFormat("An item with the same key ({0}) has already been added.", idleObject);
                }
                items[idleObject] = new IdleItem(idleObject, timeout, handler, data);
                if (timerStoped)
                {
                    timer.Change(timerPeriod, timerPeriod);
                    timerStoped = false;
                    log.DebugFormat("Timer started.");
                }
            }
            log.DebugFormat("Start watch idle object: {0}, timeout: {1}", idleObject, timeout);
        }