Inheritance: MonoBehaviour
示例#1
0
        private void lbupgrades_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbupgrades.SelectedIndex >= 0)
            {
                if (!_started)
                {
                    pnlinfo.Location = new Point(351, 0);
                    pnlintro.Hide();
                    _started = true;
                }


                var item = lbupgrades.GetItemText(lbupgrades.SelectedItem);

                int dash = item.LastIndexOf("-");

                string name = item.Substring(0, dash - 1);

                int cost = int.Parse(item.Substring(dash + 2, (item.Length - 2) - (dash + 2)));

                var upgrade = CurrentSystem.GetUpgrades().FirstOrDefault(x => x.Name == name && x.Cost == cost);

                _currentUpgrade = upgrade;

                UpdateUpgradeInfo();
            }
        }
示例#2
0
    private void Update()
    {
        if (!SceneGlobals.general.InMap || SceneGlobals.in_console)
        {
            return;
        }
        CurrentSystem.Update();

        // Rotates ship at clicked point
        if (Input.GetMouseButtonDown(0) && Input.GetKey(KeyCode.LeftShift))
        {
            Ray        ray = SceneGlobals.map_camera.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            Vector3    dir = ray.direction;
            if (Physics.Raycast(ray, out hit))
            {
                dir = (hit.point - transform.position).normalized;
            }
            else
            {
                if (Vector3.Dot(ray.direction, SceneGlobals.map_camera.transform.forward) < 0)
                {
                    dir *= -1;
                }
            }
            SceneGlobals.Player.low_ai.Point2(dir);
        }
    }
示例#3
0
        private void StarSystemChanged(StarSystem newSystem)
        {
            if (newSystem == null)
            {
                return;
            }

            // Broadcast is sent by a background thread -- cannot set text directly.
            CurrentSystem.Invoke((Action) delegate
            {
                this.Text = newSystem.Name;
            });

            // Check to see if we should announce the next system.
            var shouldReadNextSystem = false;

            ReadDirectionsCheckBox.Invoke((Action) delegate
            {
                shouldReadNextSystem = ReadDirectionsCheckBox.Checked;
            });

            if (shouldReadNextSystem)
            {
                ReadNextSystem(newSystem);
            }
        }
示例#4
0
        private void btndeletefile_Click(object sender, EventArgs e)
        {
            string path = lvfiles.SelectedItems[0].Tag.ToString();

            if (path.StartsWith("/Shiftum42") || path.StartsWith("/SoftwareData"))
            {
                CurrentSystem.ShowInfo("Permission denied.", $"You do not have permission to delete {path}.");
                return;
            }

            var fs = CurrentSystem.GetFilesystem();

            if (fs.DirectoryExists(path))
            {
                CurrentSystem.AskYesNo("Delete folder?", $"Do you erally want to delete {path}?", (answer) =>
                {
                    if (answer)
                    {
                        fs.DeleteDirectory(path, true);
                        UpdateFolderList();
                    }
                });
            }
            else if (fs.FileExists(path))
            {
                CurrentSystem.AskYesNo("Delete file?", $"Do you erally want to delete {path}?", (answer) =>
                {
                    if (answer)
                    {
                        fs.DeleteFile(path);
                        UpdateFolderList();
                    }
                });
            }
        }
示例#5
0
        /// <summary>
        /// Aggregates <see cref="TransitionSystem.PossibleProactiveTransitions"/>.
        /// <para>If <see cref="CurrentSystem"/> is NULL, parse all <see cref="Systems"/>.</para>
        /// <para>If <see cref="CurrentSystem"/> is NOT NULL, only parse that.</para>
        /// </summary>
        public HashSet <Tuple <TransitionSystem, ProactiveTransition> > PossibleProactiveTransitions()
        {
            HashSet <Tuple <TransitionSystem, ProactiveTransition> > result = new HashSet <Tuple <TransitionSystem, ProactiveTransition> >();

            // If current system is set, only query that.
            if (AtomicRefinement && CurrentSystem != null)
            {
                foreach (ProactiveTransition transition in CurrentSystem.PossibleProactiveTransitions())
                {
                    result.Add(new Tuple <TransitionSystem, ProactiveTransition>(CurrentSystem, transition));
                }
            }
            // Otherwise, query all inactive systems.
            else
            {
                foreach (TransitionSystem system in Systems)
                {
                    foreach (ProactiveTransition transition in system.PossibleProactiveTransitions())
                    {
                        result.Add(new Tuple <TransitionSystem, ProactiveTransition>(system, transition));
                    }
                }
            }

            return(result);
        }
示例#6
0
        private void lvfiles_DoubleClick(object sender, EventArgs e)
        {
            if (lvfiles.SelectedItems.Count != 0)
            {
                var itemTag = lvfiles.SelectedItems[0].Tag.ToString();

                if (itemTag == "..")
                {
                    _working = _working.Substring(0, _working.LastIndexOf("/"));
                    if (string.IsNullOrWhiteSpace(_working))
                    {
                        _working = "/";
                    }
                    UpdateFolderList();
                }
                else
                {
                    var fs = CurrentSystem.GetFilesystem();
                    if (fs.DirectoryExists(itemTag))
                    {
                        _working = itemTag;
                        UpdateFolderList();
                    }
                    else if (fs.FileExists(itemTag))
                    {
                        txtfilename.Text = itemTag.Substring(itemTag.LastIndexOf("/") + 1);
                        HandleFileOpen();
                    }
                }
            }
        }
示例#7
0
        protected override void OnDesktopUpdate()
        {
            if (CurrentSystem.HasShiftoriumUpgrade("pmandam"))
            {
                toptext.Text = "The Time is";
                bottomtext.Hide();
            }
            else
            {
                toptext.Text = "Since midnight,";
                bottomtext.Show();

                if (CurrentSystem.HasShiftoriumUpgrade("hourssincemidnight"))
                {
                    bottomtext.Text = "hours have passed.";
                }
                else if (CurrentSystem.HasShiftoriumUpgrade("minutessincemidnight"))
                {
                    bottomtext.Text = "minutes have passed.";
                }
                else
                {
                    bottomtext.Text = "seconds have passed.";
                }
            }

            this.lbmaintime.Text = CurrentSystem.GetTimeOfDay();

            base.OnDesktopUpdate();
        }
示例#8
0
        private void CommandInterpreterTimer_Tick(object sender, EventArgs e)
        {
            if (_latentCallbacks.Count > 0)
            {
                var callback = _latentCallbacks[0];

                string line = "";
                if (ReadLine(ref line))
                {
                    callback.Invoke(line);
                    _latentCallbacks.RemoveAt(0);
                }
                return;
            }

            if (!_interpreting)
            {
                Write($"{CurrentSystem.Username}@{CurrentSystem.OSName} $> ");
                _interpreting = true;
            }

            string command = "";

            if (ReadLine(ref command))
            {
                CurrentSystem.ExecuteCommand(this, command);
                _interpreting = false;
            }
        }
示例#9
0
 private void ResetUpgrades()
 {
     lbupgrades.Items.Clear();
     foreach (var upgrade in CurrentSystem.GetUpgrades().OrderBy(x => x.Name))
     {
         lbupgrades.Items.Add($"{upgrade.Name} - {upgrade.Cost} CP");
     }
 }
示例#10
0
 private void btnsave_Click(object sender, EventArgs e)
 {
     CurrentSystem.AskForFile(new[] { ".txt" }, true, (path) =>
     {
         var fs = CurrentSystem.GetFilesystem();
         fs.WriteAllText(path, txtuserinput.Text);
         return(true);
     });
 }
示例#11
0
 private void btnopen_Click(object sender, EventArgs e)
 {
     CurrentSystem.AskForFile(new[] { ".txt" }, false, (path) =>
     {
         var fs            = CurrentSystem.GetFilesystem();
         txtuserinput.Text = fs.ReadAllText(path);
         return(true);
     });
 }
 public bool IsMainMenu()
 {
     if (CurrentSystem.ToLower().Contains("main menu"))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#13
0
        public async Task <Expedition> GetCurrentExpedition()
        {
            Expedition currentExpedition = await _expeditionRepository.GetCurrent(_user.UserName);

            if (_currentSystem == null)
            {
                _currentSystem            = new CurrentSystem();
                _currentSystem.Expedition = currentExpedition;
            }
            return(currentExpedition);
        }
示例#14
0
        public void Write(string text)
        {
            TerminalControl.SelectionStart = TerminalControl.Text.Length;
            TerminalControl.Text          += text;
            TerminalControl.SelectionStart = TerminalControl.Text.Length;

            if (CurrentSystem.HasShiftoriumUpgrade("autoscrollterminal"))
            {
                TerminalControl.ScrollToCaret();
            }
        }
示例#15
0
 private void btnbuy_Click(object sender, EventArgs e)
 {
     if (_currentUpgrade != null)
     {
         if (_currentUpgrade.CanBuy(CurrentSystem))
         {
             CurrentSystem.Buy(_currentUpgrade);
             ResetUpgrades();
             UpdateUpgradeInfo();
         }
     }
 }
示例#16
0
        protected override void OnDesktopUpdate()
        {
            base.OnDesktopUpdate();

            pnloptions.Visible = CurrentSystem.HasShiftoriumUpgrade("textpadnew") | CurrentSystem.HasShiftoriumUpgrade("textpadopen") || CurrentSystem.HasShiftoriumUpgrade("textpadsave");

            btnnew.Visible  = CurrentSystem.HasShiftoriumUpgrade("textpadnew");
            btnopen.Visible = CurrentSystem.HasShiftoriumUpgrade("textpadopen");
            btnsave.Visible = CurrentSystem.HasShiftoriumUpgrade("textpadsave");

            pnlbreak.Visible = pnloptions.Visible;
        }
示例#17
0
 private void UpdateUpgradeInfo()
 {
     if (_currentUpgrade != null)
     {
         if (CurrentSystem.HasShiftoriumUpgrade(_currentUpgrade.ID))
         {
             lbupgradename.Font  = new Font("teen", 13, FontStyle.Bold);
             lbupgradename.Text  = "Purchased " + _currentUpgrade.Name;
             lbudescription.Text = _currentUpgrade.Tutorial;
             lbprice.Font        = new Font("teen", 16, FontStyle.Bold);
             lbprice.Text        = $"Bought for {_currentUpgrade.Cost} CP";
             picpreview.Image    = CurrentSystem.FindBitmapResource("upgrade" + _currentUpgrade.ID);
             if (picpreview.Image == null)
             {
                 picpreview.Image = CurrentSystem.FindBitmapResource(_currentUpgrade.ImageResource);
             }
             btnbuy.Hide();
         }
         else
         {
             lbupgradename.Font  = new Font("teen", 20, FontStyle.Bold);
             lbupgradename.Text  = _currentUpgrade.Name;
             lbudescription.Text = _currentUpgrade.Description;
             if (_currentUpgrade.CanBuy(CurrentSystem))
             {
                 btnbuy.Text = "Buy";
             }
             else
             {
                 btnbuy.Text = "Can't afford.";
             }
             lbprice.Font     = new Font("teen", 26, FontStyle.Bold);
             lbprice.Text     = _currentUpgrade.Cost.ToString() + " CP";
             picpreview.Image = CurrentSystem.FindBitmapResource("upgrade" + _currentUpgrade.ID);
             if (picpreview.Image == null)
             {
                 picpreview.Image = CurrentSystem.FindBitmapResource(_currentUpgrade.ImageResource);
             }
             btnbuy.Show();
         }
     }
 }
示例#18
0
        protected override void OnDesktopUpdate()
        {
            // Hide the window border until the "Windowed Terminal" upgrade is purchased.
            this.ShowShiftOSBorders = CurrentSystem.HasShiftoriumUpgrade("windowedterminal");

            // Make ourselves maximized if the borders are hidden.
            this.WindowState = ShowShiftOSBorders ? FormWindowState.Normal : FormWindowState.Maximized;

            // Terminal scrollbar upgrade.
            if (CurrentSystem.HasShiftoriumUpgrade("terminalscrollbar"))
            {
                TerminalControl.ScrollBars = ScrollBars.Vertical;
            }
            else
            {
                TerminalControl.ScrollBars = ScrollBars.None;
            }

            base.OnDesktopUpdate();
        }
示例#19
0
        private void btnnewfolder_Click(object sender, EventArgs e)
        {
            string work = this._working;

            CurrentSystem.AskForText("New Folder", "Please enter a name for your new folder.", (name) =>
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    CurrentSystem.ShowInfo("New Folder", "The folder name cannot be blank.");
                    return(false);
                }

                if (name.Any(x => Path.GetInvalidFileNameChars().Contains(x)))
                {
                    CurrentSystem.ShowInfo("New Folder", "The folder name contains some invalid characters.");
                    return(false);
                }

                string path = "";
                if (work.EndsWith("/"))
                {
                    path = work + name;
                }
                else
                {
                    path = work + "/" + name;
                }

                var fs = CurrentSystem.GetFilesystem();

                if (fs.DirectoryExists(path))
                {
                    CurrentSystem.ShowInfo("New Folder", "A folder with that name already exists.");
                    return(false);
                }

                fs.CreateDirectory(path);
                UpdateFolderList();
                return(true);
            });
        }
示例#20
0
        protected override void OnDesktopUpdate()
        {
            // Update the working directory.
            lbllocation.Text = _working;

            pnloptions.Visible = CurrentSystem.HasShiftoriumUpgrade("fsnewfolder") || CurrentSystem.HasShiftoriumUpgrade("fsdelete") && Mode == FileSkimmerMode.Skim;

            btnnewfolder.Visible  = CurrentSystem.HasShiftoriumUpgrade("fsnewfolder");
            btndeletefile.Visible = CurrentSystem.HasShiftoriumUpgrade("fsdelete") && lvfiles.SelectedItems.Count > 0 && lvfiles.SelectedItems[0].Tag.ToString() != "..";

            pnlopenoptions.Visible = Mode == FileSkimmerMode.Open || Mode == FileSkimmerMode.Save;

            pnlbreak.Visible = pnlopenoptions.Visible || pnloptions.Visible;

            switch (Mode)
            {
            case FileSkimmerMode.Open:
                txtfilename.Hide();
                lblfilenameprompt.Hide();
                lblcurrentlydisplayingprompt.Show();
                btnopen.Text = "Open";
                break;

            case FileSkimmerMode.Save:
                txtfilename.Show();
                lblfilenameprompt.Show();
                lblcurrentlydisplayingprompt.Hide();
                btnopen.Text = "Save";
                break;
            }

            if (pnlopenoptions.Visible)
            {
                if (cmbformatchooser.Items.Count == 1)
                {
                    cmbformatchooser.Hide();
                }
                else
                {
                    cmbformatchooser.Show();
                }
                lbextention.Text = cmbformatchooser.SelectedItem.ToString();
            }

            if (btndeletefile.Visible)
            {
                var item = lvfiles.SelectedItems[0];
                if (item.ImageKey == "folder")
                {
                    btndeletefile.Text  = "Delete Folder";
                    btndeletefile.Image = Properties.Resources.deletefolder;
                }
                else
                {
                    btndeletefile.Text  = "Delete File";
                    btndeletefile.Image = Properties.Resources.deletefile;
                }
            }

            base.OnDesktopUpdate();
        }
示例#21
0
 public override int GetHashCode()
 {
     return(CurrentSystem.GetHashCode());
 }
示例#22
0
        private void HandleFileOpen()
        {
            var fs = CurrentSystem.GetFilesystem();

            switch (Mode)
            {
            case FileSkimmerMode.Open:
                if (lvfiles.SelectedItems.Count == 0)
                {
                    CurrentSystem.ShowInfo("Open File", "No file has been selected.");
                    return;
                }
                string path = lvfiles.SelectedItems[0].Tag.ToString();
                if (fs.FileExists(path))
                {
                    if (FileOpenCallback?.Invoke(path) == true)
                    {
                        Close();
                        return;
                    }
                }
                else
                {
                    CurrentSystem.ShowInfo("Open File", "File not found.");
                    return;
                }
                break;

            case FileSkimmerMode.Save:
                string work = _working;
                string name = txtfilename.Text;

                if (string.IsNullOrWhiteSpace(name))
                {
                    CurrentSystem.ShowInfo("Save File", "Please enter a file name.");
                    return;
                }

                if (!name.ToLower().EndsWith(lbextention.Text))
                {
                    name += lbextention.Text;
                }

                if (name.Any(x => Path.GetInvalidFileNameChars().Contains(x)))
                {
                    CurrentSystem.ShowInfo("Save File", "The file name you entered contains some invalid characters.");
                    return;
                }

                string savePath = "";
                if (work.EndsWith("/"))
                {
                    savePath = work + name;
                }
                else
                {
                    savePath = work + "/" + name;
                }

                if (savePath.StartsWith("/Shiftum42") || savePath.StartsWith("/SoftwareData"))
                {
                    CurrentSystem.ShowInfo("Permission denied.", "You do not have permission to save here.");
                    return;
                }

                if (fs.FileExists(savePath))
                {
                    CurrentSystem.AskYesNo("Save File - Overwrite?", "A file with that name already exists. Do you want to overwrite it?", (answer) =>
                    {
                        if (FileOpenCallback?.Invoke(savePath) == true)
                        {
                            Close();
                            return;
                        }
                    });
                    return;
                }
                else
                {
                    if (FileOpenCallback?.Invoke(savePath) == true)
                    {
                        Close();
                        return;
                    }
                }
                break;
            }
        }
示例#23
0
        private void UpdateFolderList()
        {
            // Clear the last file list.
            lvfiles.Items.Clear();

            // Add an 'up one level' button if we're not the root path.
            if (_working != "/")
            {
                var up = new ListViewItem();
                up.Text     = "Up one";
                up.Tag      = "..";
                up.ImageKey = "folderup";
                lvfiles.Items.Add(up);
            }

            // Get the filesystem context.
            var fs = CurrentSystem.GetFilesystem();

            // Loop through all folders.
            foreach (var folder in fs.GetDirectories(_working))
            {
                var folderItem = new ListViewItem();
                folderItem.Tag = folder;

                int lastslash = folder.LastIndexOf("/");

                string name = folder.Substring(lastslash + 1);

                folderItem.Text     = name;
                folderItem.ImageKey = "folder";
                lvfiles.Items.Add(folderItem);
            }

            // Now onto files.
            foreach (var file in fs.GetFiles(_working))
            {
                if (Mode != FileSkimmerMode.Skim)
                {
                    if (!file.ToLower().EndsWith(lbextention.Text))
                    {
                        continue;
                    }
                }

                var fileItem = new ListViewItem();

                fileItem.Tag = file;
                int lastslash = file.LastIndexOf("/");

                string name = file.Substring(lastslash + 1);

                fileItem.Text = name;

                if (name.Contains("."))
                {
                    string extension = name.Substring(name.LastIndexOf(".") + 1);
                    fileItem.ImageKey = GetIcon(extension);
                }
                else
                {
                    fileItem.ImageKey = "unknown.png";
                }

                lvfiles.Items.Add(fileItem);
            }
        }
示例#24
0
        /*01、02*/
        //public override string System()
        //{
        //    return "IOS";
        //}
        //public override void Call()
        //{
        //    Console.WriteLine("使用{0}打电话", this.GetType());
        //}

        //public override void Message()
        //{
        //    Console.WriteLine("使用{0}发短信", this.GetType());
        //}

        /*03*/
        public override void Call()
        {
            Console.WriteLine("使用{0} {1}打电话", this.GetType(), CurrentSystem.System());
        }
示例#25
0
 private void SetSystemData(ComboBox comboBox, List <SystemIm> systems, CurrentSystem currentSystem)
 {
     comboBox.ItemsSource   = systems.Select(im => im.Name);
     comboBox.SelectedIndex = comboBox.Items.IndexOf(currentSystem.Name);
 }
示例#26
0
 public override void Message()
 {
     Console.WriteLine("使用{0} {1}发短信", this.GetType(), CurrentSystem.System());
 }