Пример #1
0
 public override void Update(float time, System.Drawing.PointF CameraLocation)
 {
     if (owner != null)
     {
         this.listedKey = true;
         float x = owner.Properties.CollisionRect.X + (owner.Properties.CollisionRect.Width / 2);
         float y = owner.Properties.CollisionRect.Y + (owner.Properties.CollisionRect.Height / 2);
         if (owner.Properties.Direction != this.Properties.Direction)
         {
             this.FlipY();
             this.Properties.Direction = owner.Properties.Direction;
         }
         x += owner.Properties.VelocityRect.X * owner.Properties.GameScreen.time;
         if (owner.Properties.Direction == Core.Sprite.SpriteProperties.Directions.Right)
         {
             x -= owner.Properties.CollisionRect.Width;
         }
         y -= (this.Properties.CollisionRect.Height / 2);
         this.Properties.CollisionRect = new RectangleF(x, y, this.Properties.CollisionRect.Width, this.Properties.CollisionRect.Height);
         for (int i = 0; i < PlayerKeyList.Count; i++)
         {
             if (PlayerKeyList[i].Key.KeyCode == System.Windows.Forms.Keys.A)
             {
                 if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Up)
                 {
                     Shoot();
                 }
             }
             PlayerKeyList.RemoveAt(i);
             i--;
         }
     }
 }
Пример #2
0
 public override void Update(float time, System.Drawing.PointF CameraLocation)
 {
     if (rotate)
     {
         rotateHandle();
     }
     for (int i = 0; i < PlayerKeyList.Count; i++)
     {
         if (PlayerKeyList[i].Key.KeyCode == System.Windows.Forms.Keys.Right)
         {
             if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Down)
             {
                 if (this.Properties.Direction == SpriteProperties.Directions.Right)
                 {
                     this.Properties.Direction = SpriteProperties.Directions.Left;
                     //this.FlipY();
                 }
             }
         }
         if (PlayerKeyList[i].Key.KeyCode == System.Windows.Forms.Keys.Left)
         {
             if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Down)
             {
                 if (this.Properties.Direction == SpriteProperties.Directions.Left)
                 {
                     this.Properties.Direction = SpriteProperties.Directions.Right;
                     //this.FlipY();
                 }
             }
         }
         PlayerKeyList.RemoveAt(i);
         i--;
     }
 }
Пример #3
0
 public void RemoveNullKeys(int betweensecond)
 {
     for (int i = 0; i < PlayerKeyList.Count; i++)
     {
         if (PlayerKeyList[i].BetweenClick > betweensecond)
         {
             if (i == 0)
             {
                 PlayerKeyList.RemoveAt(i);
                 i--;
             }
             else
             {
                 PlayerKeyList.RemoveRange(0, i + 1);
                 i = -1;
             }
         }
         if (i > 0)
         {
         }
     }
 }
Пример #4
0
        public bool findKeys(Keys[] fkeys, bool removeKeys)
        {
            if (PlayerKeyList.Count < fkeys.Length || fkeys.Length == 0)
            {
                return(false);
            }

            for (int i = 0; i < fkeys.Length; i++)
            {
                if (this.Properties.Direction == Core.Sprite.SpriteProperties.Directions.Left)
                {
                    if (fkeys[i] == Keys.Left)
                    {
                        fkeys[i] = Keys.Right;
                    }
                    if (fkeys[i] == Keys.Right)
                    {
                        fkeys[i] = Keys.Left;
                    }
                }
                if (PlayerKeyList[i].Key.KeyCode != fkeys[i])
                {
                    return(false);
                }
            }
            if (removeKeys)
            {
                if (fkeys.Length == 1)
                {
                    PlayerKeyList.RemoveAt(0);
                }
                else
                {
                    PlayerKeyList.RemoveRange(0, fkeys.Length);
                }
            }
            return(true);
        }
Пример #5
0
 public override void Update(float time, PointF CameraLocation)
 {
     if (this.Properties.CollisionRect.Y > this.Properties.GameScreen.GameRect.Height)
     {
         this.Properties.GameScreen.Reset();
     }
     if (jumping && this.JumpLength != RectangleF.Empty)
     {
         if (this.Properties.CollisionRect.Y <= this.JumpLength.Y)
         {
             jumping = false;
         }
     }
     LookisKill();
     for (int i = 0; i < PlayerKeyList.Count; i++)
     {
         if (PlayerKeyList[i].Key.KeyCode == System.Windows.Forms.Keys.Left)
         {
             if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Down)
             {
                 MoveLeftOrRight(true, -0.38f);
             }
             else if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Up)
             {
                 MoveLeftOrRight(false, 0f);
             }
         }
         if (PlayerKeyList[i].Key.KeyCode == System.Windows.Forms.Keys.Right)
         {
             if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Down)
             {
                 MoveLeftOrRight(true, 0.38f);
             }
             else if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Up)
             {
                 MoveLeftOrRight(false, 0f);
             }
         }
         if (PlayerKeyList[i].Key.KeyCode == System.Windows.Forms.Keys.Down)
         {
             if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Down)
             {
                 Crouch(true);
             }
             else if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Up)
             {
                 Crouch(false);
             }
         }
         if (PlayerKeyList[i].Key.KeyCode == System.Windows.Forms.Keys.Space)
         {
             if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Down)
             {
                 Jump(true, -0.38f);
             }
             else if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Up)
             {
                 Jump(false, 0f);
             }
         }
         if (PlayerKeyList[i].Key.KeyCode == System.Windows.Forms.Keys.A)
         {
             if (PlayerKeyList[i].ClickType == PlayerKey.ClickTypes.Up)
             {
                 Shoot();
             }
         }
         PlayerKeyList.RemoveAt(i);
         i--;
     }
 }