Esempio n. 1
0
        public FormAdmin()
        {
            InitializeComponent();
            txtdefaultcolor = txtFName.BackColor;
            //txtFName.LostFocus += new EventHandler(CheckName);
            //txtLName.LostFocus += new EventHandler(CheckName);
            //txtMName.LostFocus += new EventHandler(CheckName);

            txtFName.TextChanged += new EventHandler(CheckName);
            txtLName.TextChanged += new EventHandler(CheckName);
            txtMName.TextChanged += new EventHandler(CheckName);
            txtSpeed.TextChanged += new EventHandler(CheckSpeed);

            txtFName.MaxLength = Lootbox.MAX_LEN_STRING_FOR_NAME;
            txtLName.MaxLength = Lootbox.MAX_LEN_STRING_FOR_NAME;
            txtMName.MaxLength = Lootbox.MAX_LEN_STRING_FOR_NAME;

            cmbBoxSize.DataSource = Enum.GetValues(typeof(BoxSize));

            dgvWorkers.CellDoubleClick += DgvWorkers_CellDoubleClick;
            dgvWorkers.SelectionMode    = DataGridViewSelectionMode.FullRowSelect;
            dgvWorkers.Hide();
            dgvWorkers.ReadOnly = true;
            dgvWorkers.Rows.AddRange(Lootbox.FillGridWorkers().ToArray());

            this.CancelButton = btnClose;
            btnClose.Click   += new EventHandler(Close);
            btnList.Click    += new EventHandler(Click_btnList);
            btnDel.Click     += new EventHandler(Click_btnDel);
            btnAdd.Click     += new EventHandler(Click_btnAdd);
        }
Esempio n. 2
0
        static void Main()
        {
            do
            {
                MenuMain.PrintMenu();

                switch (Lootbox.GetPressedKey())
                {
                case ConsoleKey.NumPad1 or ConsoleKey.D1:
                    //user space
                    MenuUser.Work();
                    break;

                case ConsoleKey.NumPad2 or ConsoleKey.D2:
                    //admin space
                    MenuAdmin.Work();
                    break;

                case ConsoleKey.Escape:
                    Lootbox.SaveData();
                    return;

                default:
                    break;
                }
            } while (true);
        }
Esempio n. 3
0
    void Update()
    {
        if (gameOver)
        {
            return;
        }

        if (Time.time >= nextTick)
        {
            nextTick = Time.time + tickLength;

            bool foundBoxes = false;

            foreach (GameObject Lootbox in Lootboxes)
            {
                if (Lootbox == null)
                {
                    continue;
                }

                Lootbox.GetComponent <LootBox>().UpdateLootbox();
                // Lootbox.transform.Translate(0, 0.1f, 0);
                // Lootbox.GetComponent<NetworkTransform>().SetDirtyBit(1);
                foundBoxes = true;
            }

            if (foundBoxes == false)
            {
                CreateAllLootbox();
                tickLength = 0.2f;
            }
        }
    }
Esempio n. 4
0
        private void Click_btnDel(object sender, EventArgs e)
        {
            string message = "";

            if (dgvWorkers.SelectedRows.Count == 1)
            {
                this.Enabled = false;
                var row = dgvWorkers.SelectedRows;
                message   += row[0].Cells["cfname"].Value.ToString() + " ";
                message   += row[0].Cells["clname"].Value.ToString() + " ";
                message   += row[0].Cells["cmname"].Value.ToString();
                btnDel.Tag = row[0].Cells["cid"].Value.ToString();

                var res = MessageBox.Show($"Будет удален работник {message}",
                                          "Внимание",
                                          MessageBoxButtons.OKCancel,
                                          MessageBoxIcon.Exclamation);
                if (res == DialogResult.OK)
                {
                    Lootbox.DelWorker(int.Parse(btnDel.Tag.ToString()));
                }
                dgvWorkers.Rows.Clear();
                dgvWorkers.Rows.AddRange(Lootbox.FillGridWorkers().ToArray());
                ResetUserControls();
            }
            btnDel.Tag = "";

            this.Enabled = true;
        }
Esempio n. 5
0
        public void SelectClients()
        {
            Lootbox.ClearClients();
            string     sqlquery = @"select * from clients order by id";
            SqlCommand sqlcmd   = new SqlCommand(sqlquery, KEDR);

            KEDR.Open();
            using (SqlDataReader reader = sqlcmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        int             id       = (int)reader["id"];
                        string          fname    = (string)reader["f_name"];
                        string          lname    = (string)reader["l_name"];
                        string          mname    = (string)reader["m_name"];
                        float           distance = (float)(double)reader["distance"];
                        int             boxsize  = (int)reader["box_size"];
                        System.DateTime stamp    = (System.DateTime)reader["Stamp"];
                        Client          client   = new Client(id, fname, lname, mname, distance, (BoxSize)boxsize, stamp);
                        Lootbox.AddClient(client);
                    }
                }
            }
            KEDR.Close();
        }
Esempio n. 6
0
    public Lootbox CreateLootbox(int size = 3)
    {
        Lootbox lb = new Lootbox(size);

        for (int i = 0; i < size; i++)
        {
            var         r           = RarityHelper.GetWeightedRarity();
            LootboxItem item        = null;
            int         retardCheck = 0;
            do
            {
repeat:
                item = PotentialRewards.RandomElement(x => x.Rarity == r);
                if (item.RewardType == LootboxRewardType.Generators && !Services.TransportService.HasUnits(item.TargetGenerator))
                {
                    goto repeat;
                }
                r--; // if not item of that rarity was found, go one lower
                retardCheck++;

                if (retardCheck > 10)
                {
                    break;
                }
            } while (item == null && r > 0);

            lb[i] = item;
        }

        return(lb);
    }
Esempio n. 7
0
        private void AddLootboxes(XElement root)
        {
            foreach (var elem in root.XPathSelectElements("//Lootcase"))
            {
                string id = elem.Attribute("id").Value;

                ushort type;
                var    typeAttr = elem.Attribute("type");
                type = (ushort)Utils.FromString(typeAttr.Value);

                if (type2id_lootBox.ContainsKey(type))
                {
                    log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_equipSet[type], type);
                }
                if (id2type_lootBox.ContainsKey(id))
                {
                    log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_equipSet[id], id);
                }

                type2id_lootBox[type]   = id;
                id2type_lootBox[id]     = type;
                type2elem_lootBox[type] = elem;

                lootBox[type] = Lootbox.FromElem(type, elem);
            }
        }
Esempio n. 8
0
        public void SelectWorkers()
        {
            Lootbox.ClearWorkers();
            string     sqlquery = @"select * from workers order by id";
            SqlCommand sqlcmd   = new SqlCommand(sqlquery, KEDR);

            KEDR.Open();
            using (SqlDataReader reader = sqlcmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        int    id      = (int)reader["id"];
                        string fname   = (string)reader["f_name"];
                        string lname   = (string)reader["l_name"];
                        string mname   = (string)reader["m_name"];
                        float  speed   = (float)(double)reader["speed"];
                        int    boxsize = (int)reader["box_size"];
                        bool   isbusy  = (bool)reader["is_busy"];
                        Worker worker  = new Worker(id, fname, lname, mname, speed, (BoxSize)boxsize, isbusy);
                        Lootbox.AddWorker(worker);
                    }
                }
            }
            KEDR.Close();
        }
Esempio n. 9
0
 private IEnumerator StartAnimNLB(int rc, Lootbox lb)
 {
     for (int i = 0; i < rc; i++)
     {
         ActivateLootboxItem(lb[i], Views[i]);
         yield return(new WaitForSeconds(InterItemDelay));
     }
     ContinueButton.SetActive(true);
 }
Esempio n. 10
0
    private IEnumerator StartAnim2LB(Lootbox lb)
    {
        ActivateLootboxItem(lb[0], Views[0]);
        yield return(new WaitForSeconds(InterItemDelay));

        ActivateLootboxItem(lb[1], Views[2]);
        yield return(new WaitForSeconds(InterItemDelay));

        ContinueButton.SetActive(true);
    }
Esempio n. 11
0
        private void CheckSpeed(object sender, EventArgs e)
        {
            TextBox objevent = sender as TextBox;

            if (!Lootbox.TryInputFloat(objevent.Text, out var none))
            {
                objevent.BackColor = Color.FromArgb(210, 180, 150);
                objevent.Tag       = false;
            }
            else
            {
                objevent.BackColor = txtdefaultcolor;
                objevent.Tag       = true;
            }
        }
Esempio n. 12
0
        private void CheckName(object sender, EventArgs e)
        {
            TextBox objevent = sender as TextBox;

            if (!Lootbox.TryInputString(objevent.Text))
            {
                objevent.BackColor = Color.FromArgb(210, 180, 150);
                objevent.Tag       = false;
            }
            else
            {
                objevent.BackColor = txtdefaultcolor;
                objevent.Tag       = true;
            }
        }
Esempio n. 13
0
 public Lootbox AddItemToLootContainer(DatabaseItem a_item)
 {
     for (int i = 0; i < this.m_buildings.Count; i++)
     {
         if (null != this.m_buildings[i] && this.m_buildings[i].m_type == 103 && 0f < this.m_buildings[i].GetState())
         {
             Lootbox lootbox = (Lootbox)this.m_buildings[i];
             if (null != lootbox && a_item.cid == lootbox.m_cid && lootbox.m_container != null)
             {
                 lootbox.m_container.UpdateOrCreateItem(a_item);
                 return(lootbox);
             }
         }
     }
     return(null);
 }
Esempio n. 14
0
    public void Loot()
    {
        gameObject.SetActive(false);
        var list = looser.equipment;

        list.RemoveAll(m => m.durability <= 2);
        if (list.Count == 0)
        {
            Lootbox.OpenCheapSmall();
        }
        else
        {
            for (int i = 0; i < list.Count; i++)
            {
                list[i].durability -= 2;
            }
            Lootbox.Open(list, Mathf.Min(list.Count, 2));
        }
    }
Esempio n. 15
0
        private void Click_btnAdd(object sender, EventArgs e)
        {
            this.Enabled = false;

            if ((bool)(txtFName.Tag ?? false) &&
                (bool)(txtLName.Tag ?? false) &&
                (bool)(txtMName.Tag ?? false) &&
                (bool)(txtSpeed.Tag ?? false))
            {
                string message = "";
                message += txtFName.Text.Trim() + " ";
                message += txtLName.Text.Trim() + " ";
                message += txtMName.Text.Trim();
                var res = MessageBox.Show($"Будет добавлен работник {message}",
                                          "Внимание",
                                          MessageBoxButtons.OKCancel,
                                          MessageBoxIcon.Exclamation);
                if (res == DialogResult.OK)
                {
                    string fname   = txtFName.Text.Trim();
                    string lname   = txtLName.Text.Trim();
                    string mname   = txtMName.Text.Trim();
                    float  speed   = float.Parse(txtSpeed.Text.Trim());
                    int    boxsize = (int)Enum.Parse(typeof(BoxSize), cmbBoxSize.Text.Trim(), true);

                    Lootbox.AddWorker(fname, lname, mname, speed, boxsize);
                    dgvWorkers.Rows.Clear();
                    dgvWorkers.Rows.AddRange(Lootbox.FillGridWorkers().ToArray());
                    ResetUserControls();
                }
            }
            else
            {
                MessageBox.Show($"Данные не коректны или не предоставлены.\nИли исправьте подсвеченные поля.",
                                "Внимание",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }

            this.Enabled = true;
        }
Esempio n. 16
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            Console.Out.WriteLine();
            foreach (ulong master in track[0xCF])
            {
                if (!map.ContainsKey(master))
                {
                    continue;
                }
                STUD lootbox = new STUD(Util.OpenFile(map[master], handler));
                if (lootbox.Instances == null)
                {
                    continue;
                }
#if OUTPUT_STUDLOOTBOX
                Stream instream    = Util.OpenFile(map[master], handler);
                string outFilename = string.Format("./STUD/Lootboxes/{0:X16}.mat", master);
                string putPathname = outFilename.Substring(0, outFilename.LastIndexOf('/'));
                Directory.CreateDirectory(putPathname);
                Stream OutWriter = File.Create(outFilename);
                instream.CopyTo(OutWriter);
                OutWriter.Close();
                instream.Close();
#endif
                Lootbox box = lootbox.Instances[0] as Lootbox;
                if (box == null)
                {
                    continue;
                }
                Console.Out.WriteLine(box.EventNameNormal);
                Console.Out.WriteLine("\t{0}", Util.GetString(box.Master.title, map, handler));
                foreach (Lootbox.Bundle bundle in box.Bundles)
                {
                    Console.Out.WriteLine("\t\t{0}", Util.GetString(bundle.title, map, handler));
                }
            }
        }
Esempio n. 17
0
        private void Extract(ulong model, Lootbox lootbox, Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            if (model == 0 || !map.ContainsKey(model))
            {
                return;
            }

            string output = $"{flags.Positionals[2]}{Path.DirectorySeparatorChar}{Util.SanitizePath(lootbox.EventName)}{Path.DirectorySeparatorChar}";

            STUD stud = new STUD(Util.OpenFile(map[model], handler));

            HashSet <ulong>           models              = new HashSet <ulong>();
            Dictionary <ulong, ulong> animList            = new Dictionary <ulong, ulong>();
            HashSet <ulong>           parsed              = new HashSet <ulong>();
            Dictionary <ulong, List <ImageLayer> > layers = new Dictionary <ulong, List <ImageLayer> >();
            Dictionary <ulong, ulong>         replace     = new Dictionary <ulong, ulong>();
            Dictionary <ulong, List <ulong> > sound       = new Dictionary <ulong, List <ulong> >();

            foreach (ISTUDInstance inst in stud.Instances)
            {
                if (inst == null)
                {
                    continue;
                }
                if (inst.Name == stud.Manager.GetName(typeof(ComplexModelRecord)))
                {
                    ComplexModelRecord r = (ComplexModelRecord)inst;
                    ulong modelKey       = r.Data.model.key;
                    models.Add(modelKey);
                    Skin.FindAnimations(r.Data.animationList.key, sound, animList, replace, parsed, map, handler, models, layers, modelKey);
                    Skin.FindAnimations(r.Data.secondaryAnimationList.key, sound, animList, replace, parsed, map, handler, models, layers, modelKey);
                    Skin.FindTextures(r.Data.material.key, layers, replace, parsed, map, handler);
                }
            }

            Skin.Save(null, output, "", "", replace, parsed, models, layers, animList, flags, track, map, handler, model, false, quiet, sound, 0);
        }
Esempio n. 18
0
        public void Parse(Dictionary <ushort, List <ulong> > track, Dictionary <ulong, Record> map, CASCHandler handler, bool quiet, OverToolFlags flags)
        {
            Console.Out.WriteLine();
            foreach (ulong master in track[0xCF])
            {
                if (!map.ContainsKey(master))
                {
                    continue;
                }
                STUD lootbox = new STUD(Util.OpenFile(map[master], handler));
                if (lootbox.Instances == null)
                {
                    continue;
                }
                Lootbox box = lootbox.Instances[0] as Lootbox;
                if (box == null)
                {
                    continue;
                }

                Extract(box.Master.model, box, track, map, handler, quiet, flags);
                Extract(box.Master.alternate, box, track, map, handler, quiet, flags);
            }
        }
Esempio n. 19
0
        public Tuple <Item> GetUnboxResult(int crateType, Random rand)
        {
            Lootbox loot = Manager.Resources.GameData.Lootboxes[Manager.Resources.GameData.IdtoLootboxType[LootboxType(crateType)]];

            if (rand == null)
            {
                rand = new Random();
            }
            double choice      = rand.NextDouble();
            double totalChance = 0;

            foreach (Tuple <double, List <CrateLoot> > i in loot.CrateLoot)
            {
                totalChance += i.Item1;
                if (choice < totalChance)
                {
                    var crateLoot = i.Item2.RandomElement(rand);
                    return(GetCrateLoot(crateLoot, rand));
                }
            }
            Item item = Manager.Resources.GameData.Items[Manager.Resources.GameData.IdToObjectType["Gold Medal"]];

            return(Tuple.Create(item));
        }
Esempio n. 20
0
 private void Awake()
 {
     instance = this;
     gameObject.SetActive(false);
 }
Esempio n. 21
0
 public void OLEL()
 {
     gameObject.SetActive(false);
     GameState.State.money -= 400;
     Lootbox.OpenExpensiveLarge();
 }
Esempio n. 22
0
 public void OLES()
 {
     gameObject.SetActive(false);
     GameState.State.money -= 250;
     Lootbox.OpenExpensiveSmall();
 }
Esempio n. 23
0
 public void OLCL()
 {
     gameObject.SetActive(false);
     GameState.State.money -= 200;
     Lootbox.OpenCheapLarge();
 }
Esempio n. 24
0
 public void OLCS()
 {
     gameObject.SetActive(false);
     GameState.State.money -= 100;
     Lootbox.OpenCheapSmall();
 }
Esempio n. 25
0
    public void GiveRewards(Lootbox lb)
    {
        if (!lb.IsValid)
        {
            return;
        }
        var pdata = Player.LegacyPlayerData;

        foreach (var item in lb.Items)
        {
            switch (item.RewardType)
            {
            case LootboxRewardType.Generators:
                if (Services.TransportService.HasUnits(item.TargetGenerator))
                {
                    Services.TransportService.AddLiveUnits(item.TargetGenerator, (int)item.RewardValue);
                }
                else
                {
                    var generator = Services.GenerationService.Generators.GetGeneratorInfo(item.TargetGenerator);
                    Services.GenerationService.BuyGenerator(generator, true);
                    //AllManagers.BalanceManager.BuyGenerator(generator, free: true);
                }
                break;

            case LootboxRewardType.ProfitUpgrade:

                if (item.TargetGenerator == -1)
                {
                    Services.GenerationService.Generators.AddProfitBoost(
                        boost: BoostInfo.CreateTimed(
                            id: $"lootbox_{item.RewardType}_".GuidSuffix(5),
                            value: item.RewardValue,
                            endTime: Services.TimeService.UnixTimeInt + 600));
                }
                else
                {
                    if (Services.TransportService.HasUnits(item.TargetGenerator))
                    {
                        Services.GenerationService.Generators.AddProfitBoost(
                            generatorId: item.TargetGenerator,
                            boost: BoostInfo.CreateTimed(
                                id: $"lootbox_{item.RewardType}_".GuidSuffix(5),
                                value: item.RewardValue,
                                endTime: Services.TimeService.UnixTimeInt + 600));
                    }
                }
                break;

            case LootboxRewardType.SpeedUpgrade:

                if (item.TargetGenerator == -1)
                {
                    Services.GenerationService.Generators.AddTimeBoost(
                        boost: BoostInfo.CreateTimed(
                            id: $"lootbox_{item.RewardType}_".GuidSuffix(5),
                            value: item.RewardValue,
                            endTime: Services.TimeService.UnixTimeInt + 600));
                }
                else
                {
                    if (Services.TransportService.HasUnits(item.TargetGenerator))
                    {
                        Services.GenerationService.Generators.AddTimeBoost(
                            generatorId: item.TargetGenerator,
                            boost: BoostInfo.CreateTimed(
                                id: $"lootbox_{item.RewardType}_".GuidSuffix(5),
                                value: item.RewardValue,
                                endTime: Services.TimeService.UnixTimeInt + 600));
                    }
                }
                break;

            case LootboxRewardType.Manager:
                // TODO : ??
                Debug.Log("TODO: implement Lootbox manager reward");
                break;

            case LootboxRewardType.Investors:
                //pdata.Investors += item.RewardValue;
                //pdata.LifeTimeInvestors += item.RewardValue;
                Services.PlayerService.AddSecurities(item.RewardValue.ToCurrencyNumber());
                break;

            case LootboxRewardType.Balance:
                Player.AddGenerationCompanyCash(item.RewardValue);
                break;

            case LootboxRewardType.Coins:
                Player.AddCoins((int)item.RewardValue);
                break;

            case LootboxRewardType.CoinsAndBalance:
                Player.AddGenerationCompanyCash(item.RewardValue);
                Player.AddCoins((int)item.RewardValue2);
                break;

            case LootboxRewardType.PercentBalance:
                var q = Services.PlayerService.CompanyCash.Value * item.RewardValue;
                if (q < 20)
                {
                    q = 20;
                }
                Player.AddGenerationCompanyCash(q);
                item.DescText = Currencies.DefaultCurrency.CreatePriceString(q, false, " ");
                break;

            default:
                break;
            }

            StatsCollector.Instance[Stats.REWARDS_UNLOCKED]++;
        }

        pdata.Save();

        Analytics.CustomEvent(AnalyticsStrings.LOOTBOX_OPEN);
    }