Example #1
0
        public static Item GenerateRandomItem()
        {
            int result = Engine.RNG.Next(0, 100);

            if (result <= 17)
            {
                return(WeaponGenerator.GenerateRandomWeapon());
            }
            else if (result <= 34)
            {
                return(ConsumableGenerator.GeneratePotion());
            }
            else if (result <= 51)
            {
                return(ConsumableGenerator.GenerateScroll());
            }
            else if (result <= 68)
            {
                return(ArmorGenerator.GenerateRandomArmor());
            }
            else if (result <= 85)
            {
                return(MiscItemGenerator.GetRandomItem());
            }

            return(ConsumableGenerator.GenerateFood());
        }
Example #2
0
    public void EnemyDrops()
    {
        // Debug.Log("checking for enemy drops");
        WeaponGenerator weaponGenerator = gameObject.GetComponent <WeaponGenerator>();
        ArmorGenerator  armorGenerator  = gameObject.GetComponent <ArmorGenerator>();
        ItemGenerator   itemGenerator   = gameObject.GetComponent <ItemGenerator>();

        CheckItemDrop();

        if (isWeaponDrop)
        {
            // check for preset weapon chance
            CheckPresetWeapon();

            weaponGenerator.GenerateWeapon(presetWeapon);
            isWeaponDrop = false;
        }

        if (isArmorDrop)
        {
            // check for preset armor chance
            CheckPresetArmor();

            armorGenerator.GenerateArmor();
            isArmorDrop = false;
        }

        if (isItemDrop)
        {
            itemGenerator.GenerateItem();
            isItemDrop = false;
        }
    }
Example #3
0
        /// <summary>
        /// Генерация и выбор оружия для персонажа на основе переданных параметров.
        /// Если передается Any, то генерируем любое оружие. Если передается конкретный тип,
        /// то генерируем до тех пор, пока не попадется нужный тип оружия   
        /// </summary>
        /// <param name="name">Имя оружия для генерации. Any - рандомное оружие</param>
        /// <param name="game"></param>
        /// <returns></returns>
        public Weapon Generate(string name, Game game)
        {
            var weaponGenerator = new WeaponGenerator();
            var flag = true;

            if (name == "Any") {
                return weaponGenerator.Generate(game.Character);
            }

            do {
                weapon = weaponGenerator.Generate(game.Character);
                if (weapon.Mace) {
                    flag = name.ToLower() == "mace";
                }
                if (weapon.Sword) {
                    flag = name.ToLower() == "sword";
                }
                if (weapon.Dagger) {
                    flag = name.ToLower() == "dagger";
                }
                if (weapon.Staff) {
                    flag = name.ToLower() == "staff";
                }
                if (weapon.Bow) {
                    flag = name.ToLower() == "bow";
                }
            } while (!flag);

            return weapon;
        }
    // Adds a weapon to our inventory
    public bool AddWeapon(WeaponController weaponPrefab, string weaponName)
    {
        if (weaponName == null)
        {
            weaponName = weaponPrefab.weaponName;
        }

        if (HasWeapon(weaponName) || !canPickWeapons)
        {
            return(false);
        }

        // search our weapon slots for the first free one, assign the weapon to it, and return true if we found one. Return false otherwise
        for (int i = 0; i < m_WeaponSlots.Length; i++)
        {
            // only add the weapon if the slot is free
            if (m_WeaponSlots[i] == null)
            {
                // spawn the weapon prefab as child of the weapon socket
                WeaponController weaponInstance = Instantiate(weaponPrefab, weaponParentSocket);
                WeaponGenerator.modWeapon(weaponInstance, weaponName);
                // weaponInstance.weaponName = weaponName; //Name the instance, not the prefab!
                weaponInstance.transform.localPosition = Vector3.zero;
                weaponInstance.transform.localRotation = Quaternion.identity;

                // Set owner to this gameObject so the weapon can alter projectile/damage logic accordingly
                weaponInstance.owner        = gameObject;
                weaponInstance.sourcePrefab = weaponPrefab.gameObject;
                weaponInstance.ShowWeapon(false);

                // Assign the first person layer to the weapon
                int layerIndex = Mathf.RoundToInt(Mathf.Log(FPSWeaponLayer.value, 2)); // This function converts a layermask to a layer index
                foreach (Transform t in weaponInstance.gameObject.GetComponentsInChildren <Transform>(true))
                {
                    t.gameObject.layer = layerIndex;
                }

                m_WeaponSlots[i] = weaponInstance;

                if (onAddedWeapon != null)
                {
                    onAddedWeapon.Invoke(weaponInstance, i);
                }

                PlayerPrefs.SetString($"m_WeaponSlots[{i}]", weaponInstance.weaponName);
                //Debug.Log("Slot "+(i+1)+" = "+weaponInstance.weaponName);
                hasWeapons = true;

                return(true);
            }
        }

        // Handle auto-switching to weapon if no weapons currently
        if (GetActiveWeapon() == null)
        {
            SwitchWeapon(true);
        }

        return(false);
    }
Example #5
0
    // private ItemGenerator itemGenerator;

    void Start()
    {
        lootManager     = GameObject.Find("LootManager");
        armorGenerator  = lootManager.GetComponent <ArmorGenerator>();
        weaponGenerator = lootManager.GetComponent <WeaponGenerator>();
        // itemGenerator = lootManager.GetComponent<ItemGenerator>();
    }
Example #6
0
        Transform SpawnLauncher()
        {
            var launcher = Instantiate(LauncherPrefab).GetComponent <GrenadeLauncher>();

            launcher.Initialize(WeaponGenerator.GenerateNewGrenadeLauncher(ItemQuality.Common));
            return(launcher.transform);
        }
Example #7
0
    void OnDie()
    {
        // spawn a particle system when dying
        var vfx = Instantiate(deathVFX, deathVFXSpawnPoint.position, Quaternion.identity);

        Destroy(vfx, 5f);

        // tells the game flow manager to handle the enemy destruction
        m_EnemyManager.UnregisterEnemy(this);

        // drop unique loot with unpacked&modded prefabs
        var rnd = Random.value;

        Debug.Log($"Loot rnd={rnd}");
        if (rnd < 0.15)   //15% health
        {
            Debug.Log("Dropping health");
            var pickupObject = Resources.Load("Loot_Health");
            Instantiate(pickupObject, transform.position, Quaternion.identity);
        }
        else if (rnd < 0.3)     //15% weapons
        {
            WeaponGenerator.dropWeapon(transform.position);
        }
        else if (rnd < 0.45)     //15% ammo
        {
            var pickupObject = Resources.Load("Loot_Ammo");
            Instantiate(pickupObject, transform.position, Quaternion.identity);
        }   //70% nothing

        // this will call the OnDestroy function
        Destroy(gameObject, deathDuration);
    }
Example #8
0
        Transform SpawnShotgun()
        {
            var shotgun = Instantiate(ShotgunPrefab).GetComponent <Shotgun>();

            shotgun.Initialize(WeaponGenerator.GenerateNewShotgun(ItemQuality.Common));
            return(shotgun.transform);
        }
Example #9
0
        Transform SpawnMinigun()
        {
            var minigun = Instantiate(MinigunPrefab).GetComponent <Minigun>();

            minigun.Initialize(WeaponGenerator.GenerateNewMinigun(ItemQuality.Common));
            return(minigun.transform);
        }
Example #10
0
 private static void HandleGenerateWeapon(Random r, int number = 1)
 {
     for (int i = 0; i < number; i++)
     {
         Console.WriteLine(WeaponGenerator.Generate(r.Next()));
     }
 }
Example #11
0
        public void WeaponGen_CreateType_Generic()
        {
            var target = new WeaponGenerator();

            var sword = target.CreateType <Sword>();

            Assert.IsTrue(typeof(Sword).IsAssignableFrom(sword.GetType()));
        }
Example #12
0
        public void WeaponGen_CreateType_Specific()
        {
            var target = new WeaponGenerator();

            var sword = target.CreateType <ShortSword>();

            Assert.IsTrue(sword is ShortSword);
        }
Example #13
0
        public void WeaponGenTest_Specific()
        {
            var target = new WeaponGenerator();

            var type = target.PickType <ShortSword>();

            Assert.IsTrue(typeof(ShortSword) == type);
        }
Example #14
0
        public void WeaponGenTest()
        {
            var target = new WeaponGenerator();

            var type = target.PickType <Sword>();

            Assert.IsTrue(typeof(Sword).IsAssignableFrom(type));
        }
Example #15
0
        public void Randomize()
        {
            var body   = Instantiate(Repos.RifleRepo.GetRandomBody(), transform);
            var stock  = Instantiate(Repos.RifleRepo.GetRandomStock());
            var mag    = Instantiate(Repos.RifleRepo.GetRandomMag());
            var barrel = Instantiate(Repos.RifleRepo.GetRandomBarrel());

            Initialize(WeaponGenerator.GenerateNewRifle(ItemQuality.Common), body.transform, barrel.transform,
                       stock.transform, mag.transform);
        }
Example #16
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
 void Start()
 {
     audioS = GetComponent <AudioSource>();
     shopPanel.SetActive(false);
     playerShoot     = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <PlayerShoot>();
     playerInventory = GameObject.FindGameObjectWithTag("Player Inventory").GetComponentInChildren <Inventory>();
     genny           = GetComponent <WeaponGenerator>();
     do
     {
         generateNewWeapons();
     } while (!affordableWeaponsDayZero());
 }
Example #18
0
 private void Awake()
 {
     this.m_spriteRenderer   = GetComponent <SpriteRenderer>();
     this.m_rocketController = GetComponent <PlayerRocketMovement>();
     try
     {
         this.weaponGenerator = this.transform.Find("Weapon").GetComponent <WeaponGenerator>();
     }
     catch (NullReferenceException)
     {
         this.haveWeapon = false;
     }
     PlayerRocket.PlayerTransform = this.transform;
 }
Example #19
0
    /// <summary>
    /// Sets up the shops inventory and shooting script for later use.
    /// Generates weapons for the shop's inventory whenever the player enters
    /// the hub.
    /// </summary>
    private void Start()
    {
        audioS = GetComponent <AudioSource>();
        shopPanel.SetActive(false);
        playerShoot     = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <PlayerShoot>();
        playerInventory = GameObject.FindGameObjectWithTag("Player Inventory").GetComponentInChildren <Inventory>();
        genny           = GetComponent <WeaponGenerator>();

        // On the first day, the weapons generated should be reasonably affordable, otherwise, the game is impossible or unusually difficult, as the player would be forced to take out a payday loan
        do
        {
            generateNewWeapons();
        } while (!affordableWeaponsDayZero());
    }
Example #20
0
    private void Awake()
    {
        m_Random = new Random();

        m_HelmLog    = new FileLog(@"C:\Users\leeok\Desktop\helm.txt");
        m_ChestLog   = new FileLog(@"C:\Users\leeok\Desktop\chest.txt");
        m_LegsLog    = new FileLog(@"C:\Users\leeok\Desktop\legs.txt");
        m_WeaponsLog = new FileLog(@"C:\Users\leeok\Desktop\weapon.txt");

        m_HelmetGenerator     = new HelmetGenerator(m_Random, m_HelmLog);
        m_ChestplateGenerator = new ChestplateGenerator(m_Random, m_ChestLog);
        m_PlatelegsGenerator  = new PlatelegsGenerator(m_Random, m_LegsLog);
        m_WeaponGenerator     = new WeaponGenerator(m_Random, m_WeaponsLog);
    }
Example #21
0
    public static void dropWeapon(string weaponName, Vector3 position)
    {
        Debug.Log("Dropping a weapon: " + weaponName);
        var pickupObject   = Resources.Load("Pickup_Weapon"); //generic pickup object
        var pickupInstance = (GameObject)Instantiate(pickupObject, position, Quaternion.identity);
        var pickupMesh     = pickupInstance.transform.Find("Mesh");
        var weaponObject   = WeaponGenerator.getWeaponGameObject(weaponName);
        var weaponInstance = Instantiate(weaponObject, position, Quaternion.identity, pickupMesh);
        WeaponController weaponController = weaponInstance.GetComponentInChildren(typeof(WeaponController)) as WeaponController;

        WeaponGenerator.modWeapon(weaponController, weaponName);
        WeaponPickup weaponPickupComponent = pickupInstance.AddComponent(typeof(WeaponPickup)) as WeaponPickup;

        weaponPickupComponent.weaponPrefab = weaponController;
    }
Example #22
0
    private void Awake()
    {
        _enemyGenerator = GetComponent <EnemyGenerator>();
        if (_enemyGenerator == null)
        {
            throw new NullReferenceException("No EnemyGenerator on EnvironmentalSettings.");
        }

        _weaponGenerator = GetComponent <WeaponGenerator>();
        if (_weaponGenerator == null)
        {
            throw new NullReferenceException("No WeaponGenerator on EnvironmentalSettings.");
        }

        _enemyGenerator.SpawnBounds = _spawnBounds;

        _enemyGenerator.EnemyDestroyed += OnEnemyDestroyed;
        _enemyGenerator.CentreReached  += OnCentreReached;

        _weaponGenerator.SpawnBounds = _spawnBounds;
    }
Example #23
0
        public Weapon Generate(string name, Game game)
        {
            var weaponGenerator = new WeaponGenerator();
            var flag            = true;

            if (name == "Any")
            {
                return(weaponGenerator.Generate(game.Character));
            }

            do
            {
                weapon = weaponGenerator.Generate(game.Character);
                if (weapon.Mace)
                {
                    flag = name.ToLower() == "mace";
                }
                if (weapon.Sword)
                {
                    flag = name.ToLower() == "sword";
                }
                if (weapon.Dagger)
                {
                    flag = name.ToLower() == "dagger";
                }
                if (weapon.Staff)
                {
                    flag = name.ToLower() == "staff";
                }
                if (weapon.Bow)
                {
                    flag = name.ToLower() == "bow";
                }
            } while (!flag);

            return(weapon);
        }
 private void WeaponDropper()
 {
     if (m_InputHandler.GetDropWeaponInputDown() && isLoaded)
     {
         Debug.Log($"Dropping active weapon");
         WeaponController activeWeapon = GetActiveWeapon();
         if (activeWeapon != null)
         {
             /*
              *  Don't allow picking it back immediately.
              *  Once it's been created and we've ignored the pickup event, we can safely allow pickups again.
              *  Pickup won't be triggered once we allow pickups, but when player exits&returns.
              */
             canPickWeapons = false;
             RemoveWeapon(activeWeapon);
             WeaponGenerator.dropWeapon(activeWeapon.weaponName, transform.position);
         }
     }
     else if (!canPickWeapons)
     {
         //See comment above, should be safe to allow pickups now
         canPickWeapons = true;
     }
 }
Example #25
0
        void GenerateNewRifle()
        {
            var rifle = Instantiate(RiflePrefab, Platform).GetComponent <Rifle>();

            var body   = Instantiate(Repos.RifleRepo.GetRandomBody(), rifle.transform);
            var stock  = Instantiate(Repos.RifleRepo.GetRandomStock());
            var mag    = Instantiate(Repos.RifleRepo.GetRandomMag());
            var barrel = Instantiate(Repos.RifleRepo.GetRandomBarrel());

            var quality = Enum.GetValues(typeof(ItemQuality)).Cast <ItemQuality>().PickOne();

            rifle.Initialize(WeaponGenerator.GenerateNewRifle(quality), body.transform, barrel.transform, stock.transform, mag.transform);

            Panel.FillRifleStats(rifle.GetWeaponStats() as RifleStats);

            currentRifleStats = rifle.GetWeaponStats() as RifleStats;
            currentRifleData  = new RifleAssemblyData
            {
                BarrelId = barrel.GetComponent <AssemblyPart>().AssemblyPartId,
                BodyId   = body.GetComponent <AssemblyPart>().AssemblyPartId,
                StockId  = stock.GetComponent <AssemblyPart>().AssemblyPartId,
                MagId    = mag.GetComponent <AssemblyPart>().AssemblyPartId,
            };
        }
Example #26
0
        static void INSTALL(string inputSeed, bool skipAnimRandomizer = false)
        {
            Random random;

            if (inputSeed == "")
            {
                random = new Random();
            }
            else
            {
                random = new Random(inputSeed.GetHashCode());
            }

            if (MOD_PATH == null)
            {
                MOD_PATH = AskForDir();
            }
            else
            {
                Console.WriteLine("\nUse previously-specified game directory? (Y/N)");
                bool yes = ReadKey(ConsoleKey.Y, ConsoleKey.N) == ConsoleKey.Y;
                if (!yes)
                {
                    MOD_PATH = AskForDir();
                }
            }

            if (MOD_PATH == null)
            {
                Console.WriteLine("No EXE selected. Cancelling installation.");
                return;
            }

            DateTime startTime = DateTime.Now;

            Console.WriteLine("\nBeginning installation... This will take about one minute.");
            Console.WriteLine("\n" + SoyPuns.PopRandomElement(random) + "\n");

            SoulsMod mod = new SoulsMod(
                MOD_PATH, ".smbak",
                Resources.GameData.GameParam_parambnd,
                Resources.GameData.paramdef_paramdefbnd,
                Resources.GameData.item_msgbnd,
                Resources.GameData.menu_msgbnd);

            mod.LoadPlayerCharacter();
            mod.LoadNonPlayerCharacters();
            InstallInterrootFolder("event", mod);
            InstallInterrootFolder("map", mod);
            InstallInterrootFolder("script", mod);
            InstallInterrootFolder("sfx", mod);
            InstallInterrootFolder("sound", mod);


            PlayerGenerator playerSetup = new PlayerGenerator(mod);

#if DEBUG
            Console.WriteLine("Running player setup...");
#endif
            playerSetup.Install();
            Thread.CurrentThread.Join(0);

            TextGenerator textSetup = new TextGenerator(mod);
#if DEBUG
            Console.WriteLine("Running text setup...");
#endif
            textSetup.Install();
            Thread.CurrentThread.Join(0);

            SpEffectGenerator spEffectSetup = new SpEffectGenerator(mod);
#if DEBUG
            Console.WriteLine("Running SpEffect setup...");
#endif
            spEffectSetup.Install();
            Thread.CurrentThread.Join(0);

            GoodsGenerator goodsSetup = new GoodsGenerator(mod);
#if DEBUG
            Console.WriteLine("Running goods setup...");
#endif
            goodsSetup.Install();
            Thread.CurrentThread.Join(0);

            SpellGenerator spellSetup = new SpellGenerator(mod, random);
#if DEBUG
            Console.WriteLine("Running spell setup...");
#endif
            spellSetup.Install();
            Thread.CurrentThread.Join(0);

            WeaponGenerator weaponSetup = new WeaponGenerator(mod, random);
#if DEBUG
            Console.WriteLine("Running weapon setup...");
#endif
            weaponSetup.Install();
            Thread.CurrentThread.Join(0);

            ArmorGenerator armorSetup = new ArmorGenerator(mod, random);
#if DEBUG
            Console.WriteLine("Running armor setup...");
#endif
            armorSetup.Install();
            Thread.CurrentThread.Join(0);

            EnemyGenerator enemySetup = new EnemyGenerator(mod, random, weaponSetup, armorSetup);
#if DEBUG
            Console.WriteLine("Running enemy setup...");
#endif
            enemySetup.Install();
            Thread.CurrentThread.Join(0);

            MapItemLotsGenerator itemLotsSetup = new MapItemLotsGenerator(mod, weaponSetup, armorSetup, random);
#if DEBUG
            Console.WriteLine("Running item lot setup...");
#endif
            itemLotsSetup.Install();
            Thread.CurrentThread.Join(0);

            EnemyAnimationGenerator animSetup = new EnemyAnimationGenerator(mod, random);
#if DEBUG
            Console.WriteLine("Running animation setup...");
#endif
            animSetup.Install(skipAnimRandomizer);
            Thread.CurrentThread.Join(0);

            // Must be run AFTER weapon/armor setup.
            CharacterGenerator chrSetup = new CharacterGenerator(mod, random);
#if DEBUG
            Console.WriteLine("Running chr setup...");
#endif
            chrSetup.Install();
            Thread.CurrentThread.Join(0);

            Console.WriteLine(SoyPuns.PopRandomElement(random) + "\n");

#if DEBUG
            Console.WriteLine("Installing mod...");
#endif
            mod.Install();
            Thread.CurrentThread.Join(0);

#if DEBUG
            Console.WriteLine($"Installation time: {(DateTime.Now - startTime).TotalSeconds}");
#endif
        }
Example #27
0
 void Awake()
 {
     cur = this;
 }
    private void Update()
    {
        //Load stuff on first frame instead of Start() to ensure required components have been initialized
        if (!isLoaded)
        {
            // Load weapons once HUD is ready
            for (int i = 0; i < m_WeaponSlots.Length; i++)
            {
                if (PlayerPrefs.HasKey($"m_WeaponSlots[{i}]"))
                {
                    var        weaponName   = PlayerPrefs.GetString($"m_WeaponSlots[{i}]");
                    GameObject weaponPrefab = WeaponGenerator.getWeaponGameObject(weaponName);
                    if (weaponPrefab)
                    {
                        WeaponController weaponController =
                            (WeaponController)weaponPrefab.GetComponentInChildren(typeof(WeaponController));
                        AddWeapon(weaponController, weaponName);
                    }
                }
            }

            if (!hasWeapons)
            {
                var        weaponName   = "milk";
                GameObject weaponPrefab = WeaponGenerator.getWeaponGameObject(weaponName);
                if (weaponPrefab)
                {
                    WeaponController weaponController =
                        (WeaponController)weaponPrefab.GetComponentInChildren(typeof(WeaponController));
                    AddWeapon(weaponController, weaponName);
                }
            }

            if (PlayerPrefs.HasKey("activeWeaponIndex"))
            {
                SwitchToWeaponIndex(PlayerPrefs.GetInt("activeWeaponIndex"));
            }
            else
            {
                SwitchWeapon(true);
            }

            isLoaded = true;
        }

        // shoot handling
        WeaponController activeWeapon = GetActiveWeapon();

        if (activeWeapon && m_WeaponSwitchState == WeaponSwitchState.Up)
        {
            // handle aiming down sights
            isAiming = m_InputHandler.GetAimInputHeld();

            // handle shooting
            bool hasFired = activeWeapon.HandleShootInputs(
                m_InputHandler.GetFireInputDown(),
                m_InputHandler.GetFireInputHeld(),
                m_InputHandler.GetFireInputReleased());

            // Handle accumulating recoil
            if (hasFired)
            {
                m_AccumulatedRecoil += Vector3.back * activeWeapon.recoilForce;
                m_AccumulatedRecoil  = Vector3.ClampMagnitude(m_AccumulatedRecoil, maxRecoilDistance);
            }
        }

        // weapon switch handling
        if (!isAiming &&
            (activeWeapon == null || !activeWeapon.isCharging) &&
            (m_WeaponSwitchState == WeaponSwitchState.Up || m_WeaponSwitchState == WeaponSwitchState.Down))
        {
            int switchWeaponInput = m_InputHandler.GetSwitchWeaponInput();
            if (switchWeaponInput != 0)
            {
                bool switchUp = switchWeaponInput > 0;
                SwitchWeapon(switchUp);
            }
            else
            {
                switchWeaponInput = m_InputHandler.GetSelectWeaponInput();
                if (switchWeaponInput != 0)
                {
                    if (GetWeaponAtSlotIndex(switchWeaponInput - 1) != null)
                    {
                        SwitchToWeaponIndex(switchWeaponInput - 1);
                    }
                }
            }
        }

        // Pointing at enemy handling
        isPointingAtEnemy = false;
        if (activeWeapon)
        {
            if (Physics.Raycast(weaponCamera.transform.position, weaponCamera.transform.forward, out RaycastHit hit, 1000, -1, QueryTriggerInteraction.Ignore))
            {
                if (hit.collider.GetComponentInParent <EnemyController>())
                {
                    isPointingAtEnemy = true;
                }
            }
        }

        WeaponDropper();
    }
 public void Randomize()
 {
     Initialize(WeaponGenerator.GenerateNewGrenadeLauncher(ItemQuality.Common));
 }
Example #30
0
 private void GenerateWeapon_Click(object sender, RoutedEventArgs e)
 {
     Weapon = WeaponGenerator.GetCompletelyRandomWeapon();
     UpdateDisplay();
 }
Example #31
0
        static void INSTALL(string inputSeed)
        {
            Random random;

            random = inputSeed == "" ? new Random() : new Random(inputSeed.GetHashCode());

            MOD_PATH = GetGameDir();
            if (MOD_PATH == null)
            {
                Console.WriteLine("No EXE selected. Cancelling installation.");
                return;
            }

            DateTime startTime = DateTime.Now;

            Console.WriteLine("\nBeginning installation... This will take about one minute.");
            Console.WriteLine("\n" + SoyPuns.PopRandomElement(random) + "\n");

            SoulsMod mod = new SoulsMod(
                MOD_PATH, ".rsbak",
                Resources.GameData.GameParam_parambnd,
                Resources.GameData.paramdef_paramdefbnd,
                Resources.GameData.item_msgbnd,
                Resources.GameData.menu_msgbnd);

            mod.LoadPlayerCharacter();
            mod.LoadNonPlayerCharacters();
            InstallInterrootFolder("event", mod);
            InstallInterrootFolder("map", mod);
            InstallInterrootFolder("script", mod);
            InstallInterrootFolder("sfx", mod);
            InstallInterrootFolder("sound", mod);

            TextGenerator textSetup = new TextGenerator(mod);

#if DEBUG
            Console.WriteLine("Running text setup...");
#else
            Console.WriteLine("Studying the ancient texts...");
#endif
            textSetup.Install();
            Thread.CurrentThread.Join(0);

            PlayerGenerator playerSetup = new PlayerGenerator(mod);
#if DEBUG
            Console.WriteLine("Running player setup...");
#else
            Console.WriteLine("Putting the party together...");
#endif
            playerSetup.Install();
            Thread.CurrentThread.Join(0);

            SpEffectGenerator spEffectSetup = new SpEffectGenerator(mod);
#if DEBUG
            Console.WriteLine("Running SpEffect setup...");
#else
            Console.WriteLine("Channeling the powers that be...");
#endif
            spEffectSetup.Install();
            Thread.CurrentThread.Join(0);

            GoodsGenerator goodsSetup = new GoodsGenerator(mod);
#if DEBUG
            Console.WriteLine("Running goods setup...");
#else
            Console.WriteLine("Documenting the artifacts...");
#endif
            goodsSetup.Install();
            Thread.CurrentThread.Join(0);

            SpellGenerator spellSetup = new SpellGenerator(mod, random);
#if DEBUG
            Console.WriteLine("Running spell setup...");
#else
            Console.WriteLine("Messing with forces beyond our control...");
#endif
            spellSetup.Install();
            Thread.CurrentThread.Join(0);

            WeaponGenerator weaponSetup = new WeaponGenerator(mod, random);
#if DEBUG
            Console.WriteLine("Running weapon setup...");
#else
            Console.WriteLine("Spinning up the whetstone...");
#endif
#if SKIP_BEHAVIORS
            Console.WriteLine("WARNING: Skipping weapon behaviors/attacks!");
            weaponSetup.SkipBehaviors = true;
#endif
            weaponSetup.Install();
            Thread.CurrentThread.Join(0);

            ArmorGenerator armorSetup = new ArmorGenerator(mod, random);
#if DEBUG
            Console.WriteLine("Running armor setup...");
#else
            Console.WriteLine("Polishing the armor...");
#endif
            armorSetup.Install();
            Thread.CurrentThread.Join(0);

            EnemyGenerator enemySetup = new EnemyGenerator(mod, random, weaponSetup, armorSetup);
#if DEBUG
            Console.WriteLine("Running enemy setup...");
#else
            Console.WriteLine("Opening the bestiary...");
#endif
            enemySetup.Install();
            Thread.CurrentThread.Join(0);

            EnemyAnimationGenerator animSetup = new EnemyAnimationGenerator(mod, random);
#if DEBUG
            Console.WriteLine("Modifying enemy animations...");
#else
            Console.WriteLine("Rousing the rabble...");
#endif
            animSetup.Install();
            Thread.CurrentThread.Join(0);

            MapItemLotsGenerator itemLotsSetup = new MapItemLotsGenerator(mod, weaponSetup, armorSetup, random);
#if DEBUG
            Console.WriteLine("Running item lot setup...");
#else
            Console.WriteLine("Burying the treasures...");
#endif
            itemLotsSetup.Install();
            Thread.CurrentThread.Join(0);

            // Must be run AFTER weapon/armor setup.
            CharacterGenerator chrSetup = new CharacterGenerator(mod, random);
#if DEBUG
            Console.WriteLine("Running character setup...");
#else
            Console.WriteLine("Assembling the party...");
#endif
            chrSetup.Install();
            Thread.CurrentThread.Join(0);

#if DEBUG
            Console.WriteLine("Installing mod...");
#else
            Console.WriteLine("Heading forth...");
#endif
            mod.Install();
            Thread.CurrentThread.Join(0);

            Console.WriteLine("\nInstallation successful! Press ENTER to return to the prompt.");
#if DEBUG
            Console.WriteLine($"Installation time: {(DateTime.Now - startTime).TotalSeconds} seconds");
#endif
            Console.ReadLine();
        }
Example #32
0
    void Loot()
    {
        int temp = Random.Range(0, 3);

        if (temp == 0)
        {
            BaseArmour tempArmour = ArmourGenerator.generate(ctr);
            switch (tempArmour.Armour)
            {
            case (BaseArmour.ArmourTypes.HELMET):
                equip = tempArmour;
                break;

            case (BaseArmour.ArmourTypes.CHEST):
                equip2 = tempArmour;
                break;

            case (BaseArmour.ArmourTypes.BOOTS):
                equip3 = tempArmour;
                break;
            }
            Debug.Log("Armour drop");
        }
        else if (temp == 1)
        {
            weap = WeaponGenerator.generate(ctr);
            Debug.Log("Weapon drop");
        }
        else if (temp == 2)
        {
            BasePotion tempPot = PotionGenerator.generate(ctr);
            if (string.Compare(pot1.ItemName, "Empty") == 0)
            {
                pot1 = tempPot;
            }
            else if (string.Compare(pot2.ItemName, "Empty") == 0)
            {
                pot2 = tempPot;
            }
            else if (string.Compare(pot3.ItemName, "Empty") == 0)
            {
                pot3 = tempPot;
            }
            Debug.Log("Potion drop");
        }
        int diffrence = maxStamina - currStamina;

        maxStamina  = 40 + equip.Stamina + equip2.Stamina + equip3.Stamina + weap.Stamina;
        currStamina = 40 + equip.Stamina + equip2.Stamina + equip3.Stamina + weap.Stamina - diffrence;
        if (currStamina > maxStamina)
        {
            currStamina = maxStamina;
        }
        strength     = 3 + equip.Strength + equip2.Strength + equip3.Strength + weap.Strength;
        initiative   = 7 + equip.Initiative + equip2.Initiative + equip3.Initiative + weap.Initiative;
        weapon.text  = "Weapon: " + weap.ItemName;
        arm1.text    = "Helmet: " + equip.ItemName;
        arm2.text    = "Chestplate: " + equip2.ItemName;
        arm3.text    = "Boots: " + equip3.ItemName;
        potion1.text = "Potion1: " + pot1.ItemName;
        potion2.text = "Potion2: " + pot2.ItemName;
        potion3.text = "Potion3: " + pot3.ItemName;
    }