public void PopulateRandom(int x) { for (int cnt = 0; cnt < x; cnt++) { loot.Add(ItemGenerator.CreateRandomItem()); } _used = true; }
public void GenerateRandomItems() { int numItems = 16; for (int i = 0; i < numItems; i++) { AddItem(ItemGenerator.CreateRandomItem(ItemTypeAllowed.Any, 10, 10)); //Debug.Log(items[i].Name + " generated"); } }
// やりこみモード専用処理 // スコア:バルーンを倒した数に関連して増える。 // ライフ:時間が立つ、物を投げる、と減る。バルーンを倒すと増える。アイテムでも増える。ゼロでゲーム終了 private void YarikomiProc() { // 時間計測 TimeValue += Time.deltaTime; ItemGenTime += Time.deltaTime; // Missing処理 ShowMissing(); // スコア計算 ScorePoint = ScorePoint + DestroyedBalloonCount * currentRank * ((100 - LifePoint) / 10 + 20); // 死にかけはポイント高め // ライフポイント計算 UpdateLifePoint(); // 乳酸ポイント計算 UpdateNyusanPoint(); // ランクアップ処理 RankUpYarikomi(ScorePoint); // 定期的に増えるバルーン(DestroyedBalloonCountの初期化タイミングに注意) if (DestroyedBalloonCount > 0 || MissingBalloonCount > 0) { balloonController.CreateRandomBalloon(DestroyedBalloonCount + MissingBalloonCount); DestroyedBalloonCount = 0; MissingBalloonCount = 0; } // 定期的に増えるアイテム if (ItemGenTime > ItemGenInterval) { itemGenerator.CreateRandomItem(1); ItemGenTime = 0; } // ヘッダーの更新 UpdateYarikomiHeaderContents(ScorePoint, LifePoint, NyusanPoint); if (LifePoint <= 0) // ゲーム終了 { gameMode.GameMode = GameModeController.eGameMode.BeforeResult; var obj = GameObject.Find("YarikomiDescription"); if (obj != null) { obj.GetComponent <Text>().text = "そこまで!!"; obj.GetComponent <Text>().color = new Color(0, 0, 0, 1); obj.GetComponent <Text>().fontSize = 120; } Invoke("ResultSubproc", 4f); scoreMng.SaveYarikomiScoreToLocal(ScorePoint); } // 初期化処理は最後 InitializeCounts(); }
public static PcData Generate(int listIndex, Gender gender, string r, string p) { //if (availableRaces == null || availableProfessions == null) return null; string race_key = ""; if (r == "") { race_key = availableRaces[Random.Range(0, availableRaces.Count)]; } else { race_key = r; } string professionKey = ""; if (p == "") { professionKey = availableProfessions[Random.Range(0, availableProfessions.Count)]; } else { professionKey = p; } Race race = Database.GetRace(race_key); Profession profession = Database.GetProfession(professionKey); string hair = ""; string beard = ""; if (gender == Gender.None) { if (Random.Range(0, 100) < 50) { gender = Gender.Male; if (race.maleDefaultHair != "") { hair = "Hair " + Random.Range(1, 9); } if (race.maleDefaultBeard != "" && Random.Range(0, 100) < 50) { beard = "Beard " + Random.Range(1, 8); } } else { gender = Gender.Female; if (race.femaleDefaultHair != "") { hair = "Hair " + Random.Range(1, 17); } beard = race.femaleDefaultBeard; } } else if (gender == Gender.Male) { gender = Gender.Male; if (race.maleDefaultHair != "") { hair = "Hair " + Random.Range(1, 9); } if (race.maleDefaultBeard != "" && Random.Range(0, 100) < 50) { beard = "Beard " + Random.Range(1, 8); } } else if (gender == Gender.Female) { gender = Gender.Female; if (race.femaleDefaultHair != "") { hair = "Hair " + Random.Range(1, 17); } beard = race.femaleDefaultBeard; } PcData pc = new PcData(NameGenerator.Get(gender, race_key, professionKey), gender, 1, race_key, professionKey, hair, beard, listIndex, -1, 3 + GameValue.Roll(new GameValue(1, 3), false), 3 + GameValue.Roll(new GameValue(1, 3), false)); pc.Background = BackgroundGenerator.Generate(); pc.Personality = GeneratePersonality(); pc.Description = GenerateDescription(pc); pc.LevelUp(); pc.CalculateExp(); pc.AddExperience(Random.Range(0, 999), false); if (profession.StartingItems.Count > 0) { for (int i = 0; i < profession.StartingItems.Count; i++) { ItemData item = ItemGenerator.CreateItem(profession.StartingItems[i].ItemKey, profession.StartingItems[i].MaterialKey, profession.StartingItems[i].PlusKey, profession.StartingItems[i].PreKey, profession.StartingItems[i].PostKey, profession.StartingItems[i].StackSize); if (race.ArmorSlotAllowed((EquipmentSlot)item.Slot) == true) { pc.Inventory.EquipItem(item, ((EquipmentSlot)item.Slot)); } } } else { for (int i = 0; i < pc.Inventory.EquippedItems.Length; i++) { if (Database.GetRace(race_key).ArmorSlotAllowed(((EquipmentSlot)i)) == true) { int chanceForItem = 25; if (i == (int)EquipmentSlot.Right_Hand) { chanceForItem = 100; } else if (i == (int)EquipmentSlot.Body) { chanceForItem = 100; } else if (i == (int)EquipmentSlot.Feet) { chanceForItem = 100; } if (Random.Range(1, 101) <= chanceForItem) { ItemData item = ItemGenerator.CreateRandomItem(i, 25, 25); if (item != null) { pc.Inventory.EquippedItems[i] = new ItemData(item); } } } } } int numAccessories = Random.Range(1, 3); pc.Inventory.AccessoryLimit = numAccessories + Random.Range(0, 3); for (int i = 0; i < numAccessories; i++) { pc.Inventory.EquipAccessory(ItemGenerator.CreateRandomItem(ItemTypeAllowed.Accessory, 0, 0), -1); } for (int spell = 0; spell < pc.Abilities.KnownSpells.Count; spell++) { if (Random.Range(0, 100) < 100) { pc.Abilities.KnownSpells[spell].BoostRune = Helper.RandomValues <string, AbilityModifier>(Database.Runes).Key; } } string key = positiveQuirks[Random.Range(0, positiveQuirks.Count)]; pc.Abilities.AddTrait(new Ability(Database.GetAbility(key))); key = neutralQuirks[Random.Range(0, neutralQuirks.Count)]; pc.Abilities.AddTrait(new Ability(Database.GetAbility(key))); key = negativeQuirks[Random.Range(0, negativeQuirks.Count)]; pc.Abilities.AddTrait(new Ability(Database.GetAbility(key))); if (GameValue.Roll(1, 100) < 20) { key = woundQuirks[Random.Range(0, woundQuirks.Count)]; pc.Abilities.AddTrait(new Ability(Database.GetAbility(key))); } pc.CalculateAttributeModifiers(); pc.CalculateStartAttributes(true); pc.CalculateDerivedAttributes(); pc.CalculateStartSkills(); pc.CalculateResistances(); pc.CalculateExpCosts(); pc.Abilities.PowerSlots = (pc.Attributes.GetAttribute(AttributeListType.Derived, (int)BaseAttribute.Memory).Current / 5) + 1; pc.Abilities.SpellSlots = (pc.Attributes.GetAttribute(AttributeListType.Derived, (int)BaseAttribute.Memory).Current / 5) + 1; pc.Abilities.FindTraits(); pc.Abilities.FindAvailableAbilities(); //pc.AddExperience(Random.Range(0, 500) * 10, false); pc.CalculateUpkeep(); return(pc); }