예제 #1
0
    // Update is called once per frame
    void Update()
    {
        var oldpos = Position;

        if (Level < 1)
        {
            return;
        }
        var x = Position.x;
        var y = Position.y;

        if (Level == 1)
        {
            if (Input.GetKeyDown(KeyCode.D))
            {
                x += 1;
            }
            if (Input.GetKeyDown(KeyCode.A))
            {
                x -= 1;
            }
            if (Input.GetKeyDown(KeyCode.W))
            {
                y += 1;
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                y -= 1;
            }
        }

        Position = new Vector2(x, y);
        if ((PlayerMovementEvent != null) && (oldpos != Position))
        {
            PlayerMovementEvent.Invoke();
        }
    }