Пример #1
0
        public override void RemoveFromAutoDrawSet()
        {
            this.cannonHole.RemoveFromAutoDrawSet();
            this.cannonHole = null;

            base.RemoveFromAutoDrawSet();
        }
Пример #2
0
        protected void Blow(XNACS1Circle ball)
        {
            #region Vector Calculations
            Vector2 T = this.FrontDirection;
            Vector2 V = ball.Center - this.Center;
            float dT = Vector2.Dot(V, T);

            Vector2 N = this.NormalDirection;
            float dN = Vector2.Dot(V, N);

            float range_vert = (dT * T).Length() * ((float)Math.Sin(kTheta));

            float max_dist = Vector2.Dot(XNACS1Base.World.WorldMax, T) / 2f;

            /*Ball velocity decomposed*/
            float velocity_T = Vector2.Dot(ball.Velocity, T);
            float velocity_N = Vector2.Dot(ball.Velocity, N);
            #endregion

            #region Push Da Ball
            /*Is the ball in front on the fan?*/
            if ((dT > 0f) && (dT < max_dist))
            {
                float sin_theta = (float)Math.Sin(kTheta);
                /*Is the ball in the fan's AoE?*/
                if (Math.Abs(dN) <= Math.Abs(dT * sin_theta))
                {
                    float force_scale = 1f / V.Length();
                    velocity_T += kWindForce * force_scale;
                    ball.Velocity = velocity_T * T + velocity_N * N;
                }
            }
            #endregion
        }
 private XNACS1Circle starAt(float xPos)
 {
     Vector2 position = new Vector2(xPos, randomPosition());
     XNACS1Circle star = new XNACS1Circle(position, size);
     star.Color = randomStarColor();
     return star;
 }
Пример #4
0
        /// <summary>
        /// Overrides parent collision response when an XNACS1Circle collides
        /// with this object.  This DOES apply basic physics (i.e., gravity,
        /// static friction, and elasticity) and scales up Velocity along
        /// its front face.
        /// </summary>
        /// <param name="circle"></param>
        protected override void CollideWithCircle(XNACS1Circle circle)
        {
            /*Run base collision*/
            base.CollideWithCircle(circle);

            float dT = Vector2.Dot(circle.Velocity, this.FrontDirection);

            /*If collision is along front, scale up by springForce*/
            if (Math.Sign(dT) > 0)
                circle.Velocity *= this.springForce;
        }
        public Bullet(Vector2 genaratePosition, Vector2 currentSpeed, float radius, Hero currentHero, List<Enemy> currentEnemy)
        {
            this.position = new XNACS1Circle(genaratePosition, radius);
            this.position.Color = Game.randomColor();
            explosions = new List<Explosion>();
            // set object into motion;

            this.alive = true;
            this.hero = currentHero;
            this.enemies = currentEnemy;
            this.speed = currentSpeed;
        }
Пример #6
0
        /// <summary>
        /// Overrides the RectangleWithPhysics CollideWithCircle function so
        /// that a Receptacle does not really collide with Money, but rather,
        /// removes the Money and counts it as collected.
        /// </summary>
        /// <param name="circle"></param>
        protected override void CollideWithCircle(XNACS1Circle circle)
        {
            /*Record as caught*/
            ++this.coinsCaught;

            /*Play sound to make clear that coin is in*/
            if(circle.IsInAutoDrawSet())
                XNACS1Base.PlayACue("11Coin");  //Super Mario Bros. SFX; REPLACE!

            /*Remove coin from draw set; it has been safely collected*/
            circle.RemoveFromAutoDrawSet();
        }
        public Explosion(Hero h, Enemy e)
        {
            splash = new XNACS1Circle(e.getPosition().Center, splashRadius);
            timer = new Timer(duration);
            splash.Color = h.getColor();
            splash.Visible = false;
            splash.RemoveFromAutoDrawSet();

            emitter = new ExplosionEmitter(e.getPosition().Center, duration, 0.6f, h.getColor());
            emitter.DrawHalo(20);
            emitter.AutoRemoveDeadParticles = true;
        }
        public override void fire()
        {
            base.fire();

            XNACS1Circle bullet = new XNACS1Circle(hero.getPosition().Center, bulletSize);
            bullet.Color = hero.getColor();
            angledBullets.Enqueue(bullet);

            bullet = new XNACS1Circle(hero.getPosition().Center, bulletSize);
            bullet.Color = hero.getColor();
            angledBullets.Enqueue(bullet);
        }
Пример #9
0
        private float[] startRadius; // an array holding calculated radiuses of starting rings.

        #endregion Fields

        #region Constructors

        public Background()
        {
            background = new XNACS1Rectangle(XNACS1Base.World.WorldDimension / 2, XNACS1Base.World.WorldDimension.X, XNACS1Base.World.WorldDimension.Y);
            background.Color = Color.Black;

            // starfield
            stars = new XNACS1Circle[50];
            for (int count = 0; count < stars.Length; count++)
            {
                stars[count] = new XNACS1Circle(new Vector2(0, 0), XNACS1Base.RandomFloat(0.125f, 1f));
                stars[count].CenterX = XNACS1Base.RandomFloat(0.25f, XNACS1Base.World.WorldDimension.X - 0.25f);
                stars[count].CenterY = XNACS1Base.RandomFloat(0.25f, XNACS1Base.World.WorldDimension.Y - 0.25f);
                stars[count].Color = Color.White;
            }

            // calculate how many rings will be needed...
            int ringsNeeded = 1;
            float growthSize = 0.50f;

            while (growthSize < XNACS1Base.World.WorldMax.X * 1.5)
            {
                ringsNeeded++;
                growthSize *= RATE_OF_GROWTH;
            }

            ringsNeeded = ringsNeeded / 40 - 1;
            rings = new Ring[ringsNeeded - 1];
            startRadius = new float[ringsNeeded];

            // calculate the starting radiuses of rings
            startRadius[startRadius.Length-1] = XNACS1Base.World.WorldMax.X * 1.5f;
            for (int i = startRadius.Length - 2; i >= 0; i--)
            {
                startRadius[i] = startRadius[i + 1];

                // each 40 ticks is an additional ring.
                for (int tick = 0; tick < 40; tick++)
                {
                    startRadius[i] /= RATE_OF_GROWTH;
                }
            }
            MIN_RADIUS = startRadius[0];
            MAX_RADIUS = startRadius[startRadius.Length - 1];

            // now create rings and set their radiuses
            string[] ringTextures = { "ringBlue", "ringPink" };
            for (int i = 0; i < rings.Length; i++)
            {
                rings[i] = new Ring(startRadius[i], ringTextures[0], i);
                rings[i].Radius = startRadius[i];
            }
        }
Пример #10
0
        public Cannon(  Vector2 center,
            float width = 20.0f,
            float height = 20.0f,
            float rotation = 0f,
            float static_friction = 0.1f,
            float bounciness = 0.6f)
            : base(center, width, height, rotation, static_friction, bounciness)
        {
            this.myType = ComponentType.cannon;
            this.Texture = "Cannon";

            this.cannonHole = new XNACS1Circle(this.Center, 5f);
            this.cannonHole.Texture = "empty";

            this.beginIdle();
        }
Пример #11
0
        /// <summary>
        /// Overrides the RectangleWithPhysics CollideWithCircle function so
        /// that a Receptacle does not really collide with Money, but rather,
        /// removes the Money and counts it as collected.
        /// </summary>
        /// <param name="circle"></param>
        protected override void CollideWithCircle(XNACS1Circle circle)
        {
            /*Record as caught*/
            ++this.coinsCaught;

            // increase size
            Vector2 prevSize = this.Size;
            this.Size *= 1.02f;

            // now shift object up so it's bottom edge remains the same on screen regardless of size.
            float vertDisp = (this.Size.Y - prevSize.Y) / 2;
            this.CenterY += vertDisp;

            /*Play sound to make clear that coin is in*/
            if (circle.IsInAutoDrawSet())
            {
                int soundToPlay = XNACS1Base.RandomInt(1, 5);

                switch (soundToPlay)
                {
                    case(1):
                        XNACS1Base.PlayACue("Coin1");
                        break;
                    case (2):
                        XNACS1Base.PlayACue("Coin2");
                        break;
                    case (3):
                        XNACS1Base.PlayACue("Coin3");
                        break;
                    case (4):
                        XNACS1Base.PlayACue("Coin4");
                        break;
                    default:
                        XNACS1Base.PlayACue("Coin5");
                        break;
                }

            }

            /*Remove coin from draw set; it has been safely collected*/
            circle.RemoveFromAutoDrawSet();
        }
Пример #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="circle"></param>
        private void Repel(XNACS1Circle circle)
        {
            #region Vector Calculations
            Vector2 T = this.FrontDirection;
            Vector2 N = this.NormalDirection;
            Vector2 V = circle.Center - this.Center;

            /*Circle velocities relative to the repulsor*/
            float velocity_T = Vector2.Dot(circle.Velocity, T);
            float velocity_N = Vector2.Dot(circle.Velocity, N);

            /*Scalars for adjusting imparted acceleration based on distance*/
            float scale_T = 1 / Vector2.Dot(V, T);
            float scale_N = 1 / Vector2.Dot(V, N);
            #endregion

            #region Push da Ball
            velocity_T = this.pushForce * scale_T;
            velocity_N = this.pushForce * scale_N;

            circle.Velocity = velocity_T * T + velocity_N * N;
            #endregion
        }
Пример #13
0
 public shot(Vector2 center, bool hit)
 {
     bullet = new XNACS1Circle(center, .75f, "violetlight");
     bullet.Speed = 1f;
     this.hit = hit;
     shotLife = 15;
     emitter = new XNACS1ParticleEmitter.FireEmitter(center, 10, 0.3f, "violetlight", Color.Pink, 1f, 3f, new Vector2(-1, 0));
 }
Пример #14
0
 // fire the weapon
 public virtual void fire()
 {
     XNACS1Circle bullet = new XNACS1Circle(hero.getPosition().Center, bulletSize);
     bullet.Color = hero.getColor();
     bullets.Enqueue(bullet);
 }
 public shot(Vector2 center, bool hit)
 {
     bullet = new XNACS1Circle(center, 1f, "bullet");
     this.hit = hit;
     shotLife = 25;
     emitter = new XNACS1ParticleEmitter.FireEmitter(center, 30, 0.5f, "bullet", Color.OrangeRed, 20f, 3f, new Vector2(-1, 0));
 }
Пример #16
0
 public shot(Vector2 center, bool hit)
 {
     bullet = new XNACS1Circle(center, .75f, "wizardShot");
     bullet.Speed = 1f;
     this.hit = hit;
     shotLife = 40;
     emitter = new XNACS1ParticleEmitter.FireEmitter(center, 10, 0.3f, "wizardShot", Color.Green, 1f, 3f, new Vector2(-1, 0));
 }
        /// <summary>
        /// Provides simple collision response when an XNACS1Circle collides
        /// with this object.  This DOES apply basic physics (i.e., gravity,
        /// static friction, and elasticity).
        /// </summary>
        /// <param name="circle"></param>
        protected virtual void CollideWithCircle(XNACS1Circle circle)
        {
            #region Vector Calculations
            Vector2 T = this.FrontDirection;   //Tangential vector (normalized)
            Vector2 V = circle.Center - this.Center;         //Collision vector

            float dT = Vector2.Dot(V, T);                 //Distance on tangent
            Vector2 ptT = this.Center + (dT * T);            //Point on tangent

            Vector2 N = circle.Center - ptT;                    //Normal vector
            N.Normalize();
            float dN = Vector2.Dot(V, N);                  //Distance on normal

            /*Velocity components of the circle*/
            float velocity_T = Vector2.Dot(circle.Velocity, T);
            float velocity_N = Vector2.Dot(circle.Velocity, N);
            #endregion

            #region Collision Response
            if (Math.Abs(dT) < this.Width / 2f)
            {
                /*Handling top/bottom collision*/
                float displacement_on_N = circle.Radius + (this.Height / 2f);
                if (Math.Abs(dN) < displacement_on_N)
                {
                    velocity_N += WorldPhysics.Gravity;
                    circle.Center = ptT + Math.Sign(dN) * (displacement_on_N * N);
                    velocity_N *= -1f;
                }
            }
            else /*if (Math.Abs(dT) < (this.Height / 2f))*/
            {
                /*Handling side collision*/
                float displacement_on_T = circle.Radius + (this.Width / 2f);
                if (Math.Abs(dT) < displacement_on_T)
                {
                    circle.Center = this.Center + (dN * N) + Math.Sign(dT) * (displacement_on_T * T);
                    velocity_T *= -1f;
                }
            }
            /*else
            {
                /*Handling corner collision
                float displacement_on_N = circle.Radius + (this.Height / 2f);
                float displacement_on_T = circle.Radius + (this.Width / 2f);
                if (Math.Abs(dT) < displacement_on_T && Math.Abs(dN) < displacement_on_N)
                {
                    Vector2 ptAtEdgeOnTangent = this.Center + (this.Width / 2 * Math.Sign(dT) * -1 * T);
                    Vector2 ptAtEdgeOnNormal = this.Center + (this.Height / 2 * Math.Sign(dN) * N);
                    Vector2 pointAtCorner = this.Center - (ptAtEdgeOnTangent + ptAtEdgeOnNormal);

                    Vector2 circleCenterToCorner = pointAtCorner - circle.Center;
                    circleCenterToCorner.Normalize();

                    circle.Center = pointAtCorner - circleCenterToCorner * circle.Radius;
                }
            }*/
            #endregion

            #region Stop the Circle (if needed) Pt 1
            float error = kError * circle.Radius;
            if (Math.Abs(velocity_N) < error)
                velocity_N = 0f;
            if (Math.Abs(velocity_T) < float.Epsilon)
                velocity_T = 0f;
            #endregion

            circle.Velocity = velocity_T * T * (1f - this.friction) + velocity_N * N * (this.elasticity);

            #region Stop the Circle (if needed) Pt 2
            /*Works only on flat (horizontal) suface*/
            if (circle is Money)
            {
                ((Money)circle).RestingOnSolid(this);
            }
            #endregion
        }
Пример #18
0
        private void Initialize()
        {
            // Technical Points;
            mTechnicalPoints = kMaxTechnicalPoints;
            mRechargeTimer = 0;
            mRechargeTP = false;
            mWalkTimer = 0;
            mFiringDelay = 0;
            //mSkill1Available = true;
            //mSkill2Available = true;

            // Initialize name
            mName = "Arcanian";

            // Initialize Arcanian
            mCurrentState = ArcanianState.ArcanianInMenu;
            Velocity = kVelocity;
            mHealth = kHealth;
            mFacingLeft = false;
            mIsBlinking = false;
            mBlinkTimer = 0;
            mNumBlink = 0;
            mPlayShieldRegenCue = false;

            // Initialize aimer
            mAimerBar = new XNACS1Rectangle(Center, kAimerBarWidth, kAimerBarHeight);
            mAimerBar.Color = Color.Transparent;
            mAimerBar.RotateAngle = kAimerAngle;
            mAimer = new XNACS1Circle(Center, kAimerRadius);
            mAimer.Texture = "Arcanian/aimer";
            mAimer.RotateAngle = kAimerAngle;

            // Initialize bound
            mBoundMin = new XNACS1Rectangle(Center, kBoundWidth, kBoundHeight);
            mBoundMax = new XNACS1Rectangle(Center, kBoundWidth, kBoundHeight);
            mBoundMin.Texture = texBound;
            mBoundMax.Texture = texBound;
            mBoundMin.RemoveFromAutoDrawSet();
            mBoundMax.RemoveFromAutoDrawSet();

            // Initialize shield
            mShield = kShield;
            mShieldArt = new XNACS1Circle(Center, kShieldRadius);

            // Hide arcanian at menu/selection screen
            HideArcanian();

            // Temporary til we have a minimap view
            mMiniMapXPosition = World.World.WorldMax.X / 2;
        }