Inheritance: IConsole
Example #1
0
 private void CreateRunner(Collection <Target> target, Collection <Parameter> param)
 {
     try
     {
         ManualResetEvent resetEvent = new ManualResetEvent(false);
         TextConsole      console    = new TextConsole();
         //console.Show();
         //ThreadStart consoleThreadStart = console.Show;
         //Thread consoleThread = new Thread(consoleThreadStart);
         //consoleThread.IsBackground = true;
         //consoleThread.Start();
         doneEvents.Add(resetEvent);
         TargetRunner runner = new TargetRunner(target, param, null, resetEvent);
         targetRunners.AddItem(runner);
         ThreadPool.QueueUserWorkItem(runner.ThreadPoolCallback, targetRunners.Count - 1);
         //ThreadPool.SetMaxThreads(maxRunners, maxRunners);
         //WaitOrTimerCallback waitOrTimerCallback = runner.ThreadPoolCallback;
         //ThreadPool.RegisterWaitForSingleObject(resetEvent, waitOrTimerCallback, targetRunners, TEN_MINUTES, true);
         WaitHandle.WaitAny(doneEvents.ToArray());
         //RemoveItemFromQueue(targetRunners.Count - 1);
         OnRemoveFromQueueEvent(runner, new RemoveFromQueueEventArgs(targetRunners.Count - 1));
     }
     catch
     {
     }
 }
        public void PlayersSurestrike()
        {
            TextConsole  _TextConsole = UI.Look._TextConsole;
            ScreenBuffer Buffer       = TextConsole.ScrapBuffer;

            Core.XRLCore.Core.RenderMapToBuffer(Buffer);
            var cell = PickDirection();

            ThrowSureStrike(cell);
        }
Example #3
0
        public Gerador_Grafos()
        {
            this.InitializeComponent();
            ApplicationView view = ApplicationView.GetForCurrentView();

            view.TryEnterFullScreenMode();

            myConsole  = new TextConsole(Console_output);
            graphStats = new Stats(Grafo_stats);
            graphStats.Clear();
        }
        public void ReadInputWithPrompt()
        {
            MessageBus    bus = new MessageBus();
            StringBuilder sb  = new StringBuilder();

            using (StringWriter writer = new StringWriter(sb))
                using (TextConsole console = new TextConsole(bus, TextReader.Null, writer))
                {
                    bus.Send(new InputRequestedMessage("What's up?"));

                    sb.ToString().Should().Be("What's up? ");
                }
        }
        public void ReadInputEnded()
        {
            MessageBus bus = new MessageBus();

            using (TextConsole console = new TextConsole(bus, TextReader.Null, TextWriter.Null))
            {
                bool done = false;
                bus.Subscribe <InputEndedMessage>(m => done = true);

                bus.Send(new InputRequestedMessage());

                done.Should().BeTrue();
            }
        }
Example #6
0
            public TargetRunner(Collection <Target> targets, Collection <Parameter> parameters, TextConsole console, ManualResetEvent doneEvent)
            {
                this._doneEvent = doneEvent;
                this.targets    = targets;
                this.parameters = parameters;
                this.nantPath   = "";
                nantrun         = new Process();
                Console         = console;

                //
                //nantrun
                //
                nantrun.OutputDataReceived += new DataReceivedEventHandler(nantrun_OutputDataReceived);
                nantrun.ErrorDataReceived  += new DataReceivedEventHandler(nantrun_OutputDataReceived);
            }
        public void ReadEmptyLine()
        {
            MessageBus bus = new MessageBus();

            using (StringReader reader = new StringReader(Environment.NewLine))
                using (TextConsole console = new TextConsole(bus, reader, TextWriter.Null))
                {
                    List <string> lines = new List <string>();
                    bus.Subscribe <InputReceivedMessage>(m => lines.Add(m.Line));

                    bus.Send(new InputRequestedMessage());

                    lines.Should().Equal(string.Empty);
                }
        }
        public void WriteAfterDispose()
        {
            MessageBus    bus = new MessageBus();
            StringBuilder sb  = new StringBuilder();

            using (StringWriter writer = new StringWriter(sb))
            {
                using (TextConsole console = new TextConsole(bus, TextReader.Null, writer))
                {
                }

                bus.Send(new OutputMessage("one"));

                sb.ToString().Should().BeEmpty();
            }
        }
Example #9
0
        private async Task MainAsync2()
        {
            _client = new DiscordSocketClient();

            _client.Log += Log;

            string token = BotConfig.Token; // Remember to keep this private!
            await _client.LoginAsync(TokenType.Bot, token);

            await _client.StartAsync();

            TextConsole.Log($"_client.Latency: {_client.Latency}");

            // Block this task until the program is closed.
            await Task.Delay(-1);
        }
        public void WriteTwoLines()
        {
            MessageBus    bus = new MessageBus();
            StringBuilder sb  = new StringBuilder();

            using (StringWriter writer = new StringWriter(sb))
                using (TextConsole console = new TextConsole(bus, TextReader.Null, writer))
                {
                    bus.Send(new OutputMessage("one"));

                    sb.ToString().Should().Be("one" + Environment.NewLine);

                    bus.Send(new OutputMessage("two"));

                    sb.ToString().Should().Be("one" + Environment.NewLine + "two" + Environment.NewLine);
                }
        }
        public void ReadAfterDispose()
        {
            MessageBus    bus   = new MessageBus();
            List <string> lines = new List <string>();

            bus.Subscribe <InputReceivedMessage>(m => lines.Add(m.Line));
            using (StringReader reader = new StringReader("one" + Environment.NewLine + "two"))
            {
                using (TextConsole console = new TextConsole(bus, reader, TextWriter.Null))
                {
                }

                bus.Send(new InputRequestedMessage());

                lines.Should().BeEmpty();
            }
        }
Example #12
0
        //start serwera
        private void button1_Click(object sender, EventArgs e) //start server
        {
            try {
                if (Regex.IsMatch(IPTextBox.Text, @"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b") && !is_running)
                {
                    server = new TcpListener(IPAddress.Parse(IPTextBox.Text), int.Parse(PortTextBox.Text));
                    server.Start();

                    ReadUserDataFromFile("userdata.txt");


                    TextConsole.AppendText("Server started\n");
                    TextConsole.AppendText("Waiting for client...");

                    client = server.AcceptTcpClient();
                    socket = client.Client;
                    TextConsole.AppendText("Client connected \n");

                    STR           = new StreamReader(client.GetStream());
                    STW           = new StreamWriter(client.GetStream());
                    STW.AutoFlush = true;
                    is_running    = true;

                    STW.WriteLine("220 " + server_name + " " + DateTime.Now.ToString("MM\\/dd\\/yyyy h\\:mm tt"));

                    backgroundWorker1.WorkerSupportsCancellation = true;
                    backgroundWorker1.RunWorkerAsync(); //receiving data
                }
                else
                {
                    if (is_running)
                    {
                        MessageBox.Show("Already started\n");
                    }
                    else
                    {
                        MessageBox.Show("Wrong IP Address");
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Example #13
0
        public async void Start(CancellationToken ct)
        {
            try
            {
                // ***Send a token to carry the message if cancellation is requested.
                TextConsole.Log("Discord Bot starting...");
//                await MainAsync(cts.Token);
                TextConsole.Log("Discord Bot");
            }
            // *** If cancellation is requested, an OperationCanceledException results.
            catch (OperationCanceledException)
            {
                TextConsole.Log("Discord Bot stopped!");
            }
            catch (Exception e)
            {
                TextConsole.Log("Exception: " + e.Message);
            }
        }
        public void ReadTwoLines()
        {
            MessageBus bus = new MessageBus();

            using (StringReader reader = new StringReader("one" + Environment.NewLine + "two"))
                using (TextConsole console = new TextConsole(bus, reader, TextWriter.Null))
                {
                    List <string> lines = new List <string>();
                    bus.Subscribe <InputReceivedMessage>(m => lines.Add(m.Line));

                    bus.Send(new InputRequestedMessage());

                    lines.Should().ContainSingle().Which.Should().Be("one");

                    bus.Send(new InputRequestedMessage());

                    lines.Should().Equal("one", "two");
                }
        }
        public void SW_Choke(Cell C)
        {
            TextConsole  textConsole = Look._TextConsole;
            ScreenBuffer scrapBuffer = TextConsole.ScrapBuffer;

            XRLCore.Core.RenderMapToBuffer(scrapBuffer);
            bool bDraw = C.IsVisible();

            int nBonus = Math.Max(ParentObject.Statistics["Ego"].Modifier, Level);

            if (C != null)
            {
                foreach (GameObject GO in C.GetObjectsInCell())
                {
                    if (GO.HasPart("Brain"))
                    {
                        //if(GO.HasTag("HeroNamePrefixes"))
                        if (GO.HasTag("CanBeChoked"))
                        {
                            ChokedObject = GO;
                            EquipForceGesture();
                            //Apply force choking effect to victim
                            GO.ApplyEffect((Effect) new XRL.World.Parts.Effects.ZD_Choking(Level, GetBaseDamage(Level), GetBonusDamage(Level), ParentObject, GetSaveBonus(Level), GetRange(Level), ForceGestureObject));
                        }
                        else
                        {
                            Popup.Show("The target does not have a throat for you to choke!", true);
                        }
                    }
                }
            }
            scrapBuffer.Goto(C.X, C.Y);
            scrapBuffer.Write("&Y#");
            if (bDraw)
            {
                textConsole.DrawBuffer(scrapBuffer, (IScreenBufferExtra)null, false);
            }
            if (!bDraw)
            {
                return;
            }
            Thread.Sleep(50);
        }
Example #16
0
        public Gerador_Grafos()
        {
            this.InitializeComponent();
            ApplicationView view = ApplicationView.GetForCurrentView();

            //Translate Transform Pop-Ups!
            Add_scene.RenderTransform     = new TranslateTransform();
            Remove_scene.RenderTransform  = new TranslateTransform();
            Utils_scene.RenderTransform   = new TranslateTransform();
            Grafo_manager.RenderTransform = new TranslateTransform();
            //Fullscreen
            view.TryEnterFullScreenMode();

            //Backend com calculos
            myConsole  = new TextConsole(Console_output);
            graphStats = new Stats(Grafo_stats);
            graphStats.Clear();
            log = new LogManager();

            IsNotRendered = false;
            //Desenhos do Satanas
            Drawer = new DrawManager(TelaOutput);
            //Drawer.Draw();
        }
Example #17
0
 private Task Log(LogMessage msg)
 {
     TextConsole.Log(msg.ToString());
     return(Task.CompletedTask);
 }
        public void Hydrofabricate()
        {
            List <Cell> CellList = PickCone(4 + Level, 30 + Level, AllowVis.OnlyVisible);

            CellList = CellList.OrderBy(cell => cell.ManhattanDistanceTo(ParentObject.CurrentCell)).ToList();

            if (!this.ParentObject.pPhysics.CurrentCell.ParentZone.IsWorldMap())
            {
                base.PlayWorldSound("splashcast", 1.5f, 0, true, null);
                XDidY(ParentObject, "materialize", "a torrential flood", "!", "C", null);
                for (int index = 0; index < CellList.Count; index++)
                {
                    Cell C = CellList[index];

                    if (C.ParentZone.IsActive() && C.IsVisible())
                    {
                        TextConsole.LoadScrapBuffers();
                        ScreenBuffer scrapBuffer = TextConsole.ScrapBuffer;
                        XRLCore.Core.RenderMapToBuffer(TextConsole.ScrapBuffer);
                        scrapBuffer.Goto(C.X, C.Y);
                        scrapBuffer.Write(GetRandomBlueFlashes() + "\a");
                        Popup._TextConsole.DrawBuffer(scrapBuffer);
                        Thread.Sleep(10);
                        XRLCore.Core.RenderMapToBuffer(scrapBuffer);
                        scrapBuffer.Goto(C.X, C.Y);
                        scrapBuffer.Write(GetRandomBlueFlashes() + "\u0489");
                        Popup._TextConsole.DrawBuffer(scrapBuffer);
                        Thread.Sleep(10);

                        var Roll = Stat.Random(1, 100);

                        if (Roll <= 50)
                        {
                            if (Roll >= 90)
                            {
                                base.PlayWorldSound("flood1", 1.5f, 0, true, null);
                            }
                            else if (Roll >= 60)
                            {
                                base.PlayWorldSound("flood2", 1.5f, 0, true, null);
                            }
                            else if (Roll >= 30)
                            {
                                base.PlayWorldSound("flood3", 1.5f, 0, true, null);
                            }
                            else
                            {
                            }
                        }

                        if (C.HasObjectWithPart("Combat") || C.HasObjectWithPart("Brain"))
                        {
                            var cObj = C.GetFirstObjectWithPart("Combat");
                            if (cObj != ParentObject)
                            {
                                cObj.Push(ParentObject.CurrentCell.GetDirectionFromCell(cObj.CurrentCell), 1000, 4);
                                cObj.TakeDamage(2 * Level, "Drowned in a torrent of liquid.", null, DeathReason: "from %t torrent-blast.", ThirdPersonDeathReason: null, ParentObject, ParentObject, ParentObject);
                                cObj.GetAngryAt(ParentObject, -50);
                            }
                        }

                        C.Splash("{{B|~}}");
                        C.AddObject("SaltyWaterPuddle");
                    }
                }
            }
        }
Example #19
0
        //odbieranie wiadomosci i rozpoznawanie komend
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            while (client.Connected)
            {
                try
                {
                    if (ready_to_save_file)
                    {
                        this.TextConsole.Invoke(new MethodInvoker(delegate() { TextConsole.AppendText("Saving file" + "\n"); }));
                        SaveAsFile();
                        ready_to_save_file = false;
                    }

                    else
                    {
                        received_message = STR.ReadLine();
                        if (received_message != "")
                        {
                            //this.TextConsole.Invoke(new MethodInvoker( delegate() { TextConsole.AppendText("From Client: "+received_message + "\n"); }));

                            if (received_message.Length > 3 && received_message.Substring(0, 4) == "Size")
                            {
                                _file_size = int.Parse(received_message.Substring(5));
                                this.TextConsole.Invoke(new MethodInvoker(delegate() { TextConsole.AppendText(received_message + "\n"); }));
                                SendTextMessage("250 Size Ok");
                            }


                            if (received_message.Length > 7 && received_message.Substring(0, 8) == "FileName")
                            {
                                this.TextConsole.Invoke(new MethodInvoker(delegate() { TextConsole.AppendText(received_message + "\n"); }));
                                _file_name         = received_message.Substring(9);
                                ready_to_save_file = true;
                                SendTextMessage("250 Ready");
                            }
                            if (read_mail_message)
                            {
                                if (received_message == ".")
                                {
                                    read_mail_message = false;
                                }
                                this.TextConsole.Invoke(new MethodInvoker(delegate() { TextConsole.AppendText(received_message + "\n"); }));
                            }
                            if (received_message == "No files")
                            {
                                this.TextConsole.Invoke(new MethodInvoker(delegate() { TextConsole.AppendText(received_message + "\n"); }));
                            }

                            if (!client_logged && received_message.Substring(0, 4) == "user")
                            {
                                bool user_found = false;
                                foreach (Users user in userDatabase)
                                {
                                    if (user.username == received_message.Substring(5, received_message.Length - 5))
                                    {
                                        SendTextMessage("250 User Ok");
                                        user_found = true;
                                    }
                                }
                                if (!user_found)
                                {
                                    MessageBox.Show("Wrong username");
                                }
                            }

                            if (!client_logged && received_message.Substring(0, 4) == "pass")
                            {
                                bool pass_found = false;
                                foreach (Users user in userDatabase)
                                {
                                    if (user.password == received_message.Substring(5, received_message.Length - 5))
                                    {
                                        SendTextMessage("250 Pass Ok");
                                        pass_found    = true;
                                        client_logged = true;
                                    }
                                }
                                if (!pass_found)
                                {
                                    MessageBox.Show("Wrong password");
                                }
                            }


                            if (received_message.Length > 9 && received_message.Substring(0, 10) == "mail from:")
                            {
                                this.TextConsole.Invoke(new MethodInvoker(delegate() { TextConsole.AppendText(received_message + "\n"); }));
                                SendTextMessage("250 Ok");
                            }

                            if (received_message.Length > 7 && received_message.Substring(0, 8) == "rcpt to:")
                            {
                                this.TextConsole.Invoke(new MethodInvoker(delegate() { TextConsole.AppendText(received_message + "\n"); }));
                                SendTextMessage("250 Accepted");
                            }


                            if (received_message.Length >= 4)
                            {
                                switch (received_message.Substring(0, 4))
                                {
                                case "helo":
                                {
                                    this.TextConsole.Invoke(new MethodInvoker(delegate() { TextConsole.AppendText(received_message + "\n"); }));
                                    STW.WriteLine("250 Hello " + received_message.Substring(5, received_message.Length - 5) + " " + server_name + " here!");
                                    break;
                                }

                                case "data":
                                {
                                    this.TextConsole.Invoke(new MethodInvoker(delegate() { TextConsole.AppendText(received_message + "\n"); }));
                                    SendTextMessage("354 Ok Send data");
                                    read_mail_message = true;
                                    break;
                                }

                                default:
                                {
                                    break;
                                }
                                }
                            }
                            received_message = "";
                        }
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message.ToString());
                }
            }
        }
        public void ActuallyFire(int Charges)
        {
            FocusPsi PsiMutation = ParentObject.GetPart <FocusPsi>();

            // Shows the line picker interface for the player.

            TextConsole  _TextConsole = UI.Look._TextConsole;
            ScreenBuffer Buffer       = TextConsole.ScrapBuffer;

            Core.XRLCore.Core.RenderMapToBuffer(Buffer);

            List <GameObject> hit       = new List <GameObject>(1);
            List <Cell>       usedCells = new List <Cell>(1);
            var line = PickLine(20, AllowVis.Any, null, false, ForMissileFrom: ParentObject);

            Body            body        = ParentObject.GetPart <Body>();
            List <BodyPart> ParentsHead = body.GetPart("Head");

            Cell targetCell = line[line.Count - 1];

            if (!PsiMutation.usePsiCharges(Charges))
            {
                AddPlayerMessage("You do not have enough psi-charges!");
                return;
            }
            foreach (var Head in ParentsHead)
            {
                if (Head.Equipped != null)
                {
                    Physics.ApplyExplosion(currentCell, GetForce(Level, Charges), usedCells, hit, true, true, ParentObject, GetDamage(Level, Charges), 1, false, false, 2);
                    AddPlayerMessage("Your helmet obstructs the energy of the beam--it explodes in your face!");
                    return;
                }
            }
            if (ParentObject.HasEffect("Dazed") || ParentObject.HasEffect("Confused"))
            {
                Physics.ApplyExplosion(currentCell, GetForce(Level, Charges), usedCells, hit, true, true, ParentObject, GetDamage(Level, Charges), 1, false, false, 2);
                AddPlayerMessage("You lack the concentration to hold your focus! The collected energy explodes in your face!");
                return;
            }

            ActivatedAbilities activatedAbilities = ParentObject.GetPart("ActivatedAbilities") as ActivatedAbilities;

            activatedAbilities.GetAbility(CombustionBlastActivatedAbilityID).Cooldown = (Charges - 1) * 100;

            // Loop through each cell of the line in order.

            List <string> SparkySparkyChars = new List <string>()
            {
                "\xf8", "*", "."
            };
            List <Point> Beamline = Zone.Line(line[0].X, line[0].Y, targetCell.X, targetCell.Y);

            base.PlayWorldSound("sparkblast", 0.3f, 0.1f, true, null);

            for (int index = 1; index < line.Count; index++)
            {
                Cell cell        = line[index];
                char DisplayBeam = Beamline[index].DisplayChar;
                Buffer.Goto(cell.X, cell.Y);
                Buffer.Write("&Y^r" + DisplayBeam);

                Cell SparkyBeam = cell.GetRandomLocalAdjacentCell();
                Buffer.Goto(SparkyBeam.X, SparkyBeam.Y);
                Buffer.Write("&W" + SparkySparkyChars.GetRandomElement());
                _TextConsole.DrawBuffer(Buffer);
                System.Threading.Thread.Sleep(18);
                // Find a solid object and combat id on obj in line, to hit in this cell.
                GameObject obj = cell.FindObject(o => o.ConsiderSolidFor(ParentObject, ParentObject) || (o.HasPart("Combat") && !o.pPhysics.Solid));


                if (obj != null)
                {
                    targetCell = cell;
                    break;
                }
            }
            if (Stat.Random(1, 100) <= 50)
            {
                base.PlayWorldSound("bang1", 0.3f, 0, true, null);
            }
            else
            {
                base.PlayWorldSound("bang2", 0.3f, 0, true, null);
            }
            ComExplode(GetForce(Level, Charges), targetCell, ParentObject, GetDamage(Level, Charges));
            ParentObject.UseEnergy(10000);
        }
Example #21
0
        public void SoulShunt()
        {
            Physics      pGOPhysics   = ParentObject.GetPart("Physics") as Physics;
            TextConsole  _TextConsole = UI.Look._TextConsole;
            ScreenBuffer Buffer       = TextConsole.ScrapBuffer;

            Core.XRLCore.Core.RenderMapToBuffer(Buffer);
            Cell TargetCell = PickDirection();

            if (TargetCell == null)
            {
                AddPlayerMessage("Soulshunt requires a target.");
                return;
            }

            var TargetHusk = TargetCell.GetFirstObjectWithPart("Brain");

            var SkillAccess = ParentObject.GetPart <Skills>();
            var SkillList   = SkillAccess.SkillList;

            if (TargetHusk != null)
            {
                var OwnersEgo                 = ParentObject.Statistics["Ego"];
                var OwnersWillpower           = ParentObject.Statistics["Willpower"];
                var OwnersIntelligence        = ParentObject.Statistics["Intelligence"];
                var OwnersMentalMutations     = ParentObject.GetMentalMutations();
                var OwnersMutationAlterations = ParentObject.GetPart <Mutations>();

                var TargetsEgo                 = TargetHusk.Statistics["Ego"];
                var TargetsWillpower           = TargetHusk.Statistics["Willpower"];
                var TargetsIntelligence        = TargetHusk.Statistics["Intelligence"];
                var TargetsMentalMutations     = TargetHusk.GetMentalMutations();
                var TargetsMutationAlterations = TargetHusk.GetPart <Mutations>();

                int OwnersLevel  = ParentObject.Stat("Level");
                int TargetsLevel = TargetHusk.Stat("Level");

                var LevelDifference = TargetsLevel - OwnersLevel;


                if (!TargetHusk.MakeSave("Willpower", 8 + LevelDifference, ParentObject, "Ego", ParentObject.It + " attempted to shunt " + TargetHusk.Its + " mind from " + TargetHusk.Its + " body.", false, false, false, false))
                {
                    if (!TargetHusk.HasPart("NotOriginalEntity"))
                    {
                        TargetHusk.AddPart <NotOriginalEntity>();
                    }
                    if (ParentObject.IsEsper())
                    {
                        if (!TargetHusk.IsEsper())
                        {
                            TargetHusk.SetStringProperty("Genotype", "Esper");
                        }
                    }

                    TargetsEgo.BaseValue          = OwnersEgo.BaseValue;
                    TargetsIntelligence.BaseValue = OwnersIntelligence.BaseValue;
                    TargetsWillpower.BaseValue    = OwnersWillpower.BaseValue;

                    // AddPlayerMessage("removing old mutes");
                    //removes husk original mental mutations
                    foreach (var key1 in TargetsMentalMutations)
                    {
                        TargetsMutationAlterations.RemoveMutation(key1);
                    }
                    // AddPlayerMessage("adding old mutes");
                    //adds parent objects mental mutations to husk
                    foreach (var key2 in OwnersMentalMutations)
                    {
                        TargetsMutationAlterations.AddMutation(key2.GetMutationEntry(), key2.BaseLevel);
                    }

                    if (!TargetsMutationAlterations.HasMutation("PsychoplethoricDeterioration"))
                    {
                        TargetsMutationAlterations.AddMutation("PsychoplethoricDeterioration", 1);
                    }

                    if (!TargetHusk.HasPart("Survival"))
                    {
                        TargetHusk.RequirePart <Survival>();
                        TargetHusk.RequirePart <Survival_Camp>();
                        TargetHusk.RequirePart <Survival_Trailblazer>();
                    }

                    if (ParentObject.IsPlayer())
                    {
                        XRL.The.Game.Player.Body = TargetHusk;
                    }
                    else
                    {
                        XRL.The.Game.Player.Body = ParentObject;
                    }

                    TargetHusk.UseEnergy(1000);
                    ParentObject.UseEnergy(5000);


                    TargetHusk.FireEvent(Event.New("SuccessfulDethroning", "OriginalBody", ParentObject));
                    UbernostrumScaling = 0;
                }
                else
                {
                    TargetHusk.GetAngryAt(ParentObject, -100);
                    AddPlayerMessage(TargetHusk.it + " resisted " + ParentObject.its + " attempt at shunting " + TargetHusk.its + " mind.");
                }
            }
        }
Example #22
0
 private void WriteConsole(string text)
 {
     TextConsole.AppendText("\n" + text);
 }
 public void Init(TextConsole console, ScreenBuffer buffer)
 {
     Console = console;
     Buffer  = buffer;
 }
Example #24
0
        public void CallLightningAnimation()
        {
            TextConsole  _TextConsole = UI.Look._TextConsole;
            ScreenBuffer Buffer       = TextConsole.ScrapBuffer;

            Core.XRLCore.Core.RenderMapToBuffer(Buffer);

            var TargetCell = PickDestinationCell(9, AllowVis.OnlyVisible);
            var zone       = TargetCell.ParentZone;

            var SkyCell = zone.GetCell(TargetCell.X, 0);

            List <Point> SpawningLine  = Zone.Line(9, 0, 16, 0);
            List <Point> Lightningline = Zone.Line(SpawningLine.GetRandomElement().X, SpawningLine.GetRandomElement().Y, TargetCell.X, TargetCell.Y);

            List <string> SparkySparkyChars = new List <string>()
            {
                "\xf8", "*", "."
            };

            for (int index = 0; index < Lightningline.Count; index++)
            {
                Point point = Lightningline[index];
                Cell  cell  = zone.GetCell(point);


                char DisplayBeam;

                if (index % 2 == 0)
                {
                    DisplayBeam = '/';
                }
                else
                {
                    DisplayBeam = '\\';
                }

                Buffer.Goto(cell.X, cell.Y);
                Buffer.Write("&Y^b" + DisplayBeam);

                Cell SparkyBeam = cell.GetRandomLocalAdjacentCell();
                Buffer.Goto(SparkyBeam.X, SparkyBeam.Y);
                Buffer.Write("&Y" + SparkySparkyChars.GetRandomElement());
                _TextConsole.DrawBuffer(Buffer);
                System.Threading.Thread.Sleep(18);
            }



            // foreach (var C in line)
            // {
            //     GameObject Target = C.GetFirstObjectWithPart("Combat");

            //     AddPlayerMessage("Target: " + Target.DisplayName);

            //     Cell TargetCell = Target.CurrentCell;

            //     AddPlayerMessage("Target Cell Found?: " + TargetCell.DebugName);

            //     Zone TargetsZone = Target.CurrentZone;

            //     AddPlayerMessage("Target Zone Found?: " + TargetsZone.DebugName);



            //     AddPlayerMessage("Sky Cell Found?: " + SkyCell.DebugName);


            //     List<string> ElectricChars = new List<string>() { "\xf8", "*", "." };
            //     // List<Point> Lightningline = Zone.Line(line[0].X, line[0].Y, TargetCell.X, SkyCell.Y);

            //     int num = 1;

            //     int dx = Math.Abs(num - num), sx = num < -num ? 1 : -1;
            //     int dy = Math.Abs(num - num), sy = num < -num ? 1 : -1;

            //     XRLCore.ParticleManager.Add(ElectricChars.GetRandomElement(), TargetCell.X, SkyCell.Y, -dx, -dy, 1, 0f, 0f);

            //     AddPlayerMessage("Lightining Code Fired.");

            //     // for (int index = 1; index < line.Count; index++)
            //     // {
            //     //     Cell cell = line[index];
            //     //     char DisplayLightning = Lightningline[index].DisplayChar;
            //     //     Buffer.Goto(cell.X, cell.Y);
            //     //     Buffer.Write("&B^b" + DisplayLightning);

            //     //     Cell LightningStrike = cell.GetRandomLocalAdjacentCell();
            //     //     Buffer.Goto(LightningStrike.X, LightningStrike.Y);
            //     //     Buffer.Write("&W" + ElectricChars.GetRandomElement());
            //     //     _TextConsole.DrawBuffer(Buffer);
            //     //     System.Threading.Thread.Sleep(18);
            //     //     // Find a solid object and combat id on obj in line, to hit in this cell.
            //     //     GameObject obj = cell.FindObject(o => (o.HasPart("Combat")));


            //     //     if (obj != null)
            //     //     {
            //     //         TargetCell = cell;
            //     //         break;
            //     //     }
            //     // }
            //     break;
            // }
        }
        public void CastDarkness()
        {
            try
            {
                int ParentsEgoModifer = ParentObject.Statistics["Ego"].Modifier;

                int         MaximumRadius = Math.Min(1 + (Level / 2), 4);
                List <Cell> Cells         = PickBurst(MaximumRadius, 8 + Level, false, AllowVis.OnlyExplored);

                int Ran1 = Stat.Random(1, 100);

                if (!this.ParentObject.pPhysics.CurrentCell.ParentZone.IsWorldMap())
                {
                    if (Stat.Random(1, 100) < Ran1)
                    {
                        base.PlayWorldSound("darknesscast", 15f, 0, true, null);
                    }
                    else
                    {
                        base.PlayWorldSound("darknesscastdeep", 15f, 0, true, null);
                    }

                    for (int index = 0; index < Cells.Count; index++)
                    {
                        Cell C = Cells[index];

                        if (C.ParentZone.IsActive() && C.IsVisible())
                        {
                            TextConsole.LoadScrapBuffers();
                            ScreenBuffer scrapBuffer = TextConsole.ScrapBuffer;
                            XRLCore.Core.RenderMapToBuffer(TextConsole.ScrapBuffer);
                            scrapBuffer.Goto(C.X, C.Y);
                            scrapBuffer.Write(GetDarknesBlips() + "\a");
                            Popup._TextConsole.DrawBuffer(scrapBuffer);
                            Thread.Sleep(10);
                            XRLCore.Core.RenderMapToBuffer(scrapBuffer);
                            scrapBuffer.Goto(C.X, C.Y);
                            scrapBuffer.Write(GetDarknesBlips() + "\u0489");
                            Popup._TextConsole.DrawBuffer(scrapBuffer);
                            Thread.Sleep(5);

                            var Roll = Stat.Random(1, 100);
                            if (Roll <= 10)
                            {
                                base.PlayWorldSound("darkness", 15f, 0, true, null);
                            }

                            if (C.HasObjectWithPart("Combat") || C.HasObjectWithPart("Brain"))
                            {
                                var cObj = C.GetFirstObjectWithPart("Combat");
                                if (cObj != ParentObject)
                                {
                                    if (cObj.MakeSave(Stat: "Ego", Difficulty: 5 + Level, Attacker: ParentObject, AttackerStat: "Ego"))
                                    {
                                        cObj.ApplyEffect(new Confused(ParentsEgoModifer * 10, Level, (ParentsEgoModifer + Level) / 2));
                                    }
                                }
                            }

                            GameObject gameObject = C.AddObject("MagicalDarkness");

                            MagicalDarkness Darkness = gameObject.GetPart <MagicalDarkness>();

                            // AddPlayerMessage("Status Check: Setting up Objects");

                            int Ran2 = Stat.Random(0, 3);
                            Darkness.Duration = ((Level * (10 + ParentsEgoModifer) / 2) + Ran2);
                        }
                    }
                }
                CooldownMyActivatedAbility(ShadowAreaEffectActivatedAbilityID, 60);
            }
            catch
            {
            }
        }
Example #26
0
 public static void SetToken(string token)
 {
     //TODO: change token is possible only if bot not working
     _token = token;
     TextConsole.Log("Token has been successfully set.");
 }
Example #27
0
 void Start()
 {
     textConsole = this;
 }
        public void ApplyCombustExplosion(Cell C, List <Cell> UsedCells, List <GameObject> Hit, int Force, bool bLocal, bool bShow, GameObject Owner, string BonusDamage, bool?Phase, bool Neutron = false, float DamageModifier = 1f)
        {
            TextConsole  textConsole = Look._TextConsole;
            ScreenBuffer scrapBuffer = TextConsole.ScrapBuffer;

            if (bShow)
            {
                TextConsole.LoadScrapBuffers();
                XRLCore.Core.RenderMapToBuffer(scrapBuffer);
            }
            CleanQueue <Cell>   cleanQueue  = new CleanQueue <Cell>();
            CleanQueue <int>    cleanQueue2 = new CleanQueue <int>();
            CleanQueue <string> cleanQueue3 = new CleanQueue <string>();

            cleanQueue.Enqueue(C);
            cleanQueue2.Enqueue(Force);
            cleanQueue3.Enqueue(".");
            UsedCells.Add(C);
            while (cleanQueue.Count > 0)
            {
                Cell   cell = cleanQueue.Dequeue();
                int    num  = cleanQueue2.Dequeue();
                string text = cleanQueue3.Dequeue();
                for (int i = 0; i < UsedCells.Count; i++)
                {
                    Cell cell2 = UsedCells[i];
                    if (cell2 == null)
                    {
                        return;
                    }
                    if (cell2.ParentZone == XRLCore.Core.Game.ZoneManager.ActiveZone)
                    {
                        scrapBuffer.Goto(cell2.X, cell2.Y);
                        int num2 = Stat.Random(1, 3);
                        if (num2 == 1)
                        {
                            scrapBuffer.Write((Phase != null) ? ((!(Phase == true)) ? "&Y*" : "&K*") : "&M*");
                        }
                        else if (num2 == 2)
                        {
                            scrapBuffer.Write((Phase != null) ? ((!(Phase == true)) ? "&R*" : "&b*") : "&G*");
                        }
                        else
                        {
                            scrapBuffer.Write((Phase != null) ? ((!(Phase == true)) ? "&W*" : "&c*") : "&m*");
                        }
                    }
                }
                if (bShow && C.ParentZone != null && C.ParentZone.IsActive())
                {
                    textConsole.DrawBuffer(scrapBuffer, null, false);
                    if (Force < 100000)
                    {
                        Thread.Sleep(5);
                    }
                }
                List <Cell> list;
                if (bLocal)
                {
                    list = cell.GetLocalAdjacentCells(1, false);
                }
                else
                {
                    list = cell.GetAdjacentCells(true);
                }
                for (int j = 0; j < UsedCells.Count; j++)
                {
                    Cell item = UsedCells[j];
                    if (list.CleanContains(item))
                    {
                        list.Remove(item);
                    }
                }
                int    num3   = 0;
                Damage damage = null;
                Event  @event = null;
                foreach (GameObject gameObject in cell.GetObjectsWithPart("Physics"))
                {
                    if (!Hit.Contains(gameObject))
                    {
                        Hit.Add(gameObject);
                        if (gameObject.PhaseMatches(0))
                        {
                            num3 += gameObject.Weight;
                            if (damage == null || !string.IsNullOrEmpty(BonusDamage))
                            {
                                damage = new Damage((int)(DamageModifier * (float)num / 250f));
                                if (!string.IsNullOrEmpty(BonusDamage))
                                {
                                    damage.Amount += BonusDamage.RollCached();
                                }
                                damage.AddAttribute("Explosion");
                                damage.AddAttribute("Heat");
                                damage.AddAttribute("Fire");
                                damage.AddAttribute("Concussion");
                                if (cell != C)
                                {
                                    damage.AddAttribute("Accidental");
                                }
                            }
                            if (@event == null || !string.IsNullOrEmpty(BonusDamage))
                            {
                                @event = Event.New("TakeDamage", 0, 0, 0);
                                @event.SetParameter("Damage", damage);
                                @event.SetParameter("Owner", Owner);
                                @event.SetParameter("Attacker", Owner);
                                if (Neutron)
                                {
                                    if (gameObject.IsPlayer())
                                    {
                                        gameObject.pPhysics.LastDeathReason = "Crushed under the weight of a thousand suns.";
                                    }
                                    @event.SetParameter("Message", "from being crushed under the weight of a thousand suns.");
                                }
                                else
                                {
                                    @event.SetParameter("Message", "from %t explosion!");
                                }
                            }
                            gameObject.FireEvent(@event);
                        }
                    }
                }
                System.Random random = new System.Random();
                for (int k = 0; k < list.Count; k++)
                {
                    int  index = random.Next(0, list.Count);
                    Cell value = list[k];
                    list[k]     = list[index];
                    list[index] = value;
                }
                Damage damage2 = null;
                Event  event2  = null;
                for (; ;)
                {
IL_44B:
                    int l = 0;
                    while (l < list.Count)
                    {
                        Cell cell3 = list[l];
                        if (!bLocal)
                        {
                            goto IL_4AD;
                        }
                        if (cell3.X != 0)
                        {
                            if (cell3.X != 79)
                            {
                                if (cell3.Y != 0)
                                {
                                    if (cell3.Y != 24)
                                    {
                                        goto IL_4AD;
                                    }
                                }
                            }
                        }
IL_68C:
                        l++;
                        continue;
IL_4AD:
                        foreach (GameObject gameObject2 in cell3.GetObjectsWithPart("Physics"))
                        {
                            if (!Hit.Contains(gameObject2))
                            {
                                Hit.Add(gameObject2);
                                if (gameObject2.PhaseMatches(0))
                                {
                                    if (damage2 == null || !string.IsNullOrEmpty(BonusDamage))
                                    {
                                        damage2 = new Damage(num / 250);
                                        if (!string.IsNullOrEmpty(BonusDamage))
                                        {
                                            damage2.Amount += BonusDamage.RollCached();
                                        }
                                        damage2.AddAttribute("Explosion");
                                        damage2.AddAttribute("Accidental");
                                        damage2.AddAttribute("Heat");
                                        damage2.AddAttribute("Fire");
                                        damage2.AddAttribute("Concussion");
                                    }
                                    if (event2 == null || !string.IsNullOrEmpty(BonusDamage))
                                    {
                                        event2 = Event.New("TakeDamage", 0, 0, 0);
                                        event2.SetParameter("Damage", damage2);
                                        event2.SetParameter("Owner", Owner);
                                        event2.SetParameter("Attacker", Owner);
                                        if (Neutron)
                                        {
                                            if (gameObject2.IsPlayer())
                                            {
                                                gameObject2.pPhysics.LastDeathReason = "Crushed under the weight of a thousand suns.";
                                            }
                                            event2.SetParameter("Message", "from being crushed under the weight of a thousand suns.");
                                        }
                                        else
                                        {
                                            event2.SetParameter("Message", "from %t explosion!");
                                        }
                                    }
                                    gameObject2.FireEvent(event2);
                                }
                            }
                            if (gameObject2.PhaseMatches(0))
                            {
                                int weight = gameObject2.Weight;
                                if (weight > num)
                                {
                                    list.Remove(cell3);
                                    goto IL_44B;
                                }
                                if (weight > 0)
                                {
                                    gameObject2.Move((!(text == ".")) ? text : Directions.GetRandomDirection(), EnergyCost: 1000);
                                }
                            }
                        }
                        if (cell3.IsSolid())
                        {
                            list.Remove(cell3);
                            goto IL_44B;
                        }
                        goto IL_68C;
                    }
                    break;
                }
                if (list.Count > 0)
                {
                    int num4 = (num - num3) / list.Count;
                    if (num4 > 100)
                    {
                        foreach (Cell cell4 in list)
                        {
                            if (cell4 != null && !UsedCells.Contains(cell4))
                            {
                                UsedCells.Add(cell4);
                                cleanQueue.Enqueue(cell4);
                                cleanQueue2.Enqueue(num4);
                                cleanQueue3.Enqueue(cell.GetDirectionFromCell(cell4));
                            }
                        }
                    }
                }
            }
        }
Example #29
0
 internal ConsoleOutStream(TextConsole console) => this.console = console ?? throw new ArgumentNullException(nameof(console));
Example #30
0
        public static int Menu(List <string> list, string header)
        {
            if (list.Contains("Действия с профилем"))
            {
                list.Add("Выход");
            }
            else
            {
                list.Add("Назад");
            }
            var backup = list.ToList();

            ConsoleColor selected     = ConsoleColor.Magenta;
            ConsoleColor selectedHigh = ConsoleColor.DarkMagenta;

            TextConsole.PrintConsole.Header(header);
            int control = 3;

            for (int i = 0; i < list.Count; i++)
            {
                if (i == 0)
                {
                    Console.BackgroundColor = selected;
                }

                list[i] = $"{TextConsole.Tab()}[{i + 1}] - {list.ElementAt(i)}";

                Console.WriteLine(list.ElementAt(i));

                Console.ResetColor();
            }
            Console.SetCursorPosition(0, 0);

            int position     = control;
            int lastPosition = control;

            Console.SetCursorPosition(0, position);
            Console.CursorVisible = false;

            while (true)
            {
                if (position != lastPosition)
                {
                    Console.SetCursorPosition(0, lastPosition);
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.WriteLine(list[lastPosition - control]);
                    Console.SetCursorPosition(0, position);

                    Console.SetCursorPosition(0, position);
                    Console.BackgroundColor = selectedHigh;
                    Console.WriteLine(list[position - control]);
                    Console.SetCursorPosition(0, position);

                    Console.SetCursorPosition(0, position);
                }

                switch (Console.ReadKey().Key)
                {
                case ConsoleKey.UpArrow:
                    lastPosition = position;
                    if (position > control)
                    {
                        position--;
                    }
                    else
                    {
                        position = list.Count - 1 + control;
                    }

                    break;

                case ConsoleKey.DownArrow:
                    lastPosition = position;
                    if (position != list.Count - 1 + control)
                    {
                        position++;
                    }
                    else
                    {
                        position = control;
                    }
                    break;

                case ConsoleKey.Enter:
                    Console.CursorVisible = true;
                    Console.ResetColor();
                    if (backup.ElementAt(position - control).IndexOf($"Назад") == 0 || backup.ElementAt(position - control).IndexOf($"Выход") == 0)
                    {
                        return(-1);
                    }
                    return(position - control + 1);

                case ConsoleKey.D0:
                    Console.CursorVisible = true;
                    Console.ResetColor();
                    return(-1);

                case ConsoleKey.NumPad0:
                    goto case (ConsoleKey.D0);

                case ConsoleKey.Backspace:
                    goto case (ConsoleKey.D0);
                }
            }
        }