예제 #1
0
        /// <summary>
        /// Adds an Explosion Set to the list
        /// </summary>
        /// <param name="newSet">Explosion set to add</param>
        /// <param name="xOffset">The offset from this explosion animator's position
        /// on the x-axis, only used for the MULTIPLE explosion pattern
        /// </param>
        /// <param name="yOffset">The offset from this explosion animator's position
        /// on the y-axis, only used for the MULTIPLE explosion pattern
        /// </param>
        public void AddExplosion(ExplosionSet newSet, Vector2 offsetPosition)
        {
            Vector2 newVector = new Vector2(_bounds.X, _bounds.Y);

            switch (_myExplosionType)
            {
            case ExplosionType.SINGLE:
                newSet.Position = newVector + offsetPosition;
                break;

            case ExplosionType.RANDOM:

                Random r = new Random();

                newVector.X += r.Next(0, _bounds.Width);
                newVector.Y += r.Next(0, _bounds.Height);

                newSet.Position = newVector;

                break;

            case ExplosionType.MULTIPLE:
                newSet.Position = newVector + offsetPosition;
                break;

            default:
                break;
            }

            _explosionList.Add(newSet);
        }
예제 #2
0
        /// <summary>
        /// Creates an ExplodeAnim animator
        /// </summary>
        /// <param name="initialExplosionSet">The initial set to use for an explosion, the position of this will be set to the bounds</param>
        /// <param name="initialType">The initial explosion type of this animator</param>
        /// <param name="initialSlideInterval">The interval between frames to use for this animator</param>
        /// <param name="bounds">The bounds and position of this explosion animator, bounds are primarily used for the RANDOM type</param>
        public ExplodeAnim(ExplosionSet initialExplosionSet, ExplosionType initialType, float initialSlideInterval, Rectangle bounds)
        {
            _explosionList = new List <ExplosionSet>();

            _universalSlideInterval = initialSlideInterval;
            _bounds          = bounds;
            _myExplosionType = initialType;

            initialExplosionSet.Position = new Vector2(bounds.X, bounds.Y);

            AddExplosion(initialExplosionSet, Vector2.Zero);
        }
예제 #3
0
        /// <summary>
        /// This gets called whenever there is a transition to a new state
        /// </summary>
        private void onEntry()
        {
            //These are, so far, the only two states that need an onEntry method,
            //but we'll leave the structure here in case more is needed

            switch (_myBehaviourState)
            {
            case JetMinionBehaviourState.FIRE:

                _timerFire = 0;

                break;

            default:
                break;
            }

            switch (_myVisualState)
            {
            case JetMinionVisualState.EXPLODING:

                //TODO:
                //This will probably insantiate the animation class, this
                //way it is only called once when this state is entered

                Vector2 explosionSize = new Vector2(ExplosionLeftSpriteBounds[0].Width, ExplosionRightSpriteBounds[0].Height) * ExplosionScale;

                Rectangle explosionBounds = new Rectangle(0, 0, (int)explosionSize.X, (int)explosionSize.Y);

                AnimSet explosionLeftSide  = new AnimSet(ExplosionLeftSpriteBounds, _explosionSpriteSheet, explosionBounds, AnimType.LOOP, ExplosionIntervalTime);
                AnimSet explosionRightSide = new AnimSet(ExplosionRightSpriteBounds, _explosionSpriteSheet, explosionBounds, AnimType.LOOP, ExplosionIntervalTime);

                ExplosionSet newExplosion = new ExplosionSet(_position);

                newExplosion.AddAnimSet(explosionLeftSide, Vector2.Zero);
                newExplosion.AddAnimSet(explosionRightSide, new Vector2(explosionBounds.Width, 0) * ExplosionScale);

                _explosionAnimator.AddExplosion(newExplosion, Vector2.Zero);

                _explosionAnimator.Start();
                break;

            default:
                break;
            }
        }
예제 #4
0
        /// <summary>
        /// This gets called whenever there is a transition to a new state
        /// </summary>
        private void onEntry()
        {
            //These are, so far, the only two states that need an onEntry method,
            //but we'll leave the structure here in case more is needed

            switch (_myBehaviourState)
            {
                case JetMinionBehaviourState.FIRE:

                    _timerFire = 0;

                    break;

                default:
                    break;
            }

            switch (_myVisualState)
            {
                case JetMinionVisualState.EXPLODING:

                    //TODO:
                    //This will probably insantiate the animation class, this
                    //way it is only called once when this state is entered

                    Vector2 explosionSize = new Vector2(ExplosionLeftSpriteBounds[0].Width, ExplosionRightSpriteBounds[0].Height) * ExplosionScale;

                    Rectangle explosionBounds = new Rectangle(0, 0, (int)explosionSize.X, (int)explosionSize.Y);

                    AnimSet explosionLeftSide = new AnimSet(ExplosionLeftSpriteBounds, _explosionSpriteSheet, explosionBounds, AnimType.LOOP, ExplosionIntervalTime);
                    AnimSet explosionRightSide = new AnimSet(ExplosionRightSpriteBounds, _explosionSpriteSheet, explosionBounds, AnimType.LOOP, ExplosionIntervalTime);

                    ExplosionSet newExplosion = new ExplosionSet(_position);

                    newExplosion.AddAnimSet(explosionLeftSide, Vector2.Zero);
                    newExplosion.AddAnimSet(explosionRightSide, new Vector2(explosionBounds.Width, 0) * ExplosionScale);

                    _explosionAnimator.AddExplosion(newExplosion, Vector2.Zero);

                    _explosionAnimator.Start();
                    break;

                default:
                    break;
            }
        }
예제 #5
0
        /// <summary>
        /// Adds an Explosion Set to the list
        /// </summary>
        /// <param name="newSet">Explosion set to add</param>
        /// <param name="xOffset">The offset from this explosion animator's position 
        /// on the x-axis, only used for the MULTIPLE explosion pattern
        /// </param>
        /// <param name="yOffset">The offset from this explosion animator's position 
        /// on the y-axis, only used for the MULTIPLE explosion pattern
        /// </param>
        public void AddExplosion(ExplosionSet newSet, Vector2 offsetPosition)
        {
            Vector2 newVector = new Vector2(_bounds.X, _bounds.Y);

            switch (_myExplosionType)
            {
                case ExplosionType.SINGLE:
                    newSet.Position = newVector + offsetPosition;
                    break;

                case ExplosionType.RANDOM:

                    Random r = new Random();

                    newVector.X += r.Next(0, _bounds.Width);
                    newVector.Y += r.Next(0, _bounds.Height);

                    newSet.Position = newVector;

                    break;

                case ExplosionType.MULTIPLE:
                    newSet.Position = newVector + offsetPosition;
                    break;

                default:
                    break;
            }

            _explosionList.Add(newSet);
        }
예제 #6
0
        /// <summary>
        /// Creates an ExplodeAnim animator
        /// </summary>
        /// <param name="initialExplosionSet">The initial set to use for an explosion, the position of this will be set to the bounds</param>
        /// <param name="initialType">The initial explosion type of this animator</param>
        /// <param name="initialSlideInterval">The interval between frames to use for this animator</param>
        /// <param name="bounds">The bounds and position of this explosion animator, bounds are primarily used for the RANDOM type</param>
        public ExplodeAnim(ExplosionSet initialExplosionSet, ExplosionType initialType, float initialSlideInterval, Rectangle bounds)
        {
            _explosionList = new List<ExplosionSet>();

            _universalSlideInterval = initialSlideInterval;
            _bounds = bounds;
            _myExplosionType = initialType;

            initialExplosionSet.Position = new Vector2(bounds.X, bounds.Y);

            AddExplosion(initialExplosionSet, Vector2.Zero);
        }