Beispiel #1
0
 public void SetPool(Pool pool)
 {
     paths = pool.GetGroup(Matcher.PathsModel);
     enemies = pool.GetGroup(Matcher.EnemiesModel);
     difficulty = pool.GetGroup(Matcher.DifficultyController);
     enemyCreator = new EnemyCreator(pool);
     bossCreator = new BossCreator(pool);
     weaponProvider = new WeaponProvider();
     Random.seed = pool.count;
 }
Beispiel #2
0
    IEnumerator DayCycle()
    {
        for (; ;)
        {
            yield return(new WaitForSeconds(Constants.DayDuration));

            timeOfDay = 0;
            foreach (var c in ContractSuppliers)
            {
                foreach (var t in c.TypesSelling)
                {
                    for (int i = 0; i < t.Value; i++)
                    {
                        WeaponStock.AddRange(WeaponProvider.CreateWeapon(t.Key, c.QualitySelling).MakeStock(6));
                        switch (t.Key)
                        {
                        case WeaponType.Handgun:
                            Money -= (int)(100 * c.SellRate);
                            break;

                        case WeaponType.SMG:
                            Money -= (int)(200 * c.SellRate);
                            break;

                        case WeaponType.MachineGun:
                            Money -= (int)(400 * c.SellRate);
                            break;

                        case WeaponType.Explosives:
                            Money -= (int)(800 * c.SellRate);
                            break;
                        }
                    }
                }
            }



            foreach (var n in ContractedBuyers)
            {
                var toRemove = new List <Buyer>();
                foreach (var b in n.Value)
                {
                    var canSell = true;
                    foreach (var t in b.TypesBuying)
                    {
                        if (WeaponStock.Where(w => w.Type == t.Key).Count() < t.Value)
                        {
                            canSell = false;
                            break;
                        }
                    }
                    if (!canSell)
                    {
                        AffectRespect(-0.025f, n.Key);
                        continue;
                    }
                    var cargo    = Instantiate(Manager.CargoPrefab, new Vector3(-22.5f, 5, 7.5f), Quaternion.Euler(0, 0, 0)) as GameObject;
                    var behavior = cargo.GetComponent <CargoBehavior>();
                    behavior.Dealer = this;
                    behavior.Buyer  = b;
                    behavior.Block  = n.Key;
                    b.Duration--;
                    if (b.Duration == 0)
                    {
                        toRemove.Add(b);
                    }
                    foreach (var t in b.TypesBuying)
                    {
                        for (int u = 0; u < t.Value; u++)
                        {
                            var weapon = WeaponStock.Where(w => w.Type == t.Key).First();
                            WeaponStock.Remove(weapon);
                        }
                    }
                    AffectRespect(0.05f, n.Key);
                    Money += b.Price;
                }
                foreach (var r in toRemove)
                {
                    n.Value.Remove(r);
                }
            }
        }
    }