Exemplo n.º 1
0
 /// <summary>
 /// Used by tests
 /// </summary>
 /// <param name="Damage"></param>
 /// <param name="AffectedByGravity"></param>
 /// <param name="ProjectileSpeed"></param>
 public Weapon(float Damage, bool AffectedByGravity, float ProjectileSpeed)
 {
     this.Damage          = Damage;
     ActiveProjectileInfo = new ProjectileInfo();
     ActiveProjectileInfo.AffectedByGravity = AffectedByGravity;
     ActiveProjectileInfo.ProjectileSpeed   = ProjectileSpeed;
     NumberOfProjectiles = 1;
 }
Exemplo n.º 2
0
        public ProjectileBox(float Damage, ExplosionOptions ExplosionAttributes, RobotAnimation Owner,
                             Vector2 Position, Vector2 Size, float Angle, ProjectileInfo ActiveProjectileInfo)
            : base(Damage, ExplosionAttributes, Owner, false)
        {
            this.ActiveProjectileInfo = ActiveProjectileInfo;
            this.AffectedByGravity    = ActiveProjectileInfo.AffectedByGravity;

            this.Speed = new Vector2((float)Math.Cos(Angle) * ActiveProjectileInfo.ProjectileSpeed, (float)Math.Sin(Angle) * ActiveProjectileInfo.ProjectileSpeed);

            ProjectileAnimation          = ActiveProjectileInfo.ProjectileAnimation.Copy();
            ProjectileAnimation.Position = Position;

            if (ActiveProjectileInfo.TrailAnimation != null)
            {
                TrailAnimation          = ActiveProjectileInfo.TrailAnimation.Copy();
                TrailAnimation.Position = Position;
            }
            if (ActiveProjectileInfo.RotatationAllowed)
            {
                this.Angle = Angle;

                if (ProjectileAnimation != null)
                {
                    ProjectileAnimation.Angle = Angle;
                }

                if (TrailAnimation != null)
                {
                    TrailAnimation.Angle = Angle;
                }
            }

            Owner.SetAttackContext(this, Owner, Angle, Position);

            float MinX = Position.X - Size.X / 2f;
            float MinY = Position.Y - Size.Y / 2f;
            float MaxX = MinX + Size.X;
            float MaxY = MinY + Size.Y;


            Polygon NewPolygon = new Polygon();

            NewPolygon.ArrayVertex    = new Vector2[4];
            NewPolygon.ArrayVertex[0] = new Vector2(MinX, MinY);
            NewPolygon.ArrayVertex[1] = new Vector2(MaxX, MaxY);
            NewPolygon.ArrayVertex[2] = new Vector2(MaxX, MaxY);
            NewPolygon.ArrayVertex[3] = new Vector2(MinX, MinY);

            NewPolygon.ComputePerpendicularAxis();
            NewPolygon.ComputerCenter();

            Collision.ListCollisionPolygon = new List <Polygon>(1)
            {
                NewPolygon
            };
            Collision.ComputeCenterAndRadius();
            this.Collision.Position = Position;
        }
Exemplo n.º 3
0
        public Weapon(string Path, Dictionary <string, BaseSkillRequirement> DicRequirement, Dictionary <string, BaseEffect> DicEffects)
        {
            this.Name = Path;
            FileStream   FS = new FileStream("Content/Triple Thunder/Weapons/" + Path + ".ttw", FileMode.Open, FileAccess.Read);
            BinaryReader BR = new BinaryReader(FS, Encoding.UTF8);

            string NoneComboName     = BR.ReadString();
            string MovingComboName   = BR.ReadString();
            string RunningComboName  = BR.ReadString();
            string DashComboName     = BR.ReadString();
            string AirborneComboName = BR.ReadString();

            Damage        = BR.ReadSingle();
            MaxDurability = BR.ReadSingle();
            MinAngle      = BR.ReadSingle();
            MaxAngle      = BR.ReadSingle();
            bool   UseRangedProperties = BR.ReadBoolean();
            string SkillChainName      = BR.ReadString();

            if (!string.IsNullOrWhiteSpace(SkillChainName) && DicRequirement != null)
            {
                FileStream   FSSkillChain = new FileStream("Content/Triple Thunder/Skill Chains/" + SkillChainName + ".pesc", FileMode.Open, FileAccess.Read);
                BinaryReader BRSkillChain = new BinaryReader(FSSkillChain, Encoding.UTF8);
                BRSkillChain.BaseStream.Seek(0, SeekOrigin.Begin);

                int tvSkillsNodesCount = BRSkillChain.ReadInt32();
                ListActiveSkill = new List <BaseAutomaticSkill>(tvSkillsNodesCount);
                for (int N = 0; N < tvSkillsNodesCount; ++N)
                {
                    BaseAutomaticSkill ActiveSkill = new BaseAutomaticSkill(BRSkillChain, DicRequirement, DicEffects);

                    InitSkillChainTarget(ActiveSkill);

                    ListActiveSkill.Add(ActiveSkill);
                }

                BRSkillChain.Close();
                FSSkillChain.Close();
            }
            else
            {
                ListActiveSkill = new List <BaseAutomaticSkill>();
            }

            ExplosionAttributes = new ExplosionOptions(BR);

            if (UseRangedProperties)
            {
                AmmoPerMagazine = BR.ReadSingle();

                AmmoCurrent = AmmoPerMagazine;

                AmmoRegen           = BR.ReadSingle();
                Recoil              = BR.ReadSingle();
                MaxRecoil           = BR.ReadSingle();
                RecoilRecoverySpeed = BR.ReadSingle();
                NumberOfProjectiles = BR.ReadInt32();
                ProjectileType      = (ProjectileTypes)BR.ReadInt32();
                string ReloadAnimation = BR.ReadString();

                if (ProjectileType == ProjectileTypes.Projectile)
                {
                    ProjectileSize       = new Vector2(5, 2);
                    ActiveProjectileInfo = new ProjectileInfo(BR);
                    ArrayProjectileInfo  = new ProjectileInfo[1] {
                        ActiveProjectileInfo
                    };

                    NozzleFlashAnimation          = new SimpleAnimation();
                    NozzleFlashAnimation.Name     = "Nozzle Flash";
                    NozzleFlashAnimation.Path     = "Fire 1_strip5";
                    NozzleFlashAnimation.IsLooped = false;
                }

                if (!string.IsNullOrEmpty(ReloadAnimation))
                {
                    ReloadCombo = new Combo(ReloadAnimation);
                }
            }

            if (!string.IsNullOrEmpty(NoneComboName))
            {
                NoneCombo = new Combo(NoneComboName);
            }

            if (!string.IsNullOrEmpty(MovingComboName))
            {
                MovingCombo = new Combo(MovingComboName);
            }

            if (!string.IsNullOrEmpty(RunningComboName))
            {
                RunningCombo = new Combo(RunningComboName);
            }

            if (!string.IsNullOrEmpty(DashComboName))
            {
                DashCombo = new Combo(DashComboName);
            }

            if (!string.IsNullOrEmpty(AirborneComboName))
            {
                AirborneCombo = new Combo(AirborneComboName);
            }

            BR.Close();
            FS.Close();
        }
Exemplo n.º 4
0
        public WeaponBase(BinaryReader BR, string OwnerName, string WeaponPath, Dictionary <string, BaseSkillRequirement> DicRequirement,
                          Dictionary <string, BaseEffect> DicEffects, Dictionary <string, AutomaticSkillTargetType> DicAutomaticSkillTarget)
            : this(OwnerName, WeaponPath)
        {
            Damage              = BR.ReadSingle();
            MaxDurability       = BR.ReadSingle();
            MinAngle            = BR.ReadSingle();
            MaxAngle            = BR.ReadSingle();
            UseRangedProperties = BR.ReadBoolean();
            string SkillChainName = BR.ReadString();

            if (!string.IsNullOrWhiteSpace(SkillChainName) && DicRequirement != null)
            {
                FileStream   FSSkillChain = new FileStream("Content/Triple Thunder/Skill Chains/" + SkillChainName + ".pesc", FileMode.Open, FileAccess.Read);
                BinaryReader BRSkillChain = new BinaryReader(FSSkillChain, Encoding.UTF8);
                BRSkillChain.BaseStream.Seek(0, SeekOrigin.Begin);

                int tvSkillsNodesCount = BRSkillChain.ReadInt32();
                ListActiveSkill = new List <BaseAutomaticSkill>(tvSkillsNodesCount);
                for (int N = 0; N < tvSkillsNodesCount; ++N)
                {
                    BaseAutomaticSkill ActiveSkill = new BaseAutomaticSkill(BRSkillChain, DicRequirement, DicEffects, DicAutomaticSkillTarget);

                    InitSkillChainTarget(ActiveSkill, DicAutomaticSkillTarget);

                    ListActiveSkill.Add(ActiveSkill);
                }

                BRSkillChain.Close();
                FSSkillChain.Close();
            }
            else
            {
                ListActiveSkill = new List <BaseAutomaticSkill>();
            }

            ExplosionAttributes = new ExplosionOptions(BR);

            if (UseRangedProperties)
            {
                AmmoPerMagazine = BR.ReadSingle();

                AmmoCurrent = AmmoPerMagazine;

                AmmoRegen           = BR.ReadSingle();
                Recoil              = BR.ReadSingle();
                MaxRecoil           = BR.ReadSingle();
                RecoilRecoverySpeed = BR.ReadSingle();
                NumberOfProjectiles = BR.ReadInt32();
                ProjectileType      = (ProjectileTypes)BR.ReadInt32();

                if (ProjectileType == ProjectileTypes.Projectile)
                {
                    ProjectileSize       = new Vector2(5, 2);
                    ActiveProjectileInfo = new ProjectileInfo(BR);
                    ArrayProjectileInfo  = new ProjectileInfo[1] {
                        ActiveProjectileInfo
                    };

                    NozzleFlashAnimation          = new SimpleAnimation();
                    NozzleFlashAnimation.Name     = "Nozzle Flash";
                    NozzleFlashAnimation.Path     = "Fire 1_strip5";
                    NozzleFlashAnimation.IsLooped = false;
                }
            }
        }