コード例 #1
0
        /// <summary>
        /// Add any projectiles that are in the 'add later' collection.
        /// </summary>
        public void AddDelayedProjectiles()
        {
            if (projectilesToAddLater.Count == 0)
            {
                return;
            }

            List <ProjectileToAddLater> toRemove = new List <ProjectileToAddLater>();

            foreach (ProjectileToAddLater proj in projectilesToAddLater)
            {
                if (proj.timestamp <= Network.Util.Clock.GetTimeMilliseconds())
                {
                    this.Add(proj.projInfo.projectileId, CreateProjectileObject(
                                 WeaponLoader.GetProjectile(proj.projInfo.projectileTypeId),
                                 proj.projInfo.target, proj.angle, proj.owner));
                    proj.owner.TurretAngle = -proj.angle;
                    toRemove.Add(proj);
                }
            }

            foreach (ProjectileToAddLater proj in toRemove)
            {
                projectilesToAddLater.Remove(proj);
            }
        }
コード例 #2
0
        /// <summary>
        /// Create a ProjectileManager.
        /// </summary>
        /// <param name="_camera">The camera is used to draw the objects.</param>
        public ProjectileManager()
        {
            projectiles           = new Dictionary <int, Projectile>();
            projectilesToAddLater = new List <ProjectileToAddLater>();
            activeSounds          = new Dictionary <int, Audio.SoundCue>();

            if (soundEffectBank == null)
            {
                soundEffectBank = new Dictionary <int, string>();

                List <Weapon> weapons = WeaponLoader.GetWeaponsAsList();
                foreach (Weapon weapon in weapons)
                {
                    if (!soundEffectBank.ContainsKey(weapon.ProjectileID))
                    {
                        soundEffectBank[weapon.ProjectileID] = weapon.FiringSound;
                    }
                }
            }
        }
コード例 #3
0
ファイル: WeaponLoader.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Get the ProjectileData object from the raw strings from the XML
        /// </summary>
        /// <param name="rawProjectileValues">The string values from the XML</param>
        /// <param name="emitters">The projectile's emitters</param>
        /// <param name="animations">The projectile's animations</param>
        /// <returns>A ProjectileData object.</returns>
        private static ProjectileData GetProjectileFromStrings(Dictionary <string, string> rawProjectileValues,
                                                               List <Weapon.ParticleEmitter> emitters,
                                                               List <Weapon.ModelAnimation> animations)
        {
            bool valid = true;

            int    id   = HandleIdVal(rawProjectileValues["id"], out valid);
            string name = HandleNameVal(rawProjectileValues["name"], out valid);

            if (valid == false)
            {
                return(null);
            }

            string model                  = rawProjectileValues["modelName"];
            float  projectileScale        = HandleFloatVal(rawProjectileValues["scale"]);
            string particleEffectName     = rawProjectileValues["particleEffectName"];
            string impactParticleName     = rawProjectileValues["impactParticleName"];
            string impactSoundEffect      = rawProjectileValues["impactSoundEffect"];
            string expirationParticleName = rawProjectileValues["expirationParticleName"];
            int    areaOfEffectRadius     = HandleIntVal(rawProjectileValues["areaOfEffectRadius"]);
            bool   areaOfEffectUsesCone   = HandleBoolVal(rawProjectileValues["areaOfEffectUsesCone"]);
            float  areaOfEffectDecay      = HandleFloatVal(rawProjectileValues["areaOfEffectDecay"]);
            int    coneRadius             = HandleIntVal(rawProjectileValues["coneRadius"]);
            int    coneOriginWidth        = HandleIntVal(rawProjectileValues["coneOriginWidth"]);
            bool   coneDamagesEntireArea  = HandleBoolVal(rawProjectileValues["coneDamagesEntireArea"]);
            int    minDamage              = HandleIntVal(rawProjectileValues["minDamage"]);
            int    maxDamage              = HandleIntVal(rawProjectileValues["maxDamage"]);
            bool   isInstantaneous        = HandleBoolVal(rawProjectileValues["isInstantaneous"]);
            int    initialVelocity        = HandleIntVal(rawProjectileValues["initialVelocity"]);
            int    terminalVelocity       = HandleIntVal(rawProjectileValues["terminalVelocity"]);
            int    acceleration           = HandleIntVal(rawProjectileValues["acceleration"]);
            int    range                  = HandleIntVal(rawProjectileValues["range"]);
            int    rangeVariation         = HandleIntVal(rawProjectileValues["rangeVariation"]);
            int    jumpRange              = HandleIntVal(rawProjectileValues["jumpRange"]);
            float  jumpDamageDecay        = HandleFloatVal(rawProjectileValues["jumpDamageDecay"]);
            int    jumpCount              = HandleIntVal(rawProjectileValues["jumpCount"]);
            float  collisionRadius        = HandleFloatVal(rawProjectileValues["collisionRadius"]);
            int    environmentEffectID    = HandleIntVal(rawProjectileValues["environmentEffectID"]);

            return(new ProjectileData(id, name, model, projectileScale, particleEffectName, impactParticleName, impactSoundEffect, expirationParticleName,
                                      emitters, animations, areaOfEffectRadius, areaOfEffectUsesCone, areaOfEffectDecay, coneRadius, coneOriginWidth, coneDamagesEntireArea,
                                      minDamage, maxDamage, isInstantaneous, initialVelocity, terminalVelocity, acceleration, range, rangeVariation, jumpRange,
                                      jumpDamageDecay, jumpCount, environmentEffectID, collisionRadius, WeaponLoader.GetEnvironmentProperty(environmentEffectID)));
        }
コード例 #4
0
        /// <summary>
        /// Constructs a new player tank, which also initializes it's inner Object3 class.
        /// </summary>
        /// <param name="_tankModel">Model to load into the tank.</param>
        /// <param name="_attr"></param>
        /// <param name="_pos"></param>
        /// <param name="_alive"></param>
        /// <param name="_angle"></param>
        /// <param name="_id"></param>
        /// <param name="_team"></param>
        public PlayerTank(Model _tankModel,
                          VTankObject.TankAttributes _attr,
                          Vector3 _pos,
                          bool _alive,
                          float _angle,
                          int _id,
                          GameSession.Alliance _team)
            : base(_tankModel, _pos)
        {
            hoverValue      = new HoverTranslation();
            activeUtilities = new List <ActiveUtility>();
            utilities       = new List <Utility>();
            assistList      = new List <int>();
            emitters        = new List <ParticleEmitter>();
            attributes      = _attr;
            position        = _pos;

            if (_attr.model == "Icarus")
            {
                this.Translate(new Vector3(0, 0, 20));
                this.AddEmitters();
            }

            alive                 = _alive;
            Angle                 = _angle;
            ID                    = _id;
            RenderID              = -1;
            TurretRenderID        = -1;
            HealthBarRenderID     = -1;
            Team                  = _team;
            weapon                = WeaponLoader.GetWeapon(attributes.weaponID);
            elapsed               = weapon.Cooldown;
            LastDirectionMovement = VTankObject.Direction.NONE;
            PreviouslyCollidied   = false;
            IsCharging            = false;

            /*AlternateModelTexture = ServiceManager.Resources.Load<Texture2D>(
             *  @"models\tanks\skins\camo-forest");
             */

            if (_attr.name != PlayerManager.LocalPlayerName)
            {
                HealthBar  = new HealthBar(position, attributes.health);
                NameObject = new TextObject();
                NameObject.SetText(attributes.name);
            }

            if (Team == GameSession.Alliance.BLUE)
            {
                meshColor = Color.Blue;
            }
            else if (Team == GameSession.Alliance.RED)
            {
                meshColor = Color.Red;
            }
            else
            {
                meshColor = Toolkit.GetColor(attributes.color);
            }

            SetUpSphereBoundaries();
            ApplyTankSkin();
        }