Esempio n. 1
0
        /// <summary>
        /// Populate the listboxes with turret and tank models
        /// </summary>
        private void PopulateBoxes()
        {
            //Populate turrets

            weapons = WeaponLoader.GetWeaponsAsList();
            List <object> weaponNames = new List <object>();

            foreach (Weapon weapon in weapons)
            {
                weaponNames.Add(weapon.Name);
            }

            form.Turrets = weaponNames;
            form.Tanks   = Utils.GetTankModels();

            Scene scene = ServiceManager.Game.Renderer.ActiveScene;

            selectedTankRenderID = scene.Add(
                ServiceManager.Resources.GetModel("tanks\\" + form.Tanks[0]),
                Vector3.Zero, 0);
            selectedTank = scene.Access3D(selectedTankRenderID);

            selectedTurretRenderID = scene.Add(
                ServiceManager.Resources.GetModel("weapons\\" + weapons[0].Model),
                Vector3.Zero, 0);
            selectedTurret = scene.Access3D(selectedTurretRenderID);
            selectedTurret.Attach(selectedTank, "Mount");
        }
Esempio n. 2
0
        /// <summary>
        /// Event handler for when the user selects a different turret
        /// </summary>
        void TurretSelectionChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            Weapon selectedWeapon = weapons[form.TurretIndex];

            form.TurretPower = Utils.ConvertPowerToProgressBar(
                selectedWeapon.Projectile.AverageDamage);
            form.TurretRange = Utils.ConvertRangeToProgressBar(selectedWeapon.Projectile.Range);
            form.TurretRate  = Utils.ConvertRateToProgressBar(
                selectedWeapon.Cooldown);

            Scene scene = ServiceManager.Game.Renderer.ActiveScene;

            scene.Delete(selectedTurretRenderID);

            selectedTurretRenderID = ServiceManager.Game.Renderer.ActiveScene.Add(
                ServiceManager.Resources.GetModel("weapons\\" + selectedWeapon.Model),
                Vector3.Zero, 0);
            float oldRotation = selectedTurret.ZRotation;

            selectedTurret = scene.Access3D(selectedTurretRenderID);
            selectedTurret.Attach(selectedTank, "Mount");
            selectedTurret.ZRotation = oldRotation;

            ApplySkin();
        }
Esempio n. 3
0
        /// <summary>
        /// Populate the listboxes with turret and tank models
        /// </summary>
        private void PopulateBoxes()
        {
            List <object> turrets = new List <object>();

            //Populate turrets

            weapons = WeaponLoader.GetWeaponsAsList();

            foreach (Weapon weapon in weapons)
            {
                turrets.Add(weapon.Name);
            }

            form.Turrets = turrets;
            form.Tanks   = Utils.GetTankModels();

            Renderer.SceneTools.Scene scene = ServiceManager.Scene;

            selectedTankRenderID = scene.Add(
                ServiceManager.Resources.GetModel("tanks\\" + tank.model),
                Vector3.Zero, 0);
            selectedTank = scene.Access3D(selectedTankRenderID);

            selectedTurretRenderID = scene.Add(
                ServiceManager.Resources.GetModel("weapons\\" + WeaponLoader.GetWeapon(tank.weaponID).Model),
                Vector3.Zero, 0);
            selectedTurret = scene.Access3D(selectedTurretRenderID);
            selectedTurret.Attach(selectedTank, Constants.TURRET_MOUNT);
        }
Esempio n. 4
0
        /// <summary>
        /// Event handler for when the user selects a different tank
        /// </summary>
        void TankSelectionChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            Scene scene = ServiceManager.Game.Renderer.ActiveScene;

            scene.Delete(selectedTankRenderID);

            selectedTankRenderID = scene.Add(
                ServiceManager.Resources.GetModel("tanks\\" + form.Tanks[form.TankIndex]),
                Vector3.Zero, 0);
            float oldRotation = selectedTank.ZRotation;

            selectedTank = scene.Access3D(selectedTankRenderID);
            selectedTurret.Attach(selectedTank, "Mount");
            selectedTank.ZRotation = oldRotation;

            ApplySkin();
        }
Esempio n. 5
0
        void TankSelectionChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            Renderer.SceneTools.Scene scene = ServiceManager.Scene;
            scene.Delete(selectedTankRenderID);

            selectedTankRenderID = scene.Add(
                ServiceManager.Resources.GetModel("tanks\\" + form.Tanks[form.TankIndex]),
                Vector3.Zero, 0);
            float oldRotation = selectedTank.ZRotation;

            selectedTank = scene.Access3D(selectedTankRenderID);
            selectedTurret.Attach(selectedTank, Constants.TURRET_MOUNT);
            selectedTank.ZRotation = oldRotation;

            selectedTankModelName = (string)form.Tanks[form.TankIndex];
            ApplySkin();
        }
Esempio n. 6
0
        /// <summary>
        /// Add a player to the player list, overwriting any existing member
        /// whose key is also "key".
        /// </summary>
        /// <param name="key">Key of the tank. This is the tank's name. Should be unique.</param>
        /// <param name="value">The tank object stored.</param>
        public void Add(int key, PlayerTank value)
        {
            if (players.ContainsKey(key))
            {
                Remove(key);
            }

            if (value.RenderID != -1)
            {
                throw new Exception("Integrity error: Player already in renderer.");
            }

            int id = ServiceManager.Scene.Add(value, 2);

            value.RenderID = id;

            Microsoft.Xna.Framework.Graphics.Model turretModel =
                ServiceManager.Resources.GetModel(
                    "weapons\\" + value.Weapon.Model);
            Object3 turret = new Object3(turretModel,
                                         Vector3.Zero); // The turret's position shouldn't matter since it's being
                                                        // attached to the tank.

            int turretId = ServiceManager.Scene.Add(turret, 0);

            if (value.HealthBar != null)
            {
                int healthBarId = ServiceManager.Scene.Add(value.HealthBar, 4);
                value.HealthBarRenderID = healthBarId;
            }

            if (value.NameObject != null)
            {
                int nameBarId = ServiceManager.Scene.Add(value.NameObject, 4);
                value.NameObjectRenderID = nameBarId;
            }

            turret.Attach(value, Constants.TURRET_MOUNT);
            value.SetTurret(turretId, turret);
            players.Add(key, value);
        }