Ejemplo n.º 1
0
    private static long Count(IEnumerable <Instruction> instructions)
    {
        var cubes  = new ItemCounter <Cube>();
        var buffer = new ItemCounter <Cube>();

        foreach (var instruction in instructions)
        {
            buffer.Clear();
            foreach (var record in cubes)
            {
                if (record.Item.Intersect(instruction.Cube, out var intersection))
                {
                    buffer[intersection] -= record.Count;
                }
            }
            foreach (var buffered in buffer)
            {
                cubes[buffered.Item] += buffered.Count;
            }
            cubes[instruction.Cube] += instruction.IsOn ? 1 : 0;
        }
        return(cubes.Sum(record => record.Item.Count * record.Count));
    }
Ejemplo n.º 2
0
    IEnumerator LifeSystemRoutine()
    {
        while (local_profile == null)
        {
            yield return(0);
        }

        TimeSpan refilling_time = new TimeSpan(0, ProjectParameters.main.refilling_time, 0);

        while (true)
        {
            while (local_profile["life"] < ProjectParameters.main.lifes_limit && local_profile.next_life_time <= DateTime.Now)
            {
                local_profile["life"]++;
                local_profile.next_life_time += refilling_time;
                ItemCounter.RefreshAll();
            }
            if (local_profile["life"] >= ProjectParameters.main.lifes_limit)
            {
                local_profile.next_life_time = DateTime.Now + refilling_time;
            }
            yield return(new WaitForSeconds(1));
        }
    }
Ejemplo n.º 3
0
 // updating counters, when balance of goods changed
 void onGoodBalanceChanged(VirtualGood good, int balance, int amountAdded)
 {
     ItemCounter.RefreshAll();
 }
Ejemplo n.º 4
0
 // updating counters, when balance of currency changed
 void onCurrencyBalanceChanged(VirtualCurrency virtualCurrency, int balance, int amountAdded)
 {
     ItemCounter.RefreshAll();
 }
Ejemplo n.º 5
0
 //private static float minusbat = 10;
 private void Start()
 {
     count = GameObject.FindGameObjectWithTag("Player").GetComponent <ItemCounter>();
 }
Ejemplo n.º 6
0
 public void selectItemCounterChooser(String itemCounterName)
 {
     itemCounter = itemCounterChooser.getItemCounterInstance(
         itemCounterName);
 }
Ejemplo n.º 7
0
    // Update is called once per frame
    IEnumerator WheelRoutine()
    {
        if (ProfileAssistant.main.local_profile.daily_raward < System.DateTime.Now)
        {
            System.DateTime next_reward = System.DateTime.Now;
            if (next_reward.Hour > ProfileAssistant.main.local_profile.daily_raward.Hour)
            {
                next_reward = next_reward.AddDays(1);
            }

            ProfileAssistant.main.local_profile.daily_raward = new System.DateTime(
                next_reward.Year, next_reward.Month, next_reward.Day,
                ProjectParameters.main.dailyreward_hour, 0, 0);
        }
        else if (ProfileAssistant.main.local_profile["spin"] >= 1)
        {
            ProfileAssistant.main.local_profile["spin"]--;
            ItemCounter.RefreshAll();
        }
        else if (ProfileAssistant.main.local_profile["seed"] >= spinCost)
        {
            ProfileAssistant.main.local_profile["seed"] -= spinCost;
            ItemCounter.RefreshAll();
        }
        else
        {
            UIAssistant.main.ShowPage("Store");
            yield break;
        }

        ProfileAssistant.main.SaveUserInventory();

        UpdateCounters();

        Animation anim;

        locker.SetActive(true);

        anim = spinButton.GetComponent <Animation>();
        anim.Play("SWButtonHide");
        while (anim.isPlaying)
        {
            yield return(0);
        }
        spinButton.gameObject.SetActive(false);

        speed = 0;
        while (speed < 200)
        {
            speed = Mathf.MoveTowards(speed, 200, Time.deltaTime * 90);
            wheel.Rotate(0, 0, -speed * Time.deltaTime);
            yield return(0);
        }

        stopButton.gameObject.SetActive(true);
        anim = stopButton.GetComponent <Animation>();
        anim.Play("SWButtonShow");

        stopButton.onClick.RemoveAllListeners();

        bool        stoped = false;
        UnityAction stop   = () => {
            stoped = true;
        };

        stopButton.onClick.AddListener(stop);

        while (!stoped)
        {
            wheel.Rotate(0, 0, -speed * Time.deltaTime);
            yield return(0);
        }

        stopButton.onClick.RemoveAllListeners();
        anim.Play("SWButtonHide");

        int total_probability = 0;

        foreach (SpinWheelReward reward in ProjectParameters.main.spinWheelRewards)
        {
            total_probability += reward.probability;
        }
        target = Random.Range(0, total_probability);
        for (int i = 0; i < 8; i++)
        {
            target -= ProjectParameters.main.spinWheelRewards[i].probability;
            if (target <= 0)
            {
                target = i;
                break;
            }
        }

        target_angle  = target * 45 - 360;
        intrigue      = -10f + (Random.value > 0.5f ? 22.5f : -22.5f);
        target_angle -= 360 * 3;

        current_angle = wheel.eulerAngles.z;

        while (intrigue != 0 || current_angle != target_angle + intrigue)
        {
            speed         = Mathf.MoveTowards(speed, Mathf.Min(200, Mathf.Abs(current_angle - intrigue - target_angle) / 3 + 2), Time.deltaTime * 2f * (Mathf.Abs(speed) + 5f));
            current_angle = Mathf.MoveTowards(current_angle, target_angle + intrigue, speed * Time.deltaTime);
            wheel.transform.eulerAngles = Vector3.forward * current_angle;
            if (current_angle == target_angle + intrigue)
            {
                intrigue = 0;
            }
            yield return(0);
        }

        stopButton.gameObject.SetActive(false);
        locker.SetActive(false);

        rewardIcon.sprite = ProjectParameters.main.spinWheelRewards[target].icon;

        List <string> report = new List <string>();

        foreach (string reward in ProjectParameters.main.spinWheelRewards[target].items)
        {
            string[] args  = reward.Split(':');
            int      count = int.Parse(args[1]);
            ProfileAssistant.main.local_profile[args[0]] += count;
            report.Add(LocalizationAssistant.main[BerryStoreAssistant.main.items.Find(x => x.id == args[0]).localization_name] + (count > 1 ? "(x" + count.ToString() + ")" : ""));
        }

        lastReward = string.Join(", ", report.ToArray());

        ProfileAssistant.main.SaveUserInventory();

        UpdateCounters();

        ItemCounter.RefreshAll();

        UIAssistant.main.ShowPage("SpinWheelReward");
    }
Ejemplo n.º 8
0
        private void FillItemsCount(Dungeon D, ExcelWorksheet ws)
        {
            ws.Cells["A1"].Value = "Name";
            ws.Cells["B1"].Value = "Count";
            ws.Cells["C1"].Value = "Instances";
            ws.Cells["D1"].Value = "Min-Level";
            ws.Cells["E1"].Value = "Max-Level";
            ws.Cells["F1"].Value = "Subclass";

            Dictionary <string, ItemCounter> counters = new Dictionary <string, ItemCounter>();

            int row = 2;

            foreach (Entity E in D.EntitiesByClass[EntityClass.Item])
            {
                if (!counters.ContainsKey(E.Name))
                {
                    counters.Add(E.Name, new ItemCounter());
                }

                ItemCounter C = counters[E.Name];

                string stack = E.GetProperty("StackSize");
                int    qty   = 0;

                if (int.TryParse(stack, out qty))
                {
                    C.Count += qty;
                }
                else
                {
                    C.Count++;
                }

                C.Instances++;
                C.MaxLevel = Math.Max(C.MaxLevel, E.Level);
                C.MinLevel = Math.Min(C.MinLevel, E.Level);
            }

            foreach (KeyValuePair <string, ItemCounter> K in counters.OrderBy(k => k.Key))
            {
                Asset  A   = D.Assets.Get(K.Key);
                string cat = (A != null) ? A.ItemClass.ToString() : "0";
                ws.Cells[row, 1].Value = K.Key;
                ws.Cells[row, 2].Value = K.Value.Count;
                ws.Cells[row, 3].Value = K.Value.Instances;
                ws.Cells[row, 4].Value = K.Value.MinLevel;
                ws.Cells[row, 5].Value = K.Value.MaxLevel;
                ws.Cells[row, 6].Value = cat;
                ++row;
            }


            ExcelRange range1 = ws.Cells["A1:F" + (row - 1).ToString()];
            ExcelTable table1 = ws.Tables.Add(range1, "tbl_" + Guid.NewGuid().ToString("N"));

            table1.TableStyle = OfficeOpenXml.Table.TableStyles.Light1;

            ws.Column(1).AutoFit();
            ws.Column(2).AutoFit();
            ws.Column(3).AutoFit();
            ws.Column(4).AutoFit();
            ws.Column(5).AutoFit();
        }
Ejemplo n.º 9
0
 // Update is called once per frame
 void OnValueChanged(int value)
 {
     LocalizationAssistant.main.LearnLanguage(LocalizationAssistant.main.languages[value]);
     ItemCounter.RefreshAll();
 }