예제 #1
0
파일: VictimLeaf.cs 프로젝트: AnyKey/tojam4
        public VictimLeaf(  MegaTile ParentMegaTile,
                            Animation GroundAnimation, 
                            Animation StumpAnimation, 
                            Animation ExplodeAnimation, 
                            Animation TornadoAnimation,
                            string SoundFileName,
                            Vector2 Position)
        {
            this.megatile = ParentMegaTile;
            this.GroundAnimation = GroundAnimation;
            this.StumpAnimation = StumpAnimation;
            this.ExplodeAnimation = ExplodeAnimation;
            this.TornadoAnimation = TornadoAnimation;

            this.soundHit = SoundFileName;

            GroundHealth = 0;
            TornadoHealth = 0;

            Mass = 0.1f;

            bounds = new Rectangle2D(Position.X, Position.Y, TornadoAnimation.FrameWidth, TornadoAnimation.FrameHeight);

            state = State.Flying;

            PreLoadSounds();
        }
예제 #2
0
        public bool Intersects(Rectangle2D rect)
        {
            bool intersect = false;
            if (X < rect.X + rect.Width)
            {
                if (X + Width > rect.X)
                {
                    if (Y + Height > rect.Y)
                    {
                        if (Y < rect.Y + rect.Height)
                        {
                            intersect = true;
                        }
                    }
                }
            }

            return intersect;
        }
예제 #3
0
        public VictimSkyscraper(MegaTile ParentMegaTile,
                            Animation GroundAnimation,
                            Animation StumpAnimation,
                            Animation ExplodeAnimation,
                            Animation TornadoAnimation,
                            string SoundFileName,
                            Vector2 Position)
        {
            this.megatile = ParentMegaTile;
            this.GroundAnimation = GroundAnimation;
            this.StumpAnimation = StumpAnimation;
            this.ExplodeAnimation = ExplodeAnimation;
            this.TornadoAnimation = TornadoAnimation;

            this.soundHit = SoundFileName;

            removeFromMegaTileOnDeath = false;

            bounds = new Rectangle2D(Position.X, Position.Y, GroundAnimation.FrameWidth, GroundAnimation.FrameHeight);

            state = State.Ground;

            PreLoadSounds();
        }
예제 #4
0
파일: Victim.cs 프로젝트: AnyKey/tojam4
        /// <summary>
        /// Try and damage our victims with our stats
        /// </summary>
        /// <param name="victimsToCollideWith"></param>
        protected virtual void HitCheck(Victim groundObject)
        {
            if (groundObject.state == State.Ground)
            {
                float diameter = 0.0f;
                if (bounds.Width > bounds.Height)
                {
                    diameter = bounds.Width;
                }
                else
                {
                    diameter = bounds.Height;
                }

                Rectangle2D collideBox = new Rectangle2D(this.bounds.Center.X - (diameter / 2.0f), this.bounds.Center.Y - (diameter / 2.0f), diameter, diameter);

                switch (state)
                {
                    case State.Flying:
                        if (collideBox.Rectangle.Intersects(groundObject.bounds.Rectangle)) //we need to add damage
                        {
                            SoundEffectEngine.Play(soundHit,SoundEffectEngine.Priority.Normal);

                            float damageDone = getDamage(groundObject);

                            float resdamage = groundObject.RecieveHit(damageDone, this.tornado);

                            if (resdamage > 0)
                            {
                                this.TornadoHealth = 0; //If we can't kill the ground
                            }

                            if (this.TornadoHealth <= 0)
                            {
                                state = State.Exploding;
                            }
                        }
                        break;
                }
            }
        }
예제 #5
0
 public bool IsWithin(Rectangle2D InnerRect)
 {
     bool inner = false;
     if (this.X < InnerRect.X && this.Y < InnerRect.Y && this.X + this.Width > InnerRect.X + InnerRect.Width && this.Y + this.Height > InnerRect.Y + InnerRect.Height)
     {
         inner = true;
     }
     return inner;
 }
예제 #6
0
파일: Animation.cs 프로젝트: AnyKey/tojam4
 /// <summary>
 /// Draw a frame of the animation to the screen at the given location.
 /// dest specifies the rectangle to be filled by the frame
 /// Direction value orients the frame, and is given in radians
 /// </summary>
 public void Draw(SpriteBatch sBatch, Rectangle2D dest, double direction)
 {
     sBatch.Draw(texture, dest.DrawingOffset,
         new Rectangle(currentFrame * frameWidth, 0, frameWidth, frameHeight), color,
         (float)direction, new Vector2(frameWidth/2, frameHeight/2), SpriteEffects.None, 0);
 }
예제 #7
0
파일: VictimUFO.cs 프로젝트: AnyKey/tojam4
        //randomly place object in world on construction
        protected virtual void PlaceInWorld()
        {
            int border = rnd.Next(0, 3);
            float X;
            float Y;

            switch (border)
            {
                case (int)Heading.North:
                    flyHeading = rnd.Next() * ((float)Math.PI / 4f) + 3f * (float)Math.PI / 4f;
                    Y = 1 - squareDimensions;
                    X = rnd.Next(0, (int)level.Bounds.Width - squareDimensions);
                    break;
                case (int)Heading.East:
                    flyHeading = rnd.Next() * ((float)Math.PI / 4f) + 5f * (float)Math.PI / 4f;
                    X = level.Bounds.Width - 1;
                    Y = rnd.Next(0, (int)level.Bounds.Height - squareDimensions);
                    break;
                case (int)Heading.South:
                    flyHeading = rnd.Next() * ((float)Math.PI / 4f) + 7f * (float)Math.PI / 4f;
                    Y = level.Bounds.Height - 1;
                    X = rnd.Next(0, (int)level.Bounds.Width - squareDimensions);
                    break;
                case (int)Heading.West:
                    flyHeading = rnd.Next() * (float)Math.PI / 4f + (float)Math.PI / 4f;
                    X = 1 - squareDimensions;
                    Y = rnd.Next(0, (int)level.Bounds.Height - squareDimensions);
                    break;
                default:
                    throw new Exception("Unknown Border Of The Level to Generate");
                    break;
            }

            bounds = new Rectangle2D(X, Y, squareDimensions, squareDimensions);
        }