Exemple #1
0
        static public void CreateCharObj(double x, double y, List <SpriteObj> animationlist, PhysObj physicsobject, int depth, int speed, int scale, bool isplayer, string name = "null")
        {
            CharObj CharObject = new CharObj(x, y, animationlist, physicsobject, depth, speed, scale, isplayer);

            Objects.CharObjList.Add(CharObject);
            foreach (SpriteObj spriteobject in animationlist)
            {
                spriteobject.Speed = speed;
            }
            if (name == "null")
            {
                Objects.NameIDObjList.Add(new NameIDObj(CharObject.ID, CharObject.ID, "CharObj"));
            }
            else
            {
                Objects.NameIDObjList.Add(new NameIDObj(CharObject.ID, name, "CharObj"));
            }
        }
Exemple #2
0
 static public void PlayerDown(CharObj PlayerObj, bool sprint)
 {
     if (sprint == true)
     {
         PlayerObj.Speed = 5;
         PlayerObj.Y    += World.PlayerSprintSpeed;
     }
     else
     {
         PlayerObj.Speed = 10;
         PlayerObj.Y    += World.PlayerSpeed;
     }
     if (PlayerObj.CurrentAnimation != 3)
     {
         PlayerObj.CurrentAnimation = 3;
         PlayerObj.ResetFrames();
     }
 }
Exemple #3
0
 static public void PlayerLeft(CharObj PlayerObj, bool sprint)
 {
     if (sprint == true)
     {
         PlayerObj.Speed = 1;
         PlayerObj.X    -= World.PlayerSprintSpeed;
     }
     else
     {
         PlayerObj.Speed = 10;
         PlayerObj.X    -= World.PlayerSpeed;
     }
     if (PlayerObj.CurrentAnimation != 0)
     {
         PlayerObj.CurrentAnimation = 0;
         PlayerObj.ResetFrames();
     }
 }
Exemple #4
0
 static public void CharObjUpdate(CharObj CharObject)
 {
     CharObject.PhysicsObject.X = (float)CharObject.X;
     CharObject.PhysicsObject.Y = (float)CharObject.Y;
 }
Exemple #5
0
        public static void HandleInput()
        {
            KeyboardState key = keyboard.GetCurrentState();

            if (key.IsPressed(Key.E))
            {
                CharObj player = Objects.GetCharObj("Player");
                Objects.DeployEffectObj(Objects.GetEffectObj("ExplosionEffect"), player.X - (player.AnimationList[player.CurrentAnimation].Width / 2), player.Y);
            }
            if (KeyPressed() & key.PressedKeys.Count > 0)
            {
                //if (key.ToLower() != lastkey)
                //{
                //    Console.WriteLine(key);
                //}
                lastkey    = "null";
                currentkey = "null";
                foreach (Key akey in key.PressedKeys.Reverse())
                {
                    if (lastkey == "null")
                    {
                        if (akey == Key.W)
                        {
                            lastkey = "w";
                        }
                        if (akey == Key.A)
                        {
                            lastkey = "a";
                        }
                        if (akey == Key.S)
                        {
                            lastkey = "s";
                        }
                        if (akey == Key.D)
                        {
                            lastkey = "d";
                        }
                    }
                }
                foreach (Key akey in key.PressedKeys)
                {
                    if (currentkey == "null")
                    {
                        if (akey == Key.W)
                        {
                            currentkey = "w";
                        }
                        if (akey == Key.A)
                        {
                            currentkey = "a";
                        }
                        if (akey == Key.S)
                        {
                            currentkey = "s";
                        }
                        if (akey == Key.D)
                        {
                            currentkey = "d";
                        }
                    }
                }
                bool sprint = key.IsPressed(Key.LeftShift);
                if (currentkey == "w")
                {
                    foreach (CharObj CharObject in Objects.CharObjList)
                    {
                        if (CharObject.isPlayer)
                        {
                            Functions.PlayerUp(CharObject, sprint);
                            return;
                        }
                    }
                }
                if (currentkey == "a")
                {
                    foreach (CharObj CharObject in Objects.CharObjList)
                    {
                        if (CharObject.isPlayer)
                        {
                            Functions.PlayerLeft(CharObject, sprint);
                            return;
                        }
                    }
                }
                if (currentkey == "s")
                {
                    foreach (CharObj CharObject in Objects.CharObjList)
                    {
                        if (CharObject.isPlayer)
                        {
                            Functions.PlayerDown(CharObject, sprint);
                            return;
                        }
                    }
                }
                if (currentkey == "d")
                {
                    foreach (CharObj CharObject in Objects.CharObjList)
                    {
                        if (CharObject.isPlayer)
                        {
                            Functions.PlayerRight(CharObject, sprint);
                            return;
                        }
                    }
                }
            }
            else
            {
                if (lastkey == "w")
                {
                    foreach (CharObj CharObject in Objects.CharObjList)
                    {
                        if (CharObject.isPlayer)
                        {
                            Functions.PlayerReleaseUp(CharObject);
                        }
                    }
                }
                if (lastkey == "a")
                {
                    foreach (CharObj CharObject in Objects.CharObjList)
                    {
                        if (CharObject.isPlayer)
                        {
                            Functions.PlayerReleaseLeft(CharObject);
                        }
                    }
                }
                if (lastkey == "s")
                {
                    foreach (CharObj CharObject in Objects.CharObjList)
                    {
                        if (CharObject.isPlayer)
                        {
                            Functions.PlayerReleaseDown(CharObject);
                        }
                    }
                }
                if (lastkey == "d")
                {
                    foreach (CharObj CharObject in Objects.CharObjList)
                    {
                        if (CharObject.isPlayer)
                        {
                            Functions.PlayerReleaseRight(CharObject);
                        }
                    }
                }
            }
            Input.LastKeyState = keyboard.GetCurrentState();
        }
Exemple #6
0
 static public void PlayerReleaseUp(CharObj PlayerObj)
 {
     PlayerObj.CurrentAnimation = 6;
     PlayerObj.ResetFrames();
 }