Пример #1
0
        public Projectile(Weapon Source)
        {
            HardCollisionWithTerrain = true;
            CollideWithWormsCheck = true;
            SourceWeapon = Source.Data;
            SourceWorm = Source.Carrier;

            RecentlyDamagedTargets.Add(Source.Carrier);
            RecentlyCollided.Add(Source.Carrier);
        }
Пример #2
0
        public void LoadConfiguration(string LevelDirectory)
        {
            const string GENERAL_CONFIG = "General";

            string INIPath = System.IO.Path.Combine(LevelDirectory, "Config.ini");

            if (System.IO.File.Exists(INIPath))
            {
                INIFile ConfigFile = new INIFile(INIPath);

                cGravity.X = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "GravityX"));
                cGravity.Y = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "GravityY"));

                cLifeMaximum = int.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "LifeMaximum"));
                cLifeStart   = int.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "LifeStarting"));

                cWormMass   = int.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormMass"));
                cWormSize.X = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormSizeX"));
                cWormSize.Y = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormSizeY"));
                cWormSpeed  = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormSpeed"));
                cWormJumpVelocityBonus.X = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormJumpVelocityX"));
                cWormJumpVelocityBonus.Y = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormJumpVelocityY"));

                cExplosionGroundDestructionPercent = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "ExplosionGroundDestructionPercent"));

                LoadWeaponData(System.IO.Path.Combine(LevelDirectory, "Weapons"));

                string DefaultWeapon = ConfigFile.IniReadValue(GENERAL_CONFIG, "DefaultWeapon");
                if (!string.IsNullOrEmpty(DefaultWeapon))
                {
                    if (Weapons.ContainsKey(DefaultWeapon))
                    {
                        cStartingWeapon = Weapons[DefaultWeapon];
                    }
                    else
                    {
                        Console.WriteLine("Error loading data - default weapon not found.");
                    }
                }
                else
                {
                    Console.WriteLine("Error loading data - default weapon string not found.");
                }
            }
            else
            {
                Console.WriteLine("Can't find file " + Path.GetFileName("Config.ini") + " from " + LevelName + ". Loading default configuration.");
            }
        }
Пример #3
0
        public void LoadWeaponData(string DirectoryPath)
        {
            DirectoryInfo WeaponDirectory = new DirectoryInfo(DirectoryPath);

            foreach (var File in WeaponDirectory.EnumerateFiles("*.ini"))
            {
                const string WeaponSection = "Weapon";
                INIFile      WeaponFile    = new INIFile(File.FullName);

                WeaponData NewWeapon = new WeaponData();

                if (WeaponFile.TryLoading(WeaponSection, "ProjectileDamage"))
                {
                    NewWeapon.ProjectileDamage = int.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileForce"))
                {
                    NewWeapon.ProjectileForce = int.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileExplosionRadius"))
                {
                    NewWeapon.ProjectileExplosionRadius = int.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileMass"))
                {
                    NewWeapon.ProjectileMass = float.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileSpeed"))
                {
                    NewWeapon.ProjectileSpeed = int.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileLifeTime"))
                {
                    NewWeapon.ProjectileLifeTime = float.Parse(WeaponFile.LastLoadedData());
                }

                if (WeaponFile.TryLoading(WeaponSection, "ChargeTime"))
                {
                    NewWeapon.ChargeTime = float.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "ChargeSpeedBonusStart"))
                {
                    NewWeapon.ChargeSpeedBonusStart = float.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "ChargeDamageBonusStart"))
                {
                    NewWeapon.ChargeDamageBonusStart = int.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "ChargeInaccuracyBonusUncharged"))
                {
                    NewWeapon.ChargeInaccuracyBonusUncharged = float.Parse(WeaponFile.LastLoadedData());
                }

                if (WeaponFile.TryLoading(WeaponSection, "SelfDamage"))
                {
                    NewWeapon.SelfDamage = bool.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "FirendlyFire"))
                {
                    NewWeapon.FirendlyFire = bool.Parse(WeaponFile.LastLoadedData());
                }


                if (WeaponFile.TryLoading(WeaponSection, "WeaponTexture"))
                {
                    NewWeapon.WeaponTexture = ResourceManager.GetTexture(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileTexture"))
                {
                    NewWeapon.ProjectileTexture = ResourceManager.GetTexture(WeaponFile.LastLoadedData());
                }

                if (WeaponFile.TryLoading(WeaponSection, "FireInterval"))
                {
                    NewWeapon.FireInterval = float.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "Recoil"))
                {
                    NewWeapon.Recoil = float.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "MagazineSize"))
                {
                    NewWeapon.MagazineSize = int.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "ReloadTime"))
                {
                    NewWeapon.ReloadTime = float.Parse(WeaponFile.LastLoadedData());
                }
                if (WeaponFile.TryLoading(WeaponSection, "Inaccuracy"))
                {
                    NewWeapon.Inaccuracy = float.Parse(WeaponFile.LastLoadedData());
                }

                NewWeapon.Name = File.Name.Substring(0, File.Name.LastIndexOf('.'));

                if (NewWeapon.WeaponTexture != null && NewWeapon.ProjectileTexture != null)
                {
                    Weapons.Add(NewWeapon.Name, NewWeapon);
                }
            }
        }
Пример #4
0
 public Weapon(Worm Owner, WeaponData WeaponData)
 {
     Data     = WeaponData;
     Carrier  = Owner;
     Magazine = WeaponData.MagazineSize;
 }
Пример #5
0
 public Weapon(Worm Owner, WeaponData WeaponData)
 {
     Data = WeaponData;
     Carrier = Owner;
     Magazine = WeaponData.MagazineSize;
 }
Пример #6
0
        public void LoadWeaponData(string DirectoryPath)
        {
            DirectoryInfo WeaponDirectory = new DirectoryInfo(DirectoryPath);

            foreach (var File in WeaponDirectory.EnumerateFiles("*.ini"))
            {
                const string WeaponSection = "Weapon";
                INIFile WeaponFile = new INIFile(File.FullName);

                WeaponData NewWeapon = new WeaponData();

                if(WeaponFile.TryLoading(WeaponSection, "ProjectileDamage"))
                    NewWeapon.ProjectileDamage = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileForce"))
                    NewWeapon.ProjectileForce = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileExplosionRadius"))
                    NewWeapon.ProjectileExplosionRadius = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileMass"))
                    NewWeapon.ProjectileMass = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileSpeed"))
                    NewWeapon.ProjectileSpeed = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileLifeTime"))
                    NewWeapon.ProjectileLifeTime = float.Parse(WeaponFile.LastLoadedData());

                if (WeaponFile.TryLoading(WeaponSection, "ChargeTime"))
                    NewWeapon.ChargeTime = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ChargeSpeedBonusStart"))
                    NewWeapon.ChargeSpeedBonusStart = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ChargeDamageBonusStart"))
                    NewWeapon.ChargeDamageBonusStart = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ChargeInaccuracyBonusUncharged"))
                    NewWeapon.ChargeInaccuracyBonusUncharged = float.Parse(WeaponFile.LastLoadedData());

                if (WeaponFile.TryLoading(WeaponSection, "SelfDamage"))
                    NewWeapon.SelfDamage = bool.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "FirendlyFire"))
                    NewWeapon.FirendlyFire = bool.Parse(WeaponFile.LastLoadedData());

                if (WeaponFile.TryLoading(WeaponSection, "WeaponTexture"))
                    NewWeapon.WeaponTexture = ResourceManager.GetTexture(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ProjectileTexture"))
                    NewWeapon.ProjectileTexture = ResourceManager.GetTexture(WeaponFile.LastLoadedData());

                if (WeaponFile.TryLoading(WeaponSection, "FireInterval"))
                    NewWeapon.FireInterval = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "Recoil"))
                    NewWeapon.Recoil = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "MagazineSize"))
                    NewWeapon.MagazineSize = int.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "ReloadTime"))
                    NewWeapon.ReloadTime = float.Parse(WeaponFile.LastLoadedData());
                if (WeaponFile.TryLoading(WeaponSection, "Inaccuracy"))
                    NewWeapon.Inaccuracy = float.Parse(WeaponFile.LastLoadedData());

                NewWeapon.Name = File.Name.Substring(0, File.Name.LastIndexOf('.'));

                if (NewWeapon.WeaponTexture != null && NewWeapon.ProjectileTexture != null)
                {
                    Weapons.Add(NewWeapon.Name, NewWeapon);
                }

            }
        }
Пример #7
0
        public void LoadConfiguration(string LevelDirectory)
        {
            const string GENERAL_CONFIG = "General";

            string INIPath = System.IO.Path.Combine(LevelDirectory, "Config.ini");
            if(System.IO.File.Exists(INIPath))
            {
                INIFile ConfigFile = new INIFile(INIPath);

                cGravity.X = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "GravityX"));
                cGravity.Y = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "GravityY"));

                cLifeMaximum = int.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "LifeMaximum"));
                cLifeStart = int.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "LifeStarting"));

                cWormMass = int.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormMass"));
                cWormSize.X = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormSizeX"));
                cWormSize.Y = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormSizeY"));
                cWormSpeed = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormSpeed"));
                cWormJumpVelocityBonus.X = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormJumpVelocityX"));
                cWormJumpVelocityBonus.Y = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "WormJumpVelocityY"));

                cExplosionGroundDestructionPercent = float.Parse(ConfigFile.IniReadValue(GENERAL_CONFIG, "ExplosionGroundDestructionPercent"));

                LoadWeaponData(System.IO.Path.Combine(LevelDirectory, "Weapons"));

                string DefaultWeapon = ConfigFile.IniReadValue(GENERAL_CONFIG, "DefaultWeapon");
                if(!string.IsNullOrEmpty(DefaultWeapon))
                {
                    if (Weapons.ContainsKey(DefaultWeapon))
                    {
                        cStartingWeapon = Weapons[DefaultWeapon];
                    }
                    else Console.WriteLine("Error loading data - default weapon not found."); //
                }
                else Console.WriteLine("Error loading data - default weapon string not found."); //

            }
            else
            {
                Console.WriteLine("Can't find file " + Path.GetFileName("Config.ini") + " from " + LevelName  + ". Loading default configuration."); //
            }
        }