コード例 #1
0
ファイル: Map.cs プロジェクト: FaNtA91/pokemonapi
        public Tile GetTileWithPlayer()
        {
            /*
             * Credits goes to brunelli1989 for a fix
             */
            if (playerTile == null || playerTile.Location != client.GetPlayer().Location)
            {
                uint playerId = client.Player.Id;

                playerTile = GetTiles(false, false).FirstOrDefault(
                    t => t.Objects.Any(
                        o => o.Id == 0x63 && o.Data == playerId));
                playerTile.Location = client.GetPlayer().Location;
            }
            return(playerTile);
        }
コード例 #2
0
        public void Approach()
        {
            Player p = client.GetPlayer();

            p.GoTo = Location;
        }
コード例 #3
0
            public bool Login(string login, string password, string charName)
            {
                //if the player is logged or the window is minimazed return false.
                if (client.Window.IsMinimized())
                {
                    if (Report != null)
                    {
                        Report.Invoke(State.Minimized);
                    }
                    return(false);
                }
                else if (client.LoggedIn())
                {
                    if (client.GetPlayer().HasFlag(Pokemon.Constants.Flag.InBattle))
                    {
                        if (Report != null)
                        {
                            Report.Invoke(State.InBattle);
                        }
                        return(false);
                    }
                    //send CTRL+G, or however it is done
                    //TO DO

                    /*
                     * client.Input.SendMessage(Hooks.WM_KEYDOWN, (int)Keys.Control, 0);
                     * client.Input.SendMessage(Hooks.WM_KEYDOWN, (int)Keys.G, 0);
                     * client.Input.SendMessage(Hooks.WM_CHAR, (int)Keys.G, 0);
                     * client.Input.SendMessage(Hooks.WM_KEYUP, (int)Keys.G, 0);
                     * client.Input.SendMessage(Hooks.WM_KEYUP, (int)Keys.Control, 0);
                     * Thread.Sleep(300);*/
                    return(false);
                }
                else
                {
                    //assure the screen is clean, no dialog open
                    client.Input.SendKey(Keys.Escape);
                    client.Input.SendKey(Keys.Escape);
                    if (Report != null)
                    {
                        Report.Invoke(State.DialogsCleaned);
                    }

                    //reset the selected char value..
                    client.Memory.WriteUInt32(Pokemon.Addresses.Client.LoginSelectedChar, 0);
                    if (Report != null)
                    {
                        Report.Invoke(State.ResetSelectedCharValue);
                    }

                    //reset the char count value..
                    client.Memory.WriteInt32(Pokemon.Addresses.Client.LoginCharListLength, 0);
                    if (Report != null)
                    {
                        Report.Invoke(State.ResetSelectedCharCount);
                    }

                    //click the enter the game button
                    client.Input.Click(120, client.Window.Size().Height - 250);
                    if (Report != null)
                    {
                        Report.Invoke(State.ClickEnterButton);
                    }

                    //wait the dialog open
                    int waitTime = 2000;
                    while (!client.Window.IsDialogOpen() && client.Window.GetDialogCaption() != "Enter Game")
                    {
                        Thread.Sleep(100);
                        waitTime -= 100;
                        if (waitTime <= 0)
                        {
                            if (Report != null)
                            {
                                Report.Invoke(State.LoginDialogDidntOpen);
                            }
                            return(false);
                        }
                    }
                    if (Report != null)
                    {
                        Report.Invoke(State.LoginDialogOpened);
                    }

                    //now we have to send the login and the password
                    client.Input.SendString(login);
                    if (Report != null)
                    {
                        Report.Invoke(State.InputAccName);
                    }

                    //press tab
                    client.Input.SendKey(Keys.Tab);
                    if (Report != null)
                    {
                        Report.Invoke(State.PressTab);
                    }

                    //put the pass
                    client.Input.SendString(password);
                    if (Report != null)
                    {
                        Report.Invoke(State.InputPassword);
                    }

                    //press enter..
                    client.Input.SendKey(Keys.Enter);
                    if (Report != null)
                    {
                        Report.Invoke(State.PressEnter);
                    }

                    //wait for the charlist dialog
                    waitTime = 4000;
                    while (CharListCount == 0)
                    {
                        Thread.Sleep(100);
                        waitTime -= 100;
                        if (waitTime <= 0)
                        {
                            if (Report != null)
                            {
                                Report.Invoke(State.CharListNotReceived);
                            }
                            return(false);
                        }
                    }
                    if (Report != null)
                    {
                        Report.Invoke(State.CharListReceived);
                    }

                    waitTime = 1000;
                    while (client.Window.GetDialogCaption() == "Connecting")
                    {
                        Thread.Sleep(100);
                        waitTime -= 100;
                        if (waitTime <= 0)
                        {
                            if (Report != null)
                            {
                                Report.Invoke(State.ConnectingDialogNotGone);
                            }
                            return(false);
                        }
                    }
                    if (Report != null)
                    {
                        Report.Invoke(State.ConnectingDialogGone);
                    }

                    Thread.Sleep(100);

                    // Check if there is a message of the day
                    if (client.Window.GetDialogCaption() != "Select Character")
                    {
                        client.Input.SendKey(Keys.Enter);
                        Thread.Sleep(100);
                        if (Report != null)
                        {
                            Report.Invoke(State.Motd);
                        }
                    }
                }

                //now we loop at the charlist to find the selected char..
                foreach (var ch in CharacterList)
                {
                    Thread.Sleep(100); //make sure the client process the msg
                    //we start at position 0
                    if (string.Compare(ch.CharName, charName, true) == 0)
                    {
                        //we found the char
                        //lets press the entrer key
                        client.Input.SendKey(Keys.Enter);
                        if (Report != null)
                        {
                            Report.Invoke(State.SelectedCharFound);
                        }
                        return(true);
                    }

                    //move to the next char
                    client.Input.SendKey(Keys.Down);
                    if (Report != null)
                    {
                        Report.Invoke(State.GoToNextChar);
                    }
                }

                //char not found.
                if (Report != null)
                {
                    Report.Invoke(State.SelectedCharNotFound);
                }
                return(false);
            }