Example #1
0
        public override void Shoot(RobotAnimation Owner, Vector2 GunNozzlePosition, float Angle, List <BaseAutomaticSkill> ListFollowingSkill)
        {
            List <AttackBox> ListAttack = new List <AttackBox>(NumberOfProjectiles);

            for (int i = NumberOfProjectiles - 1; i >= 0; --i)
            {
                AttackBox NewAttack;

                if (ProjectileType == ProjectileTypes.Hitscan)
                {
                    NewAttack = new HitscanBox(Damage, ExplosionAttributes, Owner, GunNozzlePosition, Angle);
                }
                else
                {
                    NewAttack = new ProjectileBox(Damage, ExplosionAttributes, Owner, GunNozzlePosition, ProjectileSize, Angle, ActiveProjectileInfo);
                }

                //Clone the following skills so they are not share by every bullets.
                NewAttack.ListActiveSkill = new List <BaseAutomaticSkill>(ListFollowingSkill.Count);
                foreach (BaseAutomaticSkill ActiveFollowingSkill in ListFollowingSkill)
                {
                    NewAttack.ListActiveSkill.Add(new BaseAutomaticSkill(ActiveFollowingSkill));
                }

                ListAttack.Add(NewAttack);
            }

            Owner.CreateAttackBox(WeaponPath, GunNozzlePosition, ListAttack);
        }
Example #2
0
        public override void UpdateAnimationObject(int KeyFrame)
        {
            //An Event is being executed.
            if (NextEvent != null)
            {
                UpdateAnimationSprite(KeyFrame);
            }

            VisibleAnimationObjectKeyFrame ActiveKeyFrame;
            VisibleAnimationObjectKeyFrame ActiveAnimationSpriteKeyFrame;

            if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveAnimationSpriteKeyFrame))
            {
                ActiveKeyFrame = ActiveAnimationSpriteKeyFrame;
                //If that animation has already been used, skip it.
                if (ActiveKeyFrame.IsUsed)
                {
                    return;
                }

                int NextKeyFrame = ActiveKeyFrame.NextKeyFrame;
                OnNewKeyFrameAnimationSprite(ActiveKeyFrame);
                for (int C = ListCollisionPolygon.Count - 1; C >= 0; --C)
                {
                    ListCollisionPolygon[C].Offset(Position.X, Position.Y);
                }

                if (Owner != null)
                {
                    MeleeBox NewAttackBox = new MeleeBox(_Damage, Owner, (DeathFrame - SpawnFrame) / FramesPerSeconds, true);

                    for (int C = ListCollisionPolygon.Count - 1; C >= 0; --C)
                    {
                        ListCollisionPolygon[C].Offset(Owner.Position.X - Owner.AnimationOrigin.Position.X, Owner.Position.Y - Owner.AnimationOrigin.Position.Y);
                    }

                    NewAttackBox.ListCollisionPolygon = ListCollisionPolygon;
                    //TODO: delete the attack box is the animation is cancelled
                    Owner.CreateAttackBox(NewAttackBox);
                }

                if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveAnimationSpriteKeyFrame))
                {
                    ActiveKeyFrame = ActiveAnimationSpriteKeyFrame;
                    if (ActiveKeyFrame.IsProgressive)
                    {
                        OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame);
                    }
                    else
                    {
                        NextEvent = null;
                    }
                }
            }
        }