Esempio n. 1
0
        public HitscanBox(float Damage, ExplosionOptions ExplosionAttributes, RobotAnimation Owner, Vector2 Position, float Angle)
            : base(Damage, ExplosionAttributes, Owner, false)
        {
            this.Angle = Angle;
            Lifetime   = 50;

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

            float CosA = (float)Math.Cos(Angle);
            float SinA = (float)Math.Sin(Angle);
            float MinX = Position.X;
            float MinY = Position.Y;
            float MaxX = MinX + CosA * HitscanLength;
            float MaxY = MinY + SinA * HitscanLength;

            Speed = new Vector2(CosA * 100000, SinA * 100000);

            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
            };
        }
 protected override void Load(BinaryReader BR)
 {
     _ExplosionAttributes = new ExplosionOptions(BR);
     if (_ExplosionAttributes.ExplosionAnimation.Path != string.Empty && Params != null && Params.SharedParams.Content != null)
     {
         _ExplosionAttributes.ExplosionAnimation.Load(Params.SharedParams.Content, "Animations/Sprites/");
     }
 }
        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;
        }
Esempio n. 4
0
        public AttackBox(float Damage, ExplosionOptions ExplosionAttributes, RobotAnimation Owner, double Lifetime, bool FollowOwner)
            : base(Lifetime)
        {
            ListAttackedRobots = new List <RobotAnimation>();

            this.Owner  = Owner;
            this.Damage = Damage;
            this.ExplosionAttributes = ExplosionAttributes;
            this.FollowOwner         = FollowOwner;
            ListAttackedRobots.Add(Owner);
        }
Esempio n. 5
0
        public ExplosionOptions(ExplosionOptions Clone)
        {
            ExplosionRadius                    = Clone.ExplosionRadius;
            ExplosionWindPowerAtCenter         = Clone.ExplosionWindPowerAtCenter;
            ExplosionWindPowerAtEdge           = Clone.ExplosionWindPowerAtEdge;
            ExplosionWindPowerToSelfMultiplier = Clone.ExplosionWindPowerToSelfMultiplier;
            ExplosionDamageAtCenter            = Clone.ExplosionDamageAtCenter;
            ExplosionDamageAtEdge              = Clone.ExplosionDamageAtEdge;
            ExplosionDamageToSelfMultiplier    = Clone.ExplosionDamageToSelfMultiplier;
            sndExplosionPath                   = Clone.sndExplosionPath;
            sndExplosion = Clone.sndExplosion;

            ExplosionAnimation = Clone.ExplosionAnimation.Copy();
        }
Esempio n. 6
0
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                IWindowsFormsEditorService svc = (IWindowsFormsEditorService)
                                                 provider.GetService(typeof(IWindowsFormsEditorService));

                if (svc != null)
                {
                    ExplosionOptions          ActiveParams = (ExplosionOptions)value;
                    ExplosionAttributesEditor NewEditor    = new ExplosionAttributesEditor(ActiveParams);
                    if (NewEditor.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        value = NewEditor.ExplosionAttributes;
                    }
                }
                return(value);
            }
        public ExplosionAttributesEditor(ExplosionOptions ExplosionAttributes)
            : this()
        {
            this.ExplosionAttributes = ExplosionAttributes;

            txtExplosionRadius.Value = (decimal)ExplosionAttributes.ExplosionRadius;

            txtExplosionWindPowerAtCenter.Value         = (decimal)ExplosionAttributes.ExplosionWindPowerAtCenter;
            txtExplosionWindPowerAtEdge.Value           = (decimal)ExplosionAttributes.ExplosionWindPowerAtEdge;
            txtExplosionWindPowerToSelfMultiplier.Value = (decimal)ExplosionAttributes.ExplosionWindPowerToSelfMultiplier;

            txtExplosionDamageAtCenter.Value         = (decimal)ExplosionAttributes.ExplosionDamageAtCenter;
            txtExplosionDamageAtEdge.Value           = (decimal)ExplosionAttributes.ExplosionDamageAtEdge;
            txtExplosionDamageToSelfMultiplier.Value = (decimal)ExplosionAttributes.ExplosionDamageToSelfMultiplier;

            txtProjectilePath.Text = ExplosionAttributes.ExplosionAnimation.Path;
            txtSoundPath.Text      = ExplosionAttributes.sndExplosionPath;
        }
Esempio n. 8
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();
        }
Esempio n. 9
0
        public void CreateExplosion(Vector2 ExplosionCenter, RobotAnimation RobotOwner, ExplosionOptions ExplosionAttributes, Vector2 CollisionGroundResult)
        {
            foreach (KeyValuePair <uint, RobotAnimation> ActiveRobotPair in DicRobot)
            {
                RobotAnimation TargetRobot = ActiveRobotPair.Value;

                bool IsSelf = TargetRobot == RobotOwner;

                if (TargetRobot.HP <= 0 || (TargetRobot.Team == RobotOwner.Team && !IsSelf))
                {
                    continue;
                }

                float DistanceFromCenter = Vector2.Distance(ExplosionCenter, TargetRobot.Position);

                if (DistanceFromCenter <= ExplosionAttributes.ExplosionRadius)
                {
                    float DistanceRatio = DistanceFromCenter / ExplosionAttributes.ExplosionRadius;
                    float ExplosionDiff = ExplosionAttributes.ExplosionDamageAtCenter - ExplosionAttributes.ExplosionDamageAtEdge;

                    float FinalDamage = ExplosionAttributes.ExplosionDamageAtCenter + ExplosionDiff * DistanceRatio;
                    if (IsSelf)
                    {
                        FinalDamage *= ExplosionAttributes.ExplosionDamageToSelfMultiplier;
                    }

                    if (Owner.IsOfflineOrServer || Owner.IsServer)
                    {
                        TargetRobot.HP -= (int)FinalDamage;

                        if (TargetRobot.HasKnockback)
                        {
                            float   WindDiff   = ExplosionAttributes.ExplosionWindPowerAtCenter - ExplosionAttributes.ExplosionWindPowerAtEdge;
                            Vector2 WindVector = Vector2.Normalize(TargetRobot.Position - ExplosionCenter);
                            Vector2 FinalWind  = WindVector * (ExplosionAttributes.ExplosionWindPowerAtCenter + WindDiff * DistanceRatio);

                            if (IsSelf)
                            {
                                FinalWind *= ExplosionAttributes.ExplosionWindPowerToSelfMultiplier;
                            }

                            TargetRobot.Speed += FinalWind;
                        }

                        OnDamageRobot(RobotOwner, TargetRobot, (int)FinalDamage, TargetRobot.Position, Owner.IsMainCharacter(TargetRobot.ID));
                    }
                }
            }

            if (!Owner.IsServer && ExplosionAttributes.ExplosionAnimation.Path != string.Empty)
            {
                if (ExplosionAttributes.sndExplosion != null)
                {
                    PlayerSFXGenerator.PrepareExplosionSound(ExplosionAttributes.sndExplosion, ExplosionCenter);
                }

                SimpleAnimation NewExplosion = ExplosionAttributes.ExplosionAnimation.Copy();
                NewExplosion.IsLooped = false;
                NewExplosion.Position = new Vector2(ExplosionCenter.X, ExplosionCenter.Y - NewExplosion.PositionRectangle.Height / 2);
                ListImages.Add(NewExplosion);

                if (Owner.IsInsideCamera(ExplosionCenter, new Vector2(1, 1)))
                {
                    for (int i = 0; i < 30; ++i)
                    {
                        AddVisualEffect(Owner.sprExplosionSplinter, ExplosionCenter, new Vector2(CollisionGroundResult.X - 3 + (float)RandomHelper.Random.NextDouble() * 6, CollisionGroundResult.Y * (2 + (float)RandomHelper.Random.NextDouble() * 4)));
                    }
                }
            }
        }
Esempio n. 10
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;
                }
            }
        }
Esempio n. 11
0
 public void CreateExplosion(Vector2 ExplosionCenter, ExplosionOptions ExplosionAttributes, Vector2 CollisionGroundResult)
 {
     CurrentLayer.CreateExplosion(ExplosionCenter, this, ExplosionAttributes, CollisionGroundResult);
 }
        protected override void DoCopyMembers(BaseEffect Copy)
        {
            CreateExplosionEffect NewEffect = (CreateExplosionEffect)Copy;

            _ExplosionAttributes = NewEffect._ExplosionAttributes;
        }
 public CreateExplosionEffect(TripleThunderAttackParams Params)
     : base(Name, false, Params)
 {
     _ExplosionAttributes = new ExplosionOptions();
     _ExplosionAttributes.ExplosionAnimation = new SimpleAnimation();
 }