예제 #1
0
 public Attack(string Name, string Description, int Price, string PowerFormula, int RangeMin, int RangeMax, WeaponPrimaryProperty Pri, WeaponSecondaryProperty Sec,
               int Hit, int Crit, int AmmoMax, int ENCost, int MoraleRequirement, string Type, Dictionary <string, char> DicTerrainAttribute)
     : base(Name, Description, Price)
 {
     ArrayAttackAttributes = new BaseAutomaticSkill[0];
     this.PowerFormula     = PowerFormula;
     this.RangeMinimum     = RangeMin;
     this.RangeMaximum     = RangeMax;
     this.Pri                 = Pri;
     this.Sec                 = Sec;
     this.Accuracy            = Hit;
     this.Critical            = Crit;
     this.MaxAmmo             = AmmoMax;
     this.ENCost              = ENCost;
     this.MoraleRequirement   = MoraleRequirement;
     this.AttackType          = Type;
     this.DicTerrainAttribute = DicTerrainAttribute;
 }
예제 #2
0
        public void SaveItem(BinaryWriter BW)
        {
            string Description = txtDescription.Text;

            int ENCost            = Convert.ToInt32(txtENCost.Value);
            int MaximumAmmo       = Convert.ToInt32(txtMaximumAmmo.Value);
            int MoraleRequirement = Convert.ToInt32(txtMoraleRequirement.Value);
            int MinimumRange      = Convert.ToInt32(txtMinimumRange.Value);
            int MaximumRange      = Convert.ToInt32(txtMaximumRange.Value);
            int Accuracy          = Convert.ToInt32(txtAccuracy.Value);
            int Critical          = Convert.ToInt32(txtCritical.Value);

            WeaponPrimaryProperty PrimaryProperty = WeaponPrimaryProperty.None;

            if (rbMAP.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.MAP;
            }
            else if (rbPLA.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.PLA;
            }
            else if (rbALL.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.ALL;
            }
            else if (rbBREAK.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.Break;
            }
            else if (rbMULTI.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.Multi;
            }
            else if (rbDASH.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.Dash;
            }
            else if (rbPER.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.PER;
            }

            WeaponSecondaryProperty SecondaryProperty = WeaponSecondaryProperty.None;

            if (cbPostMovement.Checked)
            {
                SecondaryProperty = SecondaryProperty | WeaponSecondaryProperty.PostMovement;
            }
            if (cbSwordCut.Checked)
            {
                SecondaryProperty = SecondaryProperty | WeaponSecondaryProperty.SwordCut;
            }
            if (cbShootDown.Checked)
            {
                SecondaryProperty = SecondaryProperty | WeaponSecondaryProperty.ShootDown;
            }
            if (cbPartialAttack.Checked)
            {
                SecondaryProperty = SecondaryProperty | WeaponSecondaryProperty.Partial;
            }

            int AttackType = 0;

            if (rbAttackTypeMelee.Checked)
            {
                AttackType = 1;
            }
            else if (rbAttackTypeSolidBlade.Checked)
            {
                AttackType = 2;
            }
            else if (rbAttackTypeEnergyBlade.Checked)
            {
                AttackType = 3;
            }
            else if (rbAttackTypeSolidShot.Checked)
            {
                AttackType = 4;
            }
            else if (rbAttackTypeEnergyShot.Checked)
            {
                AttackType = 5;
            }
            else if (rbAttackTypeRemote.Checked)
            {
                AttackType = 6;
            }
            else if (rbAttackTypeSpecial.Checked)
            {
                AttackType = 7;
            }

            int TerrainGradeAir   = cbAirRank.SelectedIndex;
            int TerrainGradeLand  = cbLandRank.SelectedIndex;
            int TerrainGradeSea   = cbSeaRank.SelectedIndex;
            int TerrainGradeSpace = cbSpaceRank.SelectedIndex;

            //Create the Part file.
            BW.Write(Description);

            BW.Write(txtDamage.Text);
            BW.Write(txtMinDamage.Text);
            BW.Write(ENCost);
            BW.Write(MaximumAmmo);
            BW.Write(MoraleRequirement);
            BW.Write(MinimumRange);
            BW.Write(MaximumRange);
            BW.Write(Accuracy);
            BW.Write(Critical);

            BW.Write((byte)PrimaryProperty);
            if (PrimaryProperty == WeaponPrimaryProperty.MAP)
            {
                if (MAPAttackEditor != null)
                {
                    BW.Write(MAPAttackEditor.AttackWidth);
                    BW.Write(MAPAttackEditor.AttackHeight);
                    for (int X = 0; X < MAPAttackEditor.AttackWidth * 2 + 1; X++)
                    {
                        for (int Y = 0; Y < MAPAttackEditor.AttackHeight * 2 + 1; Y++)
                        {
                            BW.Write(MAPAttackEditor.ListAttackchoice[X][Y]);
                        }
                    }

                    if (MAPAttackEditor.rbSpread.Checked)
                    {
                        BW.Write((byte)WeaponMAPProperties.Spread);
                    }
                    else if (MAPAttackEditor.rbDirection.Checked)
                    {
                        BW.Write((byte)WeaponMAPProperties.Direction);
                    }
                    else if (MAPAttackEditor.rbTargeted.Checked)
                    {
                        BW.Write((byte)WeaponMAPProperties.Targeted);
                    }

                    BW.Write(MAPAttackEditor.ckFriendlyFire.Checked);
                    BW.Write((int)MAPAttackEditor.txtAttackDelay.Value);
                }
            }
            else if (PrimaryProperty == WeaponPrimaryProperty.PER)
            {
                if (PERAttackEditor != null)
                {
                    BW.Write((float)PERAttackEditor.txtProjectileSpeed.Value);
                    BW.Write(PERAttackEditor.cbAffectedByGravity.Checked);
                    BW.Write(PERAttackEditor.cbCanBeShotDown.Checked);
                    BW.Write((byte)PERAttackEditor.txtMaxLifetime.Value);

                    BW.Write(PERAttackEditor.IsProjectileAnimated);
                    BW.Write(PERAttackEditor.txtProjectilePath.Text);
                    BW.Write((byte)PERAttackEditor.txtNumberOfProjectiles.Value);
                    BW.Write((float)PERAttackEditor.txtLateralMaxSpread.Value);
                    BW.Write((float)PERAttackEditor.txtForwardMaxSpread.Value);
                    BW.Write((float)PERAttackEditor.txtUpwardMaxSpread.Value);

                    if (PERAttackEditor.rbDestroySelf.Checked)
                    {
                        BW.Write((byte)PERAttackAttributes.GroundCollisions.DestroySelf);
                    }
                    else if (PERAttackEditor.rbStop.Checked)
                    {
                        BW.Write((byte)PERAttackAttributes.GroundCollisions.Stop);
                    }
                    else if (PERAttackEditor.rbBounce.Checked)
                    {
                        BW.Write((byte)PERAttackAttributes.GroundCollisions.Bounce);
                        BW.Write((byte)PERAttackEditor.txtBounceLimit.Value);
                    }
                }
            }

            BW.Write((byte)SecondaryProperty);
            BW.Write((byte)txtPostMovementAccuracyMalus.Value);
            BW.Write((byte)txtPostMovementEvasionBonus.Value);

            BW.Write((float)txtExplosionRadius.Value);
            BW.Write((float)txtExplosionWindPowerAtCenter.Value);
            BW.Write((float)txtExplosionWindPowerAtEdge.Value);
            BW.Write((float)txtExplosionWindPowerToSelfMultiplier.Value);
            BW.Write((float)txtExplosionDamageAtCenter.Value);
            BW.Write((float)txtExplosionDamageAtEdge.Value);
            BW.Write((float)txtExplosionDamageToSelfMultiplier.Value);

            BW.Write(AttackType);

            BW.Write(TerrainGradeAir);
            BW.Write(TerrainGradeLand);
            BW.Write(TerrainGradeSea);
            BW.Write(TerrainGradeSpace);

            #region Skills

            int PilotSkillCount = 0;
            if (txtPilotSkill1.Text != "None")
            {
                ++PilotSkillCount;
            }
            if (txtPilotSkill2.Text != "None")
            {
                ++PilotSkillCount;
            }
            if (txtPilotSkill3.Text != "None")
            {
                ++PilotSkillCount;
            }
            if (txtPilotSkill4.Text != "None")
            {
                ++PilotSkillCount;
            }

            BW.Write(PilotSkillCount);

            if (txtPilotSkill1.Text != "None")
            {
                BW.Write(txtPilotSkill1.Text);
            }
            if (txtPilotSkill2.Text != "None")
            {
                BW.Write(txtPilotSkill2.Text);
            }
            if (txtPilotSkill3.Text != "None")
            {
                BW.Write(txtPilotSkill3.Text);
            }
            if (txtPilotSkill4.Text != "None")
            {
                BW.Write(txtPilotSkill4.Text);
            }

            #endregion

            //Count the actual number of quotes listed.
            int QuoteCount = 0;
            if (Editor != null)
            {
                for (int R = 0; R < Editor.dgvQuotes.Rows.Count; R++)
                {
                    if (!string.IsNullOrEmpty((string)Editor.dgvQuotes.Rows[R].Cells[0].EditedFormattedValue))
                    {
                        QuoteCount++;
                    }
                }
            }

            BW.Write(QuoteCount);
            if (Editor != null)
            {
                for (int R = 0; R < Editor.dgvQuotes.Rows.Count; R++)
                {
                    if (!string.IsNullOrEmpty((string)Editor.dgvQuotes.Rows[R].Cells[0].EditedFormattedValue))
                    {
                        BW.Write((string)Editor.dgvQuotes.Rows[R].Cells[0].EditedFormattedValue);
                    }
                }
            }
        }
예제 #3
0
        public void Init(BinaryReader BR, ContentManager Content, string AttackName, Dictionary <string, BaseSkillRequirement> DicRequirement, Dictionary <string, BaseEffect> DicEffect,
                         Dictionary <string, AutomaticSkillTargetType> DicAutomaticSkillTarget)
        {
            //Create the Part file.
            this.ItemName    = Path.GetFileNameWithoutExtension("Content/Attacks/" + AttackName + ".pew");
            this.Description = BR.ReadString();

            this.PowerFormula      = BR.ReadString();
            this.MinDamageFormula  = BR.ReadString();
            this.ENCost            = BR.ReadInt32();
            this.MaxAmmo           = BR.ReadInt32();
            this.MoraleRequirement = BR.ReadInt32();
            this.RangeMinimum      = BR.ReadInt32();
            this.RangeMaximum      = BR.ReadInt32();
            this.Accuracy          = BR.ReadInt32();
            this.Critical          = BR.ReadInt32();

            this.Pri = (WeaponPrimaryProperty)BR.ReadByte();
            if (this.Pri == WeaponPrimaryProperty.MAP)
            {
                MAPAttributes = new MAPAttackAttributes(BR);
            }
            else if (this.Pri == WeaponPrimaryProperty.PER)
            {
                PERAttributes = new PERAttackAttributes(BR, Content);
            }

            this.Sec = (WeaponSecondaryProperty)BR.ReadByte();
            PostMovementAccuracyMalus = BR.ReadByte();
            PostMovementEvasionBonus  = BR.ReadByte();

            ExplosionOption = new ExplosionOptions(BR);

            int AttackType = BR.ReadInt32();

            if (AttackType == 0)
            {
                this.AttackType = "Blank";
                Style           = WeaponStyle.M;
            }
            else if (AttackType == 1)
            {
                this.AttackType = "Melee";
                Style           = WeaponStyle.M;
            }
            else if (AttackType == 2)
            {
                this.AttackType = "Solid blade";
                Style           = WeaponStyle.M;
            }
            else if (AttackType == 3)
            {
                this.AttackType = "Energy blade";
                Style           = WeaponStyle.M;
            }
            else if (AttackType == 4)
            {
                this.AttackType = "Solid shot";
                Style           = WeaponStyle.R;
            }
            else if (AttackType == 5)
            {
                this.AttackType = "Energy shot";
                Style           = WeaponStyle.R;
            }
            else if (AttackType == 6)
            {
                this.AttackType = "Remote";
                Style           = WeaponStyle.R;
            }
            else if (AttackType == 7)
            {
                this.AttackType = "Special";
                Style           = WeaponStyle.R;
            }

            int TerrainGradeAir   = BR.ReadInt32();
            int TerrainGradeLand  = BR.ReadInt32();
            int TerrainGradeSea   = BR.ReadInt32();
            int TerrainGradeSpace = BR.ReadInt32();

            char[] Grades = new char[6] {
                '-', 'S', 'A', 'B', 'C', 'D'
            };
            DicTerrainAttribute = new Dictionary <string, char>(4);
            DicTerrainAttribute.Add(UnitStats.TerrainAir, Grades[TerrainGradeAir]);
            DicTerrainAttribute.Add(UnitStats.TerrainLand, Grades[TerrainGradeLand]);
            DicTerrainAttribute.Add(UnitStats.TerrainSea, Grades[TerrainGradeSea]);
            DicTerrainAttribute.Add(UnitStats.TerrainSpace, Grades[TerrainGradeSpace]);

            Int32 AttackAttributesCount = BR.ReadInt32();

            this.ArrayAttackAttributes = new BaseAutomaticSkill[AttackAttributesCount];

            for (int S = 0; S < AttackAttributesCount; ++S)
            {
                string RelativePath = BR.ReadString();
                ArrayAttackAttributes[S] = new BaseAutomaticSkill("Content/Attacks/Attributes/" + RelativePath + ".peaa", RelativePath, DicRequirement, DicEffect, DicAutomaticSkillTarget);
            }

            ListQuoteSet = new List <string>();
            int ListQuoteSetCount = BR.ReadInt32();

            for (int R = 0; R < ListQuoteSetCount; R++)
            {
                ListQuoteSet.Add(BR.ReadString());
            }
        }
        public void SaveItem(BinaryWriter BW)
        {
            string Description = txtDescription.Text;

            string DamageFormula     = txtDamage.Text;
            int    ENCost            = Convert.ToInt32(txtENCost.Value);
            int    MaximumAmmo       = Convert.ToInt32(txtMaximumAmmo.Value);
            int    MoraleRequirement = Convert.ToInt32(txtMoraleRequirement.Value);
            int    MinimumRange      = Convert.ToInt32(txtMinimumRange.Value);
            int    MaximumRange      = Convert.ToInt32(txtMaximumRange.Value);
            int    Accuracy          = Convert.ToInt32(txtAccuracy.Value);
            int    Critical          = Convert.ToInt32(txtCritical.Value);

            WeaponPrimaryProperty PrimaryProperty = WeaponPrimaryProperty.None;

            if (rbMAP.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.MAP;
            }
            else if (rbPLA.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.PLA;
            }
            else if (rbALL.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.ALL;
            }
            else if (rbBREAK.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.Break;
            }
            else if (rbMULTI.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.Multi;
            }
            else if (rbDASH.Checked)
            {
                PrimaryProperty = WeaponPrimaryProperty.Dash;
            }

            WeaponSecondaryProperty SecondaryProperty = WeaponSecondaryProperty.None;

            if (cbPostMovement.Checked)
            {
                SecondaryProperty = SecondaryProperty | WeaponSecondaryProperty.PostMovement;
            }
            if (cbSwordCut.Checked)
            {
                SecondaryProperty = SecondaryProperty | WeaponSecondaryProperty.SwordCut;
            }
            if (cbShootDown.Checked)
            {
                SecondaryProperty = SecondaryProperty | WeaponSecondaryProperty.ShootDown;
            }

            int AttackType = 0;

            if (rbAttackTypeMelee.Checked)
            {
                AttackType = 1;
            }
            else if (rbAttackTypeSolidBlade.Checked)
            {
                AttackType = 2;
            }
            else if (rbAttackTypeEnergyBlade.Checked)
            {
                AttackType = 3;
            }
            else if (rbAttackTypeSolidShot.Checked)
            {
                AttackType = 4;
            }
            else if (rbAttackTypeEnergyShot.Checked)
            {
                AttackType = 5;
            }
            else if (rbAttackTypeRemote.Checked)
            {
                AttackType = 6;
            }
            else if (rbAttackTypeSpecial.Checked)
            {
                AttackType = 7;
            }

            int TerrainGradeAir   = cbAirRank.SelectedIndex;
            int TerrainGradeLand  = cbLandRank.SelectedIndex;
            int TerrainGradeSea   = cbSeaRank.SelectedIndex;
            int TerrainGradeSpace = cbSpaceRank.SelectedIndex;

            //Create the Part file.
            BW.Write(Description);

            BW.Write(DamageFormula);
            BW.Write(ENCost);
            BW.Write(MaximumAmmo);
            BW.Write(MoraleRequirement);
            BW.Write(MinimumRange);
            BW.Write(MaximumRange);
            BW.Write(Accuracy);
            BW.Write(Critical);

            BW.Write((byte)PrimaryProperty);
            if (PrimaryProperty == WeaponPrimaryProperty.MAP)
            {
                if (MAPAttackEditor != null)
                {
                    BW.Write(MAPAttackEditor.AttackWidth);
                    BW.Write(MAPAttackEditor.AttackHeight);
                    for (int X = 0; X < MAPAttackEditor.AttackWidth * 2 + 1; X++)
                    {
                        for (int Y = 0; Y < MAPAttackEditor.AttackHeight * 2 + 1; Y++)
                        {
                            BW.Write(MAPAttackEditor.ListAttackchoice[X][Y]);
                        }
                    }

                    if (MAPAttackEditor.rbSpread.Checked)
                    {
                        BW.Write((byte)WeaponMAPProperties.Spread);
                    }
                    else if (MAPAttackEditor.rbDirection.Checked)
                    {
                        BW.Write((byte)WeaponMAPProperties.Direction);
                    }
                    else if (MAPAttackEditor.rbTargeted.Checked)
                    {
                        BW.Write((byte)WeaponMAPProperties.Targeted);
                    }

                    BW.Write(MAPAttackEditor.ckFriendlyFire.Checked);
                    BW.Write((int)MAPAttackEditor.txtAttackDelay.Value);
                }
            }
            BW.Write((byte)SecondaryProperty);
            BW.Write(AttackType);

            BW.Write(TerrainGradeAir);
            BW.Write(TerrainGradeLand);
            BW.Write(TerrainGradeSea);
            BW.Write(TerrainGradeSpace);

            #region Skills

            int PilotSkillCount = 0;
            if (txtPilotSkill1.Text != "None")
            {
                ++PilotSkillCount;
            }
            if (txtPilotSkill2.Text != "None")
            {
                ++PilotSkillCount;
            }
            if (txtPilotSkill3.Text != "None")
            {
                ++PilotSkillCount;
            }
            if (txtPilotSkill4.Text != "None")
            {
                ++PilotSkillCount;
            }

            BW.Write(PilotSkillCount);

            if (txtPilotSkill1.Text != "None")
            {
                BW.Write(txtPilotSkill1.Text);
            }
            if (txtPilotSkill2.Text != "None")
            {
                BW.Write(txtPilotSkill2.Text);
            }
            if (txtPilotSkill3.Text != "None")
            {
                BW.Write(txtPilotSkill3.Text);
            }
            if (txtPilotSkill4.Text != "None")
            {
                BW.Write(txtPilotSkill4.Text);
            }

            #endregion

            //Count the actual number of quotes listed.
            int QuoteCount = 0;
            if (Editor != null)
            {
                for (int R = 0; R < Editor.dgvQuotes.Rows.Count; R++)
                {
                    if (!string.IsNullOrEmpty((string)Editor.dgvQuotes.Rows[R].Cells[0].EditedFormattedValue))
                    {
                        QuoteCount++;
                    }
                }
            }

            BW.Write(QuoteCount);
            if (Editor != null)
            {
                for (int R = 0; R < Editor.dgvQuotes.Rows.Count; R++)
                {
                    if (!string.IsNullOrEmpty((string)Editor.dgvQuotes.Rows[R].Cells[0].EditedFormattedValue))
                    {
                        BW.Write((string)Editor.dgvQuotes.Rows[R].Cells[0].EditedFormattedValue);
                    }
                }
            }
        }