Пример #1
0
        protected async void SendCommand()
        {
            try
            {
                String[] INP = TerminalIN.Text.ToUpper().Split(' ');
                if (INP[0].Trim() == "MOVE" && talking == false && landed == false)
                {
                    if (INP[1].Trim().Length == 9)
                    {
                        String[] inpx = INP[1].Split(':');
                        if (int.Parse(inpx[0]) <= (player.PXY.X + 1000) && int.Parse(inpx[0]) >= (player.PXY.X - 1000) && int.Parse(inpx[1]) <= (player.PXY.Y + 1000) && int.Parse(inpx[1]) >= (player.PXY.Y - 1000))
                        {
                            player.PXY.X = int.Parse(inpx[0]);
                            player.PXY.Y = int.Parse(inpx[1]);
                        }
                        foreach (Place PL in world.ListPlaces)
                        {
                            if (INP[1] == PL.placeXY.CurrentC())
                            {
                                player.PXY.X    = int.Parse(inpx[0]);
                                player.PXY.Y    = int.Parse(inpx[1]);
                                CommandLog.Text = CommandLog.Text + "";
                                CurrentPlaceID  = PL.plindex;
                            }
                        }
                        foreach (RandomShip RS in world.ListRandShips)
                        {
                            if (INP[1] == RS.EXY.CurrentC())
                            {
                                player.PXY.X    = int.Parse(inpx[0]);
                                player.PXY.Y    = int.Parse(inpx[1]);
                                CommandLog.Text = CommandLog.Text + "";
                            }
                        }
                        CommandLog.Text = INP[0] + ": " + INP[1];
                        if (player.questactive)
                        {
                            player.Checkquest(world.ListPlaces[CurrentPlaceID].placename);
                        }
                    }
                }
                if (TerminalIN.Text.ToUpper() == "LAND" && landed == false)
                {
                    for (int i = 0; i < world.ListPlaces.Count; i++)
                    {
                        if (player.PXY.CurrentC() == world.ListPlaces[i].placeXY.CurrentC())
                        {
                            PlaceWindow.Location = new Point(400, 0);
                            PeopleOnPlace.Text   = "";
                            CurrentPlaceID       = world.ListPlaces[i].plindex;
                            MapWindow.Visible    = false;
                            PlaceTitle.Text      = world.ListPlaces[i].placename;
                            PlaceWindow.Visible  = true;
                            CommandLog.Text      = "YOU'VE LANDED!\nINSERT THE NUMBER OF THE NPC YOU WISH TO INTERACT WITH";
                            landed = true;
                            for (int o = 0; o < world.ListPeople.Count; o++)
                            {
                                if (world.ListPeople[o].Plindex == world.ListPlaces[i].plindex)
                                {
                                    if (world.ListPeople[o].hasQuest == true)
                                    {
                                        if (world.ListPeople[o].isQuestInProg)
                                        {
                                            PeopleOnPlace.Text = PeopleOnPlace.Text + world.ListPeople[o].PlInIndex + " - " + world.ListPeople[o].name + " [!] " + "\n";
                                        }
                                        else
                                        {
                                            PeopleOnPlace.Text = PeopleOnPlace.Text + world.ListPeople[o].PlInIndex + " - " + world.ListPeople[o].name + " [Q] " + "\n";
                                        }
                                    }
                                    if (world.ListPeople[o].hasQuest == false)
                                    {
                                        PeopleOnPlace.Text = PeopleOnPlace.Text + world.ListPeople[o].PlInIndex + " - " + world.ListPeople[o].name + "\n";
                                    }
                                }
                            }
                        }
                    }
                }

                try
                {
                    if (int.Parse(TerminalIN.Text) > 0 && landed == true)
                    {
                        for (int i = 0; i < world.ListPeople.Count; i++)
                        {
                            if (int.Parse(TerminalIN.Text) == world.ListPeople[i].PlInIndex && world.ListPeople[i].Plindex == world.ListPlaces[CurrentPlaceID].plindex)
                            {
                                talkingto = world.ListPeople[i].pindex;
                                TALKTO(talkingto, "");
                            }
                        }
                    }
                }
                catch (Exception) { }

                try
                {
                    INP = TerminalIN.Text.ToUpper().Split(' ');
                    if (int.Parse(INP[1]) > 0 && inshop == true)
                    {
                        for (int i = 0; i < world.ListPeople.Count; i++)
                        {
                            if (INP[0].ToUpper() == world.ListPeople[talkingto].INNV.InInv[i].Name.ToUpper() && player.pmoney >= (world.ListPeople[talkingto].INNV.InInv[i].Value * int.Parse(INP[1])))
                            {
                                if (int.Parse(INP[1]) >= world.ListPeople[talkingto].INNV.InInv[i].Amount)
                                {
                                    INP[1] = world.ListPeople[talkingto].INNV.InInv[i].Amount.ToString();
                                }
                                player.INV.ADDITEM(INP[0], int.Parse(INP[1]));
                                player.pmoney -= (world.ListPeople[talkingto].INNV.InInv[i].Value * int.Parse(INP[1]));
                                world.ListPeople[talkingto].INNV.REMOVEITEM(INP[0], int.Parse(INP[1]));
                                SHOPTO(talkingto);
                            }
                        }
                    }
                }
                catch (Exception) { }

                if (TerminalIN.Text.ToUpper() == "QUEST" && talking == true)
                {
                    INNFO = "TALK | INFO | BACK\n";
                    if (player.questReady && player.questfrom == world.ListPeople[talkingto].pindex)
                    {
                        PeopleOnPlace.Text = INNFO + "DONE - TO FINISH THE QUEST: " + world.ListPeople[talkingto].questname;
                    }
                    else if (!player.questReady && player.questactive && player.questfrom == world.ListPeople[talkingto].pindex)
                    {
                        PeopleOnPlace.Text = INNFO + "QUEST IS IN PROGRESS: " + world.ListPeople[talkingto].questname;
                    }
                    else
                    {
                        PeopleOnPlace.Text = INNFO + "GO - TO ACCEPT THE QUEST: " + world.ListPeople[talkingto].questname;
                    }
                }

                if (TerminalIN.Text.ToUpper() == "INFO" && talking == true)
                {
                    PeopleOnPlace.Text = "TALK | INFO | BACK\n" + world.ListPeople[talkingto].Info();
                }

                if (TerminalIN.Text.ToUpper() == "GO" && talking == true)
                {
                    TALKTO(talkingto, "");
                    player.Setcurrentquest(world.ListPeople[talkingto].questname, world.ListPeople[talkingto].questplace, talkingto);
                    world.ListPeople[talkingto].isQuestInProg = true;
                }

                if (TerminalIN.Text.ToUpper() == "BACK" && talking == true)
                {
                    TerminalIN.Text    = "";
                    PeopleOnPlace.Text = "";
                    for (int i = 0; i < world.ListPlaces.Count; i++)
                    {
                        if (player.PXY.CurrentC() == world.ListPlaces[i].placeXY.CurrentC())
                        {
                            PlaceTitle.Text = world.ListPlaces[i].placename;
                            CommandLog.Text = "YOU'VE LANDED!\nINSERT THE NUMBER OF THE NPC\nYOU WISH TO INTERACT WITH";
                            talking         = false;
                            inshop          = false;
                            for (int o = 0; o < world.ListPeople.Count; o++)
                            {
                                if (world.ListPeople[o].Plindex == world.ListPlaces[i].plindex)
                                {
                                    PeopleOnPlace.ReadOnly = false;
                                    if (world.ListPeople[o].hasQuest == true)
                                    {
                                        PeopleOnPlace.Text = PeopleOnPlace.Text + world.ListPeople[o].PlInIndex + " - " + world.ListPeople[o].name + " [Q] " + "\n";
                                    }
                                    if (world.ListPeople[o].hasQuest == false)
                                    {
                                        PeopleOnPlace.Text = PeopleOnPlace.Text + world.ListPeople[o].PlInIndex + " - " + world.ListPeople[o].name + "\n";
                                    }
                                    PeopleOnPlace.ReadOnly = true;
                                }
                            }
                        }
                    }
                }

                else if (TerminalIN.Text.ToUpper() == "TALK" && talking == true)
                {
                    TALKTO(talkingto, world.ListPeople[talkingto].Talk());
                }

                else if (TerminalIN.Text.ToUpper() == "INFO" && talking == true)
                {
                    TALKTO(talkingto, world.ListPeople[talkingto].Info());
                }

                if (TerminalIN.Text.ToUpper() == "DONE" && talking == true && player.questReady == true && player.questfrom == talkingto)
                {
                    world.ListPeople[talkingto].hasQuest = false;
                    player.Questdone(world.r.Next(50, 100));
                    TALKTO(talkingto, world.ListPeople[talkingto].QuestDone());
                }

                else if (TerminalIN.Text.ToUpper() == "SHOP" && talking == true && world.ListPeople[talkingto].IsTrader)
                {
                    SHOPTO(talkingto);
                }

                else if (TerminalIN.Text.ToUpper() == "BACK")
                {
                    if (landed)
                    {
                        PlaceWindow.Visible = false;
                        MapWindow.Visible   = true;
                        CommandLog.Text     = "TAKEOFF!";
                        landed = false;
                    }
                    else if (fighting)
                    {
                        fighting              = false;
                        MapWindow.Visible     = true;
                        BattleWindow.Location = new Point(800, 0);
                        BattleTitle.Text      = "Fighting:";
                        TESTOBJ.Location      = new Point(10, 10);
                        SpeedControl.Value    = 0;
                        TurnControl.Value     = 0;
                        BattleTimer.Enabled   = false;
                        SpeedTimer.Enabled    = false;
                    }
                }

                if (TerminalIN.Text.ToUpper() == "ATTACK")
                {
                    foreach (RandomShip RS in world.ListRandShips)
                    {
                        if (RS.EXY.CurrentC() == player.PXY.CurrentC())
                        {
                            fighting              = true;
                            MapWindow.Visible     = false;
                            BattleWindow.Location = MapWindow.Location;
                            BattleTitle.Text      = BattleTitle.Text + " " + RS.Ename;
                            BattleTimer.Enabled   = true;
                            SpeedTimer.Enabled    = true;
                        }
                    }
                }

                Stats.Text = player.ShowClearStats();
                SCAN();
                ////////////////////////////////////////
                //////////////////////////////////////////////////
                ////////////////////////////////////////////////////////////
                if (TerminalIN.Text.ToUpper() == "DEBUG")
                {
                    CommandLog.Text = "";
                    foreach (RandomShip EN in world.ListRandShips)
                    {
                        CommandLog.Text = CommandLog.Text + "\n" +
                                          EN.Ename + " | " + EN.Allegiance + " | " + EN.IsHostile() + " | " + EN.EXY.CurrentC();
                    }

                    //CommandLog.Text = player.questacitvename + " | " +
                    //player.questacitvetarget + " | " +
                    //world.ListPeople[player.questfrom].name + " | " + world.ListPeople[player.questfrom].pindex;

                    //for (int pp = 0; pp < world.ListPeople.Count; pp++)
                    //{
                    //    CommandLog.Text = CommandLog.Text + "\n" +
                    //        world.ListPeople[pp].name + " | " +
                    //        world.ListPeople[pp].pindex + " | " +
                    //        world.ListPeople[pp].hasQuest.ToString() + " | " +
                    //        world.ListPeople[pp].questplace + " | " +
                    //        world.ListPeople[pp].Plindex + " | " +
                    //        world.ListPeople[pp].IsTrader.ToString();
                    //}

                    //for (int i = 0; i < world.ListPlaces.Count; i++)
                    //{
                    //    CommandLog.Text = CommandLog.Text + "\n" +
                    //        world.ListPlaces[i].placename + " | " +
                    //        world.ListPlaces[i].plindex + " | " +
                    //        world.ListPlaces[i].placeXY.CurrentC();
                    //}
                }
                ////////////////////////////////////////////////////////////
                //////////////////////////////////////////////////
                ////////////////////////////////////////
                if (TerminalIN.Text.ToUpper() == "INV")
                {
                    CommandLog.Text = "INVENTORY:";
                    for (int inv = 0; inv < player.INV.InInv.Count; inv++)
                    {
                        if (player.INV.InInv[inv].Amount > 0)
                        {
                            CommandLog.Text = CommandLog.Text + "\n" +
                                              player.INV.InInv[inv].Name + "  |  " +
                                              player.INV.InInv[inv].Amount + "  |  " +
                                              player.INV.InInv[inv].Desc;
                        }
                    }
                }

                //foreach(RandomShip EN in world.ListRandShips)
                //{
                //    if(R.Next(0, 2) == R.Next(0, 2) && EN.EXY.CurrentC() != player.PXY.CurrentC())
                //    {
                //        EN.EXY = new Coordinates(R.Next(EN.EXY.X - 500, EN.EXY.X + 500), R.Next(EN.EXY.Y - 500, EN.EXY.Y + 500));
                //    }
                //}
            }
            catch (Exception) { CommandLog.Text = CommandLog.Text + "\nCOMMAND INCORRECT!"; }
            TerminalIN.Text = "";
            await Task.Delay(1);
        }