Esempio n. 1
0
 /// <summary>
 /// Creates new itemStat and adds it to the database
 /// </summary>
 /// <param name="id">ID of the item, used to access it from the DB</param>
 /// <param name="Min">Min amount for the stat at level 1</param>
 /// <param name="Max">Max amount for the stat at level 1</param>
 /// <param name="name">Name of the stat, what should be displayed in the item context menu</param>
 /// <param name="rarity">range 0-7</param>
 /// <param name="LvlPower">How much should it increase per level(min max values will be powered to this amount)</param>
 public ItemStat(int id, float Min, float Max, float LvlPower, string name, int rarity, OnEquipDelegate onEquip = null, OnUnequipDelegate onUnequip = null, OnConsumeDelegate onConsume = null)
 {
     LevelPow  = LvlPower;
     StatID    = id;
     MaxAmount = Max;
     MinAmount = Min;
     Name      = name;
     Rarity    = rarity;
     OnEquip   = onEquip;
     OnUnequip = onUnequip;
     OnConsume = onConsume;
     ItemDataBase.AddStat(this);
 }
Esempio n. 2
0
 /// <summary>
 /// Creates new itemStat and adds it to the database
 /// </summary>
 /// <param name="id">ID of the item, used to access it from the DB</param>
 /// <param name="Min">Min amount for the stat at level 1</param>
 /// <param name="Max">Max amount for the stat at level 1</param>
 /// <param name="name">Name of the stat, what should be displayed in the item context menu</param>
 /// <param name="rarity">range 0-7</param>
 /// <param name="LvlPower">How much should it increase per level(min max values will be powered to this amount)</param>
 public ItemStat(int id, float Min, float Max, float LvlPower, string name, StatCompare comparingMethod, int rarity, Func <string> getValueFunc, OnEquipDelegate onEquip = null, OnUnequipDelegate onUnequip = null, OnConsumeDelegate onConsume = null)
 {
     comparing    = comparingMethod;
     LevelPow     = LvlPower;
     StatID       = id;
     MaxAmount    = Max;
     MinAmount    = Min;
     Name         = name;
     Rarity       = rarity;
     OnEquip      = onEquip;
     OnUnequip    = onUnequip;
     OnConsume    = onConsume;
     GetTotalStat = getValueFunc;
     ItemDataBase.AddStat(this);
 }
Esempio n. 3
0
        public static void Initialize()
        {
            try
            {
                ModSettings.DifficultyChoosen = false;
                if (SceneManager.GetActiveScene().name == "TitleScene")
                {
                    new GameObject("Resource Manager").AddComponent <Res.ResourceLoader>();
                    Res.ResourceLoader.InMainMenu = true;
                }
                else
                {
                    Res.ResourceLoader.InMainMenu = false;

                    new GameObject("NetworkManagerObj").AddComponent <Network.NetworkManager>();
                    GameObject go = new GameObject("Playerobj");
                    go.AddComponent <ModdedPlayer>();
                    go.AddComponent <Inventory>();
                    go.AddComponent <ModReferences>();
                    go.AddComponent <SpellCaster>();
                    go.AddComponent <ClinetItemPicker>();
                    go.AddComponent <MeteorSpawner>();
                    BuffDB.FillBuffList();
                    ItemDataBase.Initialize();
                    SpellDataBase.Initialize();
                    EnemyManager.Initialize();
                    new GameObject("MainMenuObj").AddComponent <MainMenu>();
                    Network.NetworkManager.instance.onGetMessage += Network.CommandReader.OnCommand;
                    Res.Buildings.InitBuildings();
                    Perk.FillPerkList();
                }
            }
            catch (Exception ex)
            {
                ModAPI.Log.Write(ex.ToString());
            }
        }
Esempio n. 4
0
        private void GroupStats()
        {
            var grouped = new Dictionary <int, List <float> >();

            foreach (var stat in Stats)
            {
                if (grouped.ContainsKey(stat.StatID))
                {
                    grouped[stat.StatID].Add(stat.Amount);
                }
                else
                {
                    grouped.Add(stat.StatID, new List <float>()
                    {
                        stat.Amount
                    });
                }
            }
            groupedStats = new Dictionary <int, float>(grouped.Count);
            foreach (var group in grouped)
            {
                groupedStats.Add(group.Key, ItemDataBase.StatByID(group.Key).EvaluateTotalIncrease(group.Value));
            }
        }
Esempio n. 5
0
        public static void Initialize()
        {
            try
            {
                ModSettings.Version = ModAPI.Mods.LoadedMods["ChampionsOfForest"].Version;
                if (SteamDSConfig.isDedicated)
                {
                    ModAPI.Log.Write("isDedicated true");
                    ModSettings.IsDedicated = true;
                }

                if (ModSettings.IsDedicated)
                {
                    DedicatedServer.COTFDS.ReadDediServerConfig();
                    new GameObject("NetworkManagerObj").AddComponent <Network.NetworkManager>();
                    GameObject go = new GameObject("Playerobj");
                    go.AddComponent <ModReferences>();
                    ItemDataBase.Initialize();
                    EnemyManager.Initialize();
                    Network.NetworkManager.instance.onGetMessage += Network.CommandReader.OnCommand;
                    ExpEvents.Initialize();
                    return;
                }

                ModSettings.DifficultyChosen = false;
                if (SceneManager.GetActiveScene().name == "TitleScene")
                {
                    new GameObject("Resource Manager").AddComponent <ResourceLoader>();
                    ResourceLoader.InMainMenu = true;
                    MainMenuVisual.Create();
                }
                else
                {
                    ResourceLoader.InMainMenu = false;
                    NetworkPlayerStats.Reset();
                    COTFEvents.ClearEvents();

                    new GameObject("NetworkManagerObj").AddComponent <Network.NetworkManager>();
                    GameObject go           = new GameObject("__COTFPlayerobj__");
                    var        moddedPlayer = go.AddComponent <ModdedPlayer>();
                    moddedPlayer.SetStats();
                    go.AddComponent <Inventory>();
                    go.AddComponent <ModReferences>();
                    go.AddComponent <SpellCaster>();
                    go.AddComponent <ClientItemPicker>();
                    go.AddComponent <MeteorSpawner>();
                    go.AddComponent <BlackFlame>();
                    go.AddComponent <AsyncHit>();
                    go.AddComponent <GlobalSFX>();
                    go.AddComponent <TheFartCreator>();
                    go.AddComponent <RCoroutines>();
                    go.AddComponent <ActiveSpellManager>();
                    new GameObject("MainMenuObj").AddComponent <MainMenu>();


                    // go.AddComponent<Crafting>();
                    Network.CommandInitializer.Init();
                    CustomCrafting.Init();
                    BuffDB.FillBuffList();
                    ItemDataBase.Initialize();
                    SpellDataBase.Initialize();
                    EnemyManager.Initialize();
                    Network.NetworkManager.instance.onGetMessage += Network.CommandReader.OnCommand;
                    Buildings.InitBuildings();
                    PerkDatabase.FillPerkList();
                    ExpEvents.Initialize();
                    Portal.InitializePortals();
                    CoopCustomWeapons.Init();
                    BallLightning.InitPrefab();
                    ResourceInitializer.SetupMeshesFromOtherAssets();
                    Cataclysm.AssignPrefabs();
                    MarkEnemy.AssignTextures();
                }
            }
            catch (Exception ex)
            {
                ModAPI.Log.Write(ex.ToString());
            }
        }
Esempio n. 6
0
        public bool OnDie()
        {
            try
            {
                if (GameSetup.IsMpClient)
                {
                    return(true);
                }
                if (setup.waterDetect.drowned)
                {
                    return(true);
                }
                if (abilities.Contains(Abilities.DoubleLife))
                {
                    if (!DualLifeSpend)
                    {
                        DualLifeSpend  = true;
                        _Health.Health = _Health.maxHealth / 2;
                        _Health.MySkin.material.color = Color.magenta;
                        prerainDmg *= 2;

                        _Health.releaseFromTrap();
                        return(false);
                    }
                }

                //if (abilities.Contains(Abilities.Molten))
                //{
                //    //not working, find a fix or replacement
                //    //BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position, Quaternion.identity);
                //    //BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position + Vector3.right * 2, Quaternion.identity);
                //    //BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position + Vector3.left * 2, Quaternion.identity);
                //    //BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position + Vector3.forward * 2, Quaternion.identity);
                //    //BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position + Vector3.back * 2, Quaternion.identity);

                //}
                if (OnDieCalled)
                {
                    return(true);
                }
                EnemyManager.RemoveEnemy(this);
                if (Random.value <= 0.1f || _AI.creepy_boss || abilities.Count > 0)
                {
                    int itemCount = Random.Range(1, 6);
                    if (_AI.creepy_boss)
                    {
                        itemCount += 14;
                    }
                    else if (abilities.Count >= 3)
                    {
                        itemCount += Random.Range(3, 6);
                    }
                    if (type == EnemyType.Boss)
                    {
                        itemCount += 4;
                    }
                    if (type == EnemyType.Miniboss)
                    {
                        itemCount += 2;
                    }
                    for (int i = 0; i < itemCount; i++)
                    {
                        Network.NetworkManager.SendItemDrop(ItemDataBase.GetRandomItem(Bounty, enemyType), transform.position + Vector3.up * (2.5f + i / 4));
                    }
                    if (enemyType == Enemy.Megan && (int)ModSettings.difficulty > 6)
                    {
                        //Drop megan only amulet
                        Network.NetworkManager.SendItemDrop(new Item(ItemDataBase.ItemBases[80], 1, 2), transform.position + Vector3.up * 3);
                    }
                }
                if (GameSetup.IsMpServer)
                {
                    Network.NetworkManager.SendLine("KX" + Convert.ToInt64(Bounty / (Mathf.Max(1, 0.8f + ModReferences.Players.Count * 0.2f))) + ";", Network.NetworkManager.Target.Everyone);
                }
                else if (GameSetup.IsSinglePlayer)
                {
                    ModdedPlayer.instance.AddKillExperience(Bounty);
                }
                OnDieCalled = true;
                timeOfDeath = 60;
            }
            catch (Exception ex)
            {
                ModAPI.Log.Write("DIEING ENEMY EXCEPTION  " + ex.ToString());
            }

            return(true);
        }
Esempio n. 7
0
        public static void Initialize()
        {
            try
            {
                ModSettings.Version = ModAPI.Mods.LoadedMods["ChampionsOfForest"].Version;

                if (SteamDSConfig.isDedicated)
                {
                    ModAPI.Log.Write("isDedicated true");
                    ModSettings.IsDedicated = true;
                }

                if (ModSettings.IsDedicated)
                {
                    ReadDediServerConfig();



                    new GameObject("NetworkManagerObj").AddComponent <Network.NetworkManager>();
                    GameObject go = new GameObject("Playerobj");
                    //go.AddComponent<ModdedPlayer>();
                    //go.AddComponent<Inventory>();
                    go.AddComponent <ModReferences>();
                    //go.AddComponent<SpellCaster>();
                    //go.AddComponent<ClinetItemPicker>();
                    //go.AddComponent<MeteorSpawner>();
                    //BuffDB.FillBuffList();
                    ItemDataBase.Initialize();
                    //SpellDataBase.Initialize();
                    EnemyManager.Initialize();
                    //new GameObject("MainMenuObj").AddComponent<MainMenu>();
                    Network.NetworkManager.instance.onGetMessage += Network.CommandReader.OnCommand;
                    //Res.Buildings.InitBuildings();
                    ExpEvents.Initialize();
                    return;
                }

                ModSettings.DifficultyChoosen = false;
                if (SceneManager.GetActiveScene().name == "TitleScene")
                {
                    new GameObject("Resource Manager").AddComponent <Res.ResourceLoader>();
                    Res.ResourceLoader.InMainMenu = true;
                }
                else
                {
                    Res.ResourceLoader.InMainMenu = false;

                    new GameObject("NetworkManagerObj").AddComponent <Network.NetworkManager>();
                    GameObject go = new GameObject("__COTFPlayerobj__");
                    go.AddComponent <ModdedPlayer>();
                    go.AddComponent <Inventory>();
                    go.AddComponent <ModReferences>();
                    go.AddComponent <SpellCaster>();
                    go.AddComponent <ClinetItemPicker>();
                    go.AddComponent <MeteorSpawner>();
                    go.AddComponent <BlackFlame>();
                    BuffDB.FillBuffList();
                    ItemDataBase.Initialize();
                    SpellDataBase.Initialize();
                    EnemyManager.Initialize();
                    new GameObject("MainMenuObj").AddComponent <MainMenu>();
                    Network.NetworkManager.instance.onGetMessage += Network.CommandReader.OnCommand;
                    Res.Buildings.InitBuildings();
                    Perk.FillPerkList();
                    ExpEvents.Initialize();
                    Portal.InitializePortals();
                }
            }
            catch (Exception ex)
            {
                ModAPI.Log.Write(ex.ToString());
            }
        }
Esempio n. 8
0
        public bool OnDie()
        {
            try
            {
                //ModAPI.Console.Write("Enemy Dies, \nhealth left "+ _Health.Health+ "\n OnDieCalled "+ OnDieCalled.ToString()+"\nDrowned "+ setup.waterDetect.drowned);
                if (setup.waterDetect.drowned)
                {
                    ModAPI.Console.Write("enemy exp giving canceled, enemy drowned");
                    ModAPI.Log.Write("enemy exp giving canceled, enemy drowned");
                    return(true);
                }
                if (abilities.Contains(Abilities.DoubleLife))
                {
                    if (!DualLifeSpend)
                    {
                        DualLifeSpend  = true;
                        _Health.Health = _Health.maxHealth / 2;
                        _Health.MySkin.material.color = Color.magenta;
                        prerainDmg *= 2;

                        _Health.releaseFromTrap();
                        return(false);
                    }
                }

                if (abilities.Contains(Abilities.Molten))
                {
                    //not working, find a fix or replacement
                    //BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position, Quaternion.identity);
                    //BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position + Vector3.right * 2, Quaternion.identity);
                    //BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position + Vector3.left * 2, Quaternion.identity);
                    //BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position + Vector3.forward * 2, Quaternion.identity);
                    //BoltNetwork.Instantiate(BoltPrefabs.instantDynamite, transform.position + Vector3.back * 2, Quaternion.identity);
                }
                if (OnDieCalled)
                {
                    ModAPI.Console.Write("enemy exp giving canceled, enemy already died");
                    ModAPI.Log.Write("enemy exp giving canceled, enemy already died");
                    return(true);
                }
                Invoke("ReanimateMe", 15);
                EnemyManager.RemoveEnemy(this);
                if (Random.value < 0.2f || _AI.creepy_boss || abilities.Count >= 2)
                {
                    int itemCount = Random.Range(1, 4);
                    if (_AI.creepy_boss)
                    {
                        itemCount += 12;
                    }
                    else if (abilities.Count >= 2)
                    {
                        itemCount += Random.Range(2, 5);
                    }
                    for (int i = 0; i < itemCount; i++)
                    {
                        Network.NetworkManager.SendItemDrop(ItemDataBase.GetRandomItem(Bounty, enemyType), transform.position + Vector3.up * 3);
                    }
                    if (enemyType == Enemy.Megan && (int)ModSettings.difficulty > 6)
                    {
                        //Drop megan only amulet
                        Network.NetworkManager.SendItemDrop(new Item(ItemDataBase.ItemBases[80], 1, 2), transform.position + Vector3.up * 3);
                    }
                }
                if (GameSetup.IsMultiplayer)
                {
                    Network.NetworkManager.SendLine("KX" + Convert.ToInt64(Bounty / (Mathf.Max(1, ModReferences.Players.Count * 0.75f))) + ";", Network.NetworkManager.Target.Everyone);
                }
                else
                {
                    ModdedPlayer.instance.AddKillExperience(Bounty);
                }
                OnDieCalled = true;
                timeOfDeath = 10;
            }
            catch (Exception ex)
            {
                ModAPI.Log.Write("DIEING ENEMY EXCEPTION  " + ex.ToString());
            }

            return(true);
        }