Пример #1
0
        protected override void typeEffect(Laser laser)
        {
            lit_up = false;
            color = new Color(color.ToVector3() + laser.Color.ToVector3());

            if (laser.Color != Color.White) parent.addScore(laser.Color);
        }
Пример #2
0
        protected override void typeEffect(Laser laser)
        {
            if (laser.Color != Color.White && laser.Color != player_color)
            {
                parent.addScore(laser.Color);
                lit_up = true;
                color = new Color(color.ToVector3() + laser.Color.ToVector3());

            }
        }
Пример #3
0
        protected override void typeEffect(Laser laser)
        {
            color = new Color(color.ToVector3() + laser.Color.ToVector3());

            if (color == keyColor) lit_up = true;
        }
Пример #4
0
        public void AddLaser(Player player, Color tint)
        {
            var laser = new Laser(player.playerIndex);
            laser.Tint = tint;
            laser.SourceRect = texPlasma.Bounds;
            laser.DestinationRect = texPlasma.Bounds;

            laser.DestinationRect.X = player.DestinationRect.X;
            laser.DestinationRect.Y = player.DestinationRect.Y;

            lasers.Add(laser);

            effectFall.Play();
        }
Пример #5
0
        protected virtual void typeEffect(Laser laser)
        {
            lit_up = true;
            color = new Color(color.ToVector3() + laser.Color.ToVector3());

            if (laser.Color != Color.White) parent.addScore(laser.Color);
        }
Пример #6
0
 public void HandleCollision(Laser laser)
 {
     typeEffect(laser);
 }
Пример #7
0
        public bool isColliding(Laser laser)
        {
            BoundingBox bounds = getBounds();

            Vector2 normalizedLaserDirection = laser.Direction;
            normalizedLaserDirection.Normalize();
            Ray laser_ray = new Ray(new Vector3(laser.End, 0), new Vector3(normalizedLaserDirection, 0));

            float? intersection = bounds.Intersects(laser_ray);
            return (intersection > 0 && intersection < laser.Length);
        }
Пример #8
0
 public virtual void HandleCollision(Laser l)
 {
     health--;
     changeColor(l.Color);
 }
Пример #9
0
        public void HandleCollision(Laser laser)
        {
            if (laser.Color == Color.White) {
                health++;
            } else {
                health--;
            }

            if (health > max_health) {
                health = max_health;
            }

            laser.Chomp(bounds);
        }
Пример #10
0
        private Vector2 calculateBounceDirection(Laser l)
        {
            Vector2 direction = surfaceLineSegment.NormalizedDirection();
            Vector2 normal;
            normal.X = -direction.Y;
            normal.Y = direction.X;

            if (m_type == SurfaceType.Refractive) {
                if (Vector2.Dot(normal, l.Direction) < 0) {
                    normal = -normal;
                }

                /* Need 3d vectors for rotations and cross products! */
                Vector3 direction3d = new Vector3(l.Direction, 0f);
                direction3d.Normalize();

                Vector3 normal3d = new Vector3(normal, 0f);
                /* Already normalized! */

                Vector3 cross = Vector3.Cross(direction3d, normal3d);
                bool incidentToNormalClockwiseRotation = (cross.Z > 0);

                /* If direction -> normal is a CLOCKWISE rotation, then
                 * normal -> refractedDirection is a COUNTER-CLOCKWISE rotation. You will find this
                 * by the negating of theta2 below. */

                float incidentTheta = (float)Math.Acos(Vector3.Dot(direction3d, normal3d));
                float refractedTheta = incidentTheta / 2;

                if (incidentToNormalClockwiseRotation) {
                    refractedTheta = -refractedTheta; /* See above! */
                }

                Vector3 refractedDirection3d = Vector3.Transform(normal3d, Matrix.CreateRotationZ(refractedTheta));
                Vector2 refractedDirection = new Vector2(refractedDirection3d.X, refractedDirection3d.Y);

                return refractedDirection;
            }

            return Vector2.Reflect(l.Direction, normal);
        }
Пример #11
0
        public void HandleCollision(Laser l, Level parent)
        {
            /* Is this a laser we're generating? Don't bother! */
            if (m_collisions.ContainsValue(l)) { return; }

            Vector2? pIntersectNullable = l.FindIntersectionPoint(surfaceLineSegment);
            if (pIntersectNullable == null) {
                return;
            }

            Vector2 pIntersect = (Vector2)pIntersectNullable;

            Laser generating = null;

            // Have we already started a laser for this collision?
            if (!m_collisions.ContainsKey(l))
            {
                if (m_type == SurfaceType.Reflective || m_type == SurfaceType.Refractive)
                {
                    generating = new Laser(pIntersect, calculateBounceDirection(l), l.Color);
                    parent.AddLaser(generating);
                }
                m_collisions.Add(l, generating);
            } else {
                generating = m_collisions[l];
            }

            float chompdAmount = l.Chomp(surfaceLineSegment);

            if (m_type == SurfaceType.Reflective || m_type == SurfaceType.Refractive)
            {
                generating.AdjustLength(chompdAmount);
            }

            m_handledCollision.Add(l);
        }
Пример #12
0
 public void RemoveLaser(Laser remove)
 {
     remove.LaserEliminated -= new Laser.LaserHandler(RemoveLaser);
     lasers.Remove(remove);
 }
Пример #13
0
 public void AddLaser(Laser add)
 {
     lasers.Add(add);
     add.LaserEliminated += new Laser.LaserHandler(RemoveLaser);
     add.loadImage(m_content);
 }
Пример #14
0
        public void KeyboardUpdate()
        {
            input.Update();
            if (input.IsPauseMenuNewlyPressed()) manager.pauseGame();
            else
            {
                if (m_generating != null)
                {
                    energy -=15;
                    if (input.IsMoveUpPressed() && !input.IsMoveDownPressed()) { m_movement.X = 0; m_movement.Y = -10f; }
                    else if (!input.IsMoveUpPressed() && input.IsMoveDownPressed()) { m_movement.X = 0; m_movement.Y = 10f; }
                    else { m_movement.X = 0; m_movement.Y = 0f; }

                    if (input.IsAimUpPressed() && !input.IsAimDownPressed()) m_rotation = .1f;
                    else if (!input.IsAimUpPressed() && input.IsAimDownPressed()) m_rotation = -.1f;
                    else m_rotation = 0;
                }
                else
                {
                    energy +=5;
                    if (energy > 748) energy = 748;
                    m_movement.X = 0; m_movement.Y = 0; m_rotation = 0;
                }
                if (input.IsFireNewlyPressed()) { m_generating = new Laser(this); m_parent.AddLaser(m_generating); }
                else if (input.IsAltFireNewlyPressed()) { m_generating = new Laser(this, true); m_parent.AddLaser(m_generating); }
                if ((input.IsAltFireReleased() && input.IsFireReleased()) || energy <=0) { m_generating = null; }
            }
        }
Пример #15
0
 public void HandleCollision(Laser laser)
 {
     if (laser.Color == Color.White) health+=2;
     else health-=5;
     laser.Chomp(bounds);
 }
Пример #16
0
        public void MoveModel(Laser[] laserList, SoundEffect firingSound, int volumeMultiplier)
        {
            KeyboardState lastState;
            KeyboardState keyboardState = Keyboard.GetState();
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);
            MouseState mouseState = Mouse.GetState();
            // Create some velocity if the right trigger is down.
            Vector3 playerVelocityAdd = Vector3.Zero;
            // Find out what direction we should be thrusting, using rotation

            if (keyboardState.IsKeyDown(Keys.Left) || gamePadState.ThumbSticks.Right.X < 0)
            {
                // Rotate left.
                playerRotation -= -1.0f * 0.10f;
            }
            if (keyboardState.IsKeyDown(Keys.Right) || gamePadState.ThumbSticks.Right.X > 0)
            {
                // Rotate right.
                playerRotation -= 1.0f * 0.10f;
            }
            if (keyboardState.IsKeyDown(Keys.W) || gamePadState.ThumbSticks.Left.Y > 0)
            {
                // Move forwards
                playerVelocityAdd.X = -(float)Math.Sin(playerRotation);
                playerVelocityAdd.Z = -(float)Math.Cos(playerRotation);
                playerVelocityAdd *= 0.5f;
                playerVelocity += playerVelocityAdd;
            }
            if (keyboardState.IsKeyDown(Keys.A) || gamePadState.ThumbSticks.Left.X < 0)
            {
                // Move left
                playerVelocityAdd.X = -(float)Math.Cos(playerRotation);
                playerVelocityAdd.Z = +(float)Math.Sin(playerRotation);
                playerVelocityAdd *= 0.5f;
                playerVelocity += playerVelocityAdd;
            }
            if (keyboardState.IsKeyDown(Keys.S) || gamePadState.ThumbSticks.Left.Y < 0)
            {
                // Move right
                playerVelocityAdd.X = +(float)Math.Sin(playerRotation);
                playerVelocityAdd.Z = +(float)Math.Cos(playerRotation);
                playerVelocityAdd *= 0.5f;
                playerVelocity += playerVelocityAdd;
            }
            if (keyboardState.IsKeyDown(Keys.D) || gamePadState.ThumbSticks.Left.X > 0)
            {
                // Move forwards
                playerVelocityAdd.X = +(float)Math.Cos(playerRotation);
                playerVelocityAdd.Z = -(float)Math.Sin(playerRotation);
                playerVelocityAdd *= 0.5f;
                playerVelocity += playerVelocityAdd;
            }
            if (keyboardState.IsKeyDown(Keys.R) || gamePadState.IsButtonDown(Buttons.Back))
            {
                playerVelocity = Vector3.Zero;
                playerPosition = Vector3.Zero;
                playerRotation = 0.0f;
            }

            //are we shooting?
            if ((mouseState.LeftButton == ButtonState.Pressed) || gamePadState.Triggers.Right > 0)
            {
                //add another bullet.  Find an inactive bullet slot and use it
                //if all bullets slots are used, ignore the user input
                for (int i = 0; i < GameConstants.NumLasers; i++)
                {
                    if (!laserList[i].isActive)
                    {
                        Matrix playerTransform = Matrix.CreateRotationY(playerRotation);
                        laserList[i].direction = playerTransform.Forward;
                        laserList[i].speed = GameConstants.LaserSpeedAdjustment;
                        laserList[i].position = playerPosition + laserList[i].direction;
                        laserList[i].isActive = true;
                        firingSound.Play((0.1f * volumeMultiplier), 0.0f, 0.0f);
                        break; //exit the loop
                    }
                }
            }

            lastState = keyboardState;
        }