Exemplo n.º 1
0
    /* 함수명 : IsPressed
     * 목적 : - 인풋이 들어왔을때 Command에 해당하는 키가 입력 되었는지 체크하는 메서드
     *        - 해당 키 입력값을 받고 방향키 입력일 경우 방향키 입력의 값을 actor에게 넘겨줌.
     * 리턴 : bool pressed
     * 파라미터 : 유저가 누른 버튼키코드
     */
    public bool IsPressed(userInput btn)
    {
        pressedBtn = userInput.None;

        isJump   = Input.GetKey(KeyCode.Space);
        isCrouch = Input.GetKey(KeyCode.C);

        if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
        {
            horizInput = Input.GetAxis("Horizontal");
            vertInput  = Input.GetAxis("Vertical");
            moveVector = camRotPivot.forward * vertInput + camRotPivot.right * horizInput;
            pressedBtn = userInput.Move;
        }

        //TODO : 누른 버튼에 따른 AttackType command
        if (Input.GetMouseButtonDown(0))
        {
            pressedBtn = userInput.Attack;
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            actor.speed = 50f;
        }
        else
        {
            actor.speed = 8f;
        }
        return
            (btn == pressedBtn);
    }
Exemplo n.º 2
0
    public gameAssembled(int _h, int _w)
    {
        gameRunning = false;
        clicks      = 0;

        gArea    = new gamearea(_h, _w); //TODO rename all these 3!
        reporter = new reportMethods(gArea);
        reader   = new userInput(this);
    }
Exemplo n.º 3
0
    /* 인풋이 들어왔을때 Command에 해당하는 키가 입력 되었는지 체크하는 메서드
     * 해당 키 입력값을 받고 방향키 입력일 경우 방향키 입력의 값을 actor에게 넘겨줌.
     * 리턴 형은 bool
     */
    public bool IsPressed(userInput btn)
    {
        pressedBtn = userInput.None;

        if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
        {
            horizInput = Input.GetAxis("Horizontal");
            vertInput  = Input.GetAxis("Vertical");
            pressedBtn = userInput.Move;
        }
        else if (Input.GetKey(KeyCode.Space))
        {
            pressedBtn = userInput.MoveJump;
        }
        else if (Input.GetMouseButtonDown(0))
        {
            pressedBtn = userInput.Attack;
        }

        return
            (btn == pressedBtn);
    }
Exemplo n.º 4
0
    static void Main()
    {
        string nickname, inputLine;

        try
        {
            // Start PingSender thread
            PingSender ping = new PingSender();
            ping.Start();
            userInput test = new userInput();
            test.start();

            writer.WriteLine("PASS " + PASS);
            writer.Flush();
            writer.WriteLine("NICK " + NICK);
            writer.Flush();
            writer.WriteLine("JOIN " + CHANNEL);
            writer.Flush();

            while (true)
            {
                while ((inputLine = reader.ReadLine()) != null)
                {
                    System.Diagnostics.Debug.WriteLine(inputLine);

                    string message  = "";
                    string userName = "";

                    string[] parts = inputLine.Split(' ');

                    switch (parts[1])
                    {
                    case "JOIN":
                        userName = parts[0].Substring(1, parts[0].IndexOf('!') - 1);
                        Users.onUserJoin(userName);
                        break;

                    case "PART":
                        userName = parts[0].Substring(1, parts[0].IndexOf('!') - 1);
                        Users.onUserLeft(userName);
                        break;

                    case "MODE":
                        foreach (User us in Users.list)
                        {
                            if (us.name == parts[4])
                            {
                                us.admin = true;
                                break;
                            }
                        }
                        break;

                    case "353":
                        for (int i = 5; i < parts.Length; i++)
                        {
                            if (i == 5)
                            {
                                Users.onUserJoin(parts[5].Substring(1));
                            }
                            else
                            {
                                Users.onUserJoin(parts[i]);
                            }
                        }
                        break;

                    case "PRIVMSG":
                        if (parts[0].Contains("jtv"))
                        {
                            break;
                        }

                        userName = parts[0].Substring(1, parts[0].IndexOf('!') - 1);
                        Users.onUserJoin(userName);

                        string tmp = "";
                        for (int i = 3; i < parts.Length; i++)
                        {
                            tmp += parts[i] + " ";
                        }

                        if (Users.isUserAdmin(userName))
                        {
                            if (userName == "monstercat")
                            {
                                writeLine(UppercaseFirst(userName) + " " + tmp, ConsoleColor.Cyan);
                            }
                            else
                            {
                                writeLine(UppercaseFirst(userName) + " " + tmp, ConsoleColor.Yellow);
                            }
                        }
                        else
                        {
                            writeLine(UppercaseFirst(userName) + " " + tmp);
                        }

                        // Now check if the user just sent a command
                        if (parts[3].StartsWith(":!"))
                        {
                            switch (parts.Length)
                            {
                            case 4:
                                Command.Check(userName, parts[3].Substring(2).ToLower());
                                break;

                            case 5:
                                Command.Check(userName, parts[3].Substring(2).ToLower(), parts[4].ToLower());
                                break;

                            case 6:
                                Command.Check(userName, parts[3].Substring(2).ToLower(), parts[4].ToLower(), parts[5].ToLower());
                                break;

                            case 7:
                                Command.Check(userName, parts[3].Substring(2).ToLower(), parts[4].ToLower(), parts[5].ToLower(), parts[6].ToLower());
                                break;

                            default:
                                // Else do nothing
                                break;
                            }
                        }
                        break;

                    default:
                        // Unknown message? Don't care, don't show it, it's in debug window anyways!
                        break;
                    }

                    #region Console Output/Send message
                    // Makes sure to not show/sends empty messages
                    if (message != "")
                    {
                        writer.WriteLine(message);
                        writer.Flush();
                    }
                    #endregion
                }

                // Close all streams
                writer.Close();
                reader.Close();
                irc.Close();
            }
        }
        catch (Exception e)
        {
            // Show the exception, sleep for a while and try to establish a new connection to irc server
            Console.WriteLine(e.ToString());
            Thread.Sleep(5000);
            Main();
        }
    }