Esempio n. 1
0
    public void buildOutpost(Tile t, TileMaker tm)
    {
        if (t.hasBuilding)
        {
            guiManager.displayTooltip("This block already has a building.");
        }
        else
        {
            t.hasBuilding = true;
            t.hasOutpost  = true;
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    Tile s = tm.findTileAtLocation(t.x + i, t.z + j);
                    if (s != null)
                    {
                        s.isWatched = true;
                    }
                }
            }
            addExpense(prices.outpost);

            GameObject outpostObject = Instantiate(outpostPrefab);
            outpostObject.transform.parent   = upgrades_folder.transform;
            outpostObject.transform.position = new Vector3(t.x, 0, t.z);
        }
    }
Esempio n. 2
0
 public void moveCriminals(TileMaker TM)
 {
     //TileMaker TM = this.GetComponent<TileMaker>();
     foreach (Criminal c in criminals)
     {
         if (c.canMove)
         {
             Tile t      = TM.findTileAtLocation(c.x, c.z);
             int  offset = Random.Range(0, 4);
             for (int i = 0; i < 4; i++)
             {
                 int mod = (offset + i) % 4;
                 if (t.openings[mod] && t.neighbours[mod] != null)
                 {
                     Tile n = t.neighbours[mod];
                     if (n.type != "blank" && !n.hasCriminal && !n.hasRoadBlock)
                     {
                         c.setLocation(n.x, n.z);
                         n.setCriminal(c);
                         t.setCriminal(null);
                         break;
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
        public void CreateManifestTest()
        {
            var maker = new TileMaker(PATH);

            maker.SetSquareLogo("../../TestFiles/Miku.png");
            maker.MakeTile();
            Assert.IsTrue(File.Exists("../../TestFiles/HelloTileMaker.VisualElementsManifest.xml"));
        }
Esempio n. 4
0
        public void CreateShortcutTest()
        {
            var maker = new TileMaker(PATH);

            maker.SetSquareLogo("../../TestFiles/Miku.png");
            maker.MakeTile();
            Assert.IsTrue(File.Exists(@"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\HelloTileMaker.lnk"));
        }
Esempio n. 5
0
 /// Awake is called when the script instance is being loaded.
 // use to grab all the refs
 void Awake()
 {
     tileMaker       = this.GetComponent <TileMaker>();
     guiManager      = this.GetComponent <GUIManager>();
     criminalManager = this.GetComponent <CriminalManager>();
     upgradeManager  = this.GetComponent <UpgradeManager>();
     statsManager    = this.GetComponent <StatsManager>();
 }
        public OpenGraphTileMakerTests(ITestOutputHelper testConsole)
            : base(testConsole)
        {
            var options = Options.Create(new DiscCacheOptions(@"C:\WINDOWS\Temp\", CacheState.Disabled));

            _webLoader = new HttpLoader(new DiscCache(options));
            _tileMaker = new TileMaker();
        }
Esempio n. 7
0
        public void CreateAssetsTest()
        {
            var maker = new TileMaker(PATH);

            maker.SetSquareLogo("../../TestFiles/Miku.png");
            maker.MakeTile();
            Assert.IsTrue(Directory.Exists("../../TestFiles/Win10TileMaker_Assets"));
            Assert.IsTrue(File.Exists("../../TestFiles/Win10TileMaker_Assets/150x150Logo.png"));
            Assert.IsTrue(File.Exists("../../TestFiles/Win10TileMaker_Assets/70x70Logo.png"));
        }
Esempio n. 8
0
        public void RemoveCustomizationTest()
        {
            var maker = new TileMaker(PATH);

            maker.SetSquareLogo("../../TestFiles/Miku.png");
            maker.MakeTile();
            maker.RemoveCustomization();
            Assert.IsTrue(!File.Exists("../../TestFiles/HelloTileMaker.VisualElementsManifest.xml-wtm"));
            Assert.IsTrue(!File.Exists("../../TestFiles/Win10TileMaker_Assets"));
        }
Esempio n. 9
0
        public void CreateBackupTest()
        {
            var maker = new TileMaker(PATH);

            maker.SetSquareLogo("../../TestFiles/Miku.png");
            maker.MakeTile();
            Directory.Delete("../../TestFiles/Win10TileMaker_Assets", true);
            maker.MakeTile();
            Assert.IsTrue(File.Exists("../../TestFiles/HelloTileMaker.VisualElementsManifest.xml-wtm"));
        }
 public Egcb_LookTiler(GameObject target)
 {
     this.LookTarget       = target;
     this.LookTargetName   = ConsoleLib.Console.ColorUtility.StripFormatting(target.DisplayName);
     this.LookTargetInfo   = new TileMaker(target);
     this.bLookTargetValid = this.LookTarget != null &&
                             this.LookTarget.IsValid() &&
                             this.LookTargetInfo.IsValid() &&
                             !string.IsNullOrEmpty(this.LookTargetName);
     this.LastTileCoordsList = new List <Coords>();
 }
Esempio n. 11
0
 public Egcb_ConversationTiler(GameObject target)
 {
     this.ConversationTarget       = target;
     this.ConversationTargetName   = ConsoleLib.Console.ColorUtility.StripFormatting(target.DisplayName);
     this.ConversationTargetInfo   = new TileMaker(target);
     this.bConversationTargetValid = this.ConversationTarget != null &&
                                     this.ConversationTarget.IsValid() &&
                                     this.ConversationTargetInfo.IsValid() &&
                                     !string.IsNullOrEmpty(this.ConversationTargetName) &&
                                     this.ConversationTargetName.Length <= 74; //no room to render tile if name is greater than 74 characters (it'll overflow off the side of the screen)
 }
Esempio n. 12
0
    public void buildRoadBlock(Tile t, TileMaker tm)
    {
        if (t.hasBuilding)
        {
            guiManager.displayTooltip("This block already has a building.");
        }
        else
        {
            t.hasBuilding  = true;
            t.hasRoadBlock = true;
            addExpense(prices.roadblock);

            GameObject roadblockObject = Instantiate(roadblockPrefab);
            roadblockObject.transform.parent   = upgrades_folder.transform;
            roadblockObject.transform.position = new Vector3(t.x, 0, t.z);
        }
    }
Esempio n. 13
0
        private void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            string info = "";

            if (Image150x150Logo.Source == null && Image70x70Logo.Source == null)
            {
                info += "At least one image should be selected\n";
            }
            if (AppPathBox.Text == "")
            {
                info += "A desktop app file should be attached\n";
            }
            if (info != "")
            {
                MessageBox.Show(info, "Attention", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            try
            {
                var maker = new TileMaker(AppPathBox.Text, ShortcutPathBox.Text);
                if (Image150x150Logo.Source != null && Image70x70Logo.Source != null)
                {
                    maker.SetSquare150x150Logo(Image150x150Logo.Tag.ToString());
                    maker.SetSquare70x70Logo(Image70x70Logo.Tag.ToString());
                }
                else if (Image150x150Logo.Source != null)
                {
                    maker.SetSquareLogo(Image150x150Logo.Tag.ToString());
                }
                else
                {
                    maker.SetSquareLogo(Image70x70Logo.Tag.ToString());
                }
                maker.SetShowNameOnSquare150x150Logo((bool)ShowNameCheckBox.IsChecked);
                maker.SetForegroundColor(ForegroundColorComboBox.SelectedIndex == 0 ? true : false);
                maker.MakeTile();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            MessageBox.Show("Your Tile has been customized successfully", "Excellent", MessageBoxButton.OK, MessageBoxImage.Information);
        }
        /// <summary>
        /// This function is called from our Harmony patch code after the Conversation UI title is drawn.
        /// It inserts the speaker's tile into the title and disables any Unity prefabs currently being
        /// animated under that tile.
        /// </summary>
        /// <remarks>
        /// We could probably cache the speakerTileInfo instead of recreating it every time the screen is
        /// redrawn, but this works fine as-is and there's no noticeable performance issues.
        /// </remarks>
        public static void DrawConversationSpeakerTile(ScreenBuffer screenBuffer, GameObject speaker)
        {
            if (!Options.UI.AddConversationTiles)
            {
                return;
            }
            GameObject player = XRLCore.Core?.Game?.Player?.Body;

            if (player == null)
            {
                return;          //theoretically should never happen
            }
            screenBuffer.X -= 1; //backspace to where the ']' was drawn
            TileMaker speakerTileInfo = new TileMaker(speaker);

            speakerTileInfo.WriteTileToBuffer(screenBuffer);
            screenBuffer.Write("{{y| ]}}");
        }
Esempio n. 15
0
        private void RecoverButton_Click(object sender, RoutedEventArgs e)
        {
            string appPath = AppPathBox.Text, shortcutPath = ShortcutPathBox.Text;

            if (appPath == "" || shortcutPath == "")
            {
                MessageBox.Show("To remove the customization, the desktop app's path and its shortcut's path should be provided",
                                "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            try
            {
                var maker = new TileMaker(appPath, shortcutPath);
                maker.RemoveCustomization();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            MessageBox.Show("The original Tile has been recovered", "Calm down", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Esempio n. 16
0
        public ScreenReturn Show(GameObject GO)
        {
            GameManager.Instance.PushGameView("QudUX:Inventory");
            QudUX_InventoryScreenState SavedInventoryState = GO.RequirePart <QudUX_InventoryScreenState>();

            InventoryScreenExtender.TabController TabController = new InventoryScreenExtender.TabController(GO);
            Inventory pInventory = GO.GetPart("Inventory") as Inventory;
            Body      pBody      = GO.GetPart("Body") as Body;

            ResetNameCache(GO);
            FilterString = "";
            Keys keys  = 0;
            bool bDone = false;

            StartObject      = 0;
            nSelected        = 0;
            currentMaxWeight = Rules.Stats.GetMaxWeight(GO);
            bool AltDisplayMode            = false;
            Dictionary <char, int> ItemMap = new Dictionary <char, int>();
            bool bShowInventoryTiles       = QudUX.Concepts.Options.UI.ViewInventoryTiles;
            List <GameObject> disabledObjectsWithImposters = null;
            GameObject        fakeTraderForPriceEval       = GameObject.create("DromadTrader1");

            if (bShowInventoryTiles)
            {
                //temporarily disable unity prefab animations in the zone from coordinates 9,3 to 9,22 - this
                //is the area where we'll render tiles and where those animations would potentially animate
                //through the inventory screen.
                disabledObjectsWithImposters = ImposterUtilities.DisableImposters(GO.CurrentZone, 9, 3, 9, 22);
            }

            while (!bDone)
            {
redraw:
                Event.ResetPool(resetMinEventPools: false);
                RebuildLists(GO, TabController);

redrawnorebuild:

                Buffer.Clear();
                Buffer.SingleBox(0, 0, 79, 24, ColorUtility.MakeColor(TextColor.Grey, TextColor.Black));
                Buffer.SingleBox(0, 0, 79, 2, ColorUtility.MakeColor(TextColor.Grey, TextColor.Black));
                //Connect box intersections
                Buffer.Goto(0, 2);
                Buffer.Write(195);
                Buffer.Goto(79, 2);
                Buffer.Write(180);

                Buffer.Goto(35, 0);
                Buffer.Write("[ {{W|Inventory}} ]");

                Buffer.Goto(60, 0);
                Buffer.Write(" {{W|ESC}} or {{W|5}} to exit ");

                Buffer.Goto(50, 24);
                Buffer.Write("< {{W|7}} Character | Equipment {{W|9}} >");

                StringBuilder WeightString = Event.NewStringBuilder();
                WeightString
                .Append("Total weight: {{Y|")
                .Append(pInventory.GetWeight() + pBody.GetWeight())
                .Append(" {{y|/}}  ")
                .Append(Rules.Stats.GetMaxWeight(pInventory.ParentObject))
                .Append(" lbs.}}")
                ;
                Buffer.Goto(79 - ColorUtility.LengthExceptFormatting(WeightString), 23);
                Buffer.Write(WeightString.ToString());

                ItemMap.Clear();

                int nObject = 0;

                QudUX_InventoryCategory CurrentCategory = null;
                GameObject CurrentObject = null;

                int yStart = 3;
                int xStart = 1;
                foreach (char keychar in CategorySelectionList.Keys)
                {
                    if (CategorySelectionList[keychar].Category != null) //category header
                    {
                        Buffer.Goto(xStart, yStart + nObject);
                        string nStart = "";

                        if (nObject == nSelected)
                        {
                            nStart          = "{{Y|>}}";
                            CurrentCategory = CategorySelectionList[keychar].Category;
                        }
                        else
                        {
                            nStart = " ";
                        }

                        StringBuilder sWeight = Event.NewStringBuilder();
                        StringBuilder sCount  = Event.NewStringBuilder();
                        char          color   = (nObject == nSelected) ? 'Y' : 'K';
                        sCount
                        .Append("{{")
                        .Append(color)
                        .Append('|')
                        ;
                        if (Options.ShowNumberOfItems)
                        {
                            sCount
                            .Append(", ")
                            .Append(CategorySelectionList[keychar].Category.Items)
                            .Append(CategorySelectionList[keychar].Category.Items == 1 ? " item" : " items")
                            ;
                        }
                        sCount.Append("}}");

                        sWeight
                        .Append(" {{")
                        .Append(nObject == nSelected ? 'Y' : 'y')
                        .Append("|[")
                        .Append(CategorySelectionList[keychar].Category.Weight)
                        .Append("#]}}")
                        ;

                        string expansionSymbol = CategorySelectionList[keychar].Category.Expanded ? "[-] " : "[+] ";

                        if (nObject == nSelected)
                        {
                            StringBuilder SB = Event.NewStringBuilder();
                            SB
                            .Append(nStart)
                            .Append(expansionSymbol)
                            .Append(keychar)
                            .Append(") {{K|[{{Y|")
                            .Append(CategorySelectionList[keychar].Category.Name)
                            .Append(sCount)
                            .Append("}}]}}")
                            ;
                            Buffer.Write(SB.ToString());
                        }
                        else
                        {
                            StringBuilder SB = Event.NewStringBuilder();
                            SB
                            .Append(nStart)
                            .Append(expansionSymbol)
                            .Append(keychar)
                            .Append(") {{K|[")
                            .Append(CategorySelectionList[keychar].Category.Name)
                            .Append(sCount)
                            .Append("]}}")
                            ;
                            Buffer.Write(SB.ToString());
                        }

                        Buffer.Goto(79 - ColorUtility.LengthExceptFormatting(sWeight), yStart + nObject);
                        Buffer.Write(sWeight);

                        ItemMap.Add(keychar, nObject);
                        nObject++;
                    }
                    else //item (not category header)
                    {
                        string nStart;
                        if (nObject == nSelected)
                        {
                            nStart        = "{{Y|>}}    ";
                            CurrentObject = CategorySelectionList[keychar].Object;
                        }
                        else
                        {
                            nStart = "     ";
                        }

                        Buffer.Goto(xStart, yStart + nObject);
                        StringBuilder SB = Event.NewStringBuilder();
                        SB
                        .Append(nStart)
                        .Append(keychar)
                        .Append(") ")
                        ;
                        Buffer.Write(SB.ToString());

                        if (bShowInventoryTiles)
                        {
                            TileMaker objectTileInfo = new TileMaker(CategorySelectionList[keychar].Object);
                            objectTileInfo.WriteTileToBuffer(Buffer);
                            Buffer.X += 1;
                        }
                        Buffer.Write(CategorySelectionList[keychar].Object.DisplayName);

                        bool          shouldHighlight = (nObject == nSelected);
                        StringBuilder detailString    = Event.NewStringBuilder();
                        if (AltDisplayMode == false || QudUX.Concepts.Options.UI.ViewItemValues == false)
                        {
                            Physics pPhysics = CategorySelectionList[keychar].Object.pPhysics;
                            if (pPhysics != null)
                            {
                                int nWeight = pPhysics.Weight;
                                detailString.Append(" {{")
                                .Append(shouldHighlight ? 'Y' : 'K')
                                .Append("|")
                                .Append(nWeight)
                                .Append("#}}");
                            }
                        }
                        else
                        {
                            string valuePerPound = InventoryScreenExtender.GetItemValueString(CategorySelectionList[keychar].Object, fakeTraderForPriceEval, shouldHighlight);
                            detailString.Append(valuePerPound);
                        }
                        detailString.Append((char)179); //right box border segment in case item name overflowed the screen
                        Buffer.Goto(80 - ColorUtility.LengthExceptFormatting(detailString), yStart + nObject);
                        Buffer.Write(detailString);

                        ItemMap.Add(keychar, nObject);
                        nObject++;
                    }
                }

                if (nObject == 0 && StartObject != 0)
                {
                    StartObject = 0;
                    goto redraw;
                }

                if (nSelected >= nObject)
                {
                    nSelected = nObject - 1;
                    goto redraw;
                }

                if (FilterString != "")
                {
                    Buffer.Goto(3, 23);
                    Buffer.Write("{{y|" + ItemsSkippedByFilter + " items hidden by filter}}");
                    Buffer.Goto(1, 1);
                    Buffer.Write("{{y|Filtering on \"" + FilterString + "\" }}");
                    Buffer.Goto(58, 1);
                    Buffer.Write("{{y| {{W|DEL}} to remove filter}}");

                    if (CategorySelectionList.Count == 0)
                    {
                        Buffer.Goto(4, 5);
                        Buffer.Write("{{y|There are no matching items in your inventory.}}");
                    }
                }
                else
                {
                    Buffer.Goto(1, 1);
                    Buffer.Write(TabController.GetTabUIString());

                    if (CategorySelectionList.Count == 0)
                    {
                        if (TabController.CurrentTab != "Main" && TabController.CurrentTab != "Other")
                        {
                            Buffer.Goto(4, 5);
                            Buffer.Write("{{y|You are not carrying any " + TabController.CurrentTab.ToLower() + ".}}");
                        }
                    }

                    if (TabController.CurrentTab == "Main")
                    {
                        Buffer.Goto(2, 24);
                        Buffer.Write("{{y|{{W|Ctrl}}+{{W|M}} move category to Other}}");
                    }
                    else if (TabController.CurrentTab == "Other")
                    {
                        if (TabController.GetCategoriesForTab("Other").Count > 0)
                        {
                            Buffer.Goto(2, 24);
                            Buffer.Write("{{y|{{W|Ctrl}}+{{W|M}} move category to Main}}");
                        }
                        else
                        {
                            Buffer.Goto(4, 5);
                            Buffer.Write("{{y|There are no item categories here.}}");
                            Buffer.Goto(4, 7);
                            Buffer.Write("{{y|Select a category on the {{Y|Main}} tab and press {{W|Ctrl}}+{{W|M}} to move it here.}}");
                        }
                    }
                }

                Buffer.Goto(34, 24);
                Buffer.Write("{{y|[{{W|?}} view keys]}}");

                TextConsole.DrawBuffer(Buffer, ImposterManager.getImposterUpdateFrame()); //need to update imposters because we've toggled their visibility
                if (!XRL.Core.XRLCore.Core.Game.Running)
                {
                    if (bShowInventoryTiles)
                    {
                        ImposterUtilities.RestoreImposters(disabledObjectsWithImposters);
                    }
                    fakeTraderForPriceEval.Obliterate();
                    GameManager.Instance.PopGameView();
                    return(ScreenReturn.Exit);
                }
                IEvent SentEvent = null;

                keys = ConsoleLib.Console.Keyboard.getvk(Options.MapDirectionsToKeypad, true);
                string ts = "";
                char   ch = (ts + (char)Keyboard.Char + " ").ToLower()[0];
                if (keys == Keys.Enter)
                {
                    keys = Keys.Space;
                }

                if (keys == Keys.MouseEvent && Keyboard.CurrentMouseEvent.Event == "RightClick")
                {
                    bDone = true;
                }
                if (keys == Keys.OemQuestion || ch == '?')
                {
                    InventoryScreenExtender.HelpText.Show();
                }
                else
                if ((int)keys == 131137)  // ctrl+a
                {
                    if (CurrentObject != null)
                    {
                        InventoryActionEvent.Check(out SentEvent, CurrentObject, GO, CurrentObject, "Eat");
                        ResetNameCache(GO);
                        ClearLists();
                    }
                }
                else
                if ((int)keys == 131140) // ctrl+d
                {
                    if (CurrentObject != null)
                    {
                        Event E = Event.New("CommandDropObject", "Object", CurrentObject);
                        SentEvent = E;
                        GO.FireEvent(E);
                        ResetNameCache(GO);
                        ClearLists();
                    }
                }
                else
                if ((int)keys == 131142 || ch == ',') // ctrl+f
                {
                    FilterString = Popup.AskString("Enter text to filter inventory by item name.", FilterString, 80, 0);
                    ClearLists();
                }
                else
                if (keys == Keys.Delete)
                {
                    FilterString = "";
                    ClearLists();
                }
                else
                if ((int)keys == 131154) // ctrl+r
                {
                    if (CurrentObject != null)
                    {
                        InventoryActionEvent.Check(out SentEvent, CurrentObject, GO, CurrentObject, "Drink");
                        ResetNameCache(GO);
                    }
                }
                else
                if ((int)keys == 131152) // ctrl+p
                {
                    if (CurrentObject != null)
                    {
                        InventoryActionEvent.Check(out SentEvent, CurrentObject, GO, CurrentObject, "Apply");
                        ResetNameCache(GO);
                        ClearLists();
                    }
                }
                else
                if (keys == Keys.NumPad7 || (keys == Keys.NumPad9 && Keyboard.RawCode != Keys.PageUp && Keyboard.RawCode != Keys.Next))
                {
                    bDone = true;
                }
                else
                if (keys == Keys.Escape || keys == Keys.NumPad5)
                {
                    bDone = true;
                }
                else
                if (keys == Keys.NumPad8)
                {
                    if (nSelected > 0)
                    {
                        nSelected--;
                        goto redrawnorebuild;
                    }
                    else
                    {
                        if (StartObject > 0)
                        {
                            StartObject--;
                        }
                    }
                }
                else
                if (keys == Keys.NumPad2)
                {
                    if (nSelected < nObject - 1)
                    {
                        nSelected++;
                        goto redrawnorebuild;
                    }
                    else
                    {
                        if (bMore)
                        {
                            StartObject++;
                        }
                    }
                }
                else
                if (keys == Keys.PageDown || keys == Keys.Next || Keyboard.RawCode == Keys.Next || Keyboard.RawCode == Keys.PageDown)
                {
                    if (nSelected < nObject - 1)
                    {
                        nSelected = nObject - 1;
                    }
                    else if (bMore)
                    {
                        StartObject += (InventoryListHeight - 1);
                    }
                }
                else
                if (keys == Keys.PageUp || keys == Keys.Back || Keyboard.RawCode == Keys.PageUp || Keyboard.RawCode == Keys.Back)
                {
                    if (nSelected > 0)
                    {
                        nSelected = 0;
                    }
                    else
                    {
                        StartObject -= (InventoryListHeight - 1);
                        if (StartObject < 0)
                        {
                            StartObject = 0;
                        }
                    }
                }
                else
                if (keys == Keys.Subtract || keys == Keys.OemMinus)
                {
                    foreach (QudUX_InventoryCategory Cat in CategoryList.Values)
                    {
                        Cat.Expanded = false;
                        SavedInventoryState.SetExpandState(Cat.Name, false);
                    }
                }
                else if (keys == Keys.Add || keys == Keys.Oemplus)
                {
                    foreach (QudUX_InventoryCategory Cat in CategoryList.Values)
                    {
                        Cat.Expanded = true;
                        SavedInventoryState.SetExpandState(Cat.Name, true);
                    }
                }
                else if (keys == Keys.Right || keys == Keys.NumPad6)
                {
                    TabController.Forward();
                    ClearLists();
                    StartObject = 0;
                    nSelected   = 0;
                }
                else if (keys == Keys.Left || keys == Keys.NumPad4)
                {
                    TabController.Back();
                    ClearLists();
                    StartObject = 0;
                    nSelected   = 0;
                }
                else if (keys == Keys.NumPad0 || keys == Keys.D0 || keys == Keys.OemPeriod || ch == '.')
                {
                    AltDisplayMode = !AltDisplayMode;
                }
                else if (keys == (Keys.Control | Keys.M))
                {
                    string iCategory = string.Empty;
                    if (CurrentObject != null)
                    {
                        foreach (var pair in CategoryMap)
                        {
                            if (pair.Value.Contains(CurrentObject))
                            {
                                iCategory = pair.Key;
                                break;
                            }
                        }
                    }
                    else if (CurrentCategory != null)
                    {
                        iCategory = CurrentCategory.Name;
                    }
                    if (!string.IsNullOrEmpty(iCategory))
                    {
                        if (TabController.CurrentTab == "Main")
                        {
                            string message = "{{y|Move the {{K|[{{Y|" + iCategory + "}}]}} category to the {{Y|Other}} tab?}}";
                            if (Popup.ShowYesNo(message) == DialogResult.Yes)
                            {
                                TabController.MoveCategoryFromMainToOther(iCategory);
                                ClearLists();
                            }
                        }
                        else if (TabController.CurrentTab == "Other")
                        {
                            string message = "{{y|Move the {{K|[{{Y|" + iCategory + "}}]}} category to the {{Y|Main}} tab?}}";
                            if (Popup.ShowYesNo(message) == DialogResult.Yes)
                            {
                                TabController.MoveCategoryFromOtherToMain(iCategory);
                                ClearLists();
                            }
                        }
                    }
                }
                else
                {
                    if (CurrentObject != null)
                    {
                        if (keys == (Keys.Control | Keys.E))
                        {
                            if (GO.AutoEquip(CurrentObject))
                            {
                                ResetNameCache(GO);
                            }
                        }

                        if (keys == Keys.NumPad1 || keys == Keys.D1 || keys == (Keys.Control | Keys.Left) || keys == (Keys.Control | Keys.NumPad4) || keys == (Keys.Control | Keys.Subtract) || keys == (Keys.Control | Keys.OemMinus))
                        {
                            //collapse the parent category for this item
                            foreach (var pair in CategoryMap)
                            {
                                if (pair.Value.Contains(CurrentObject))
                                {
                                    CategoryList[pair.Key].Expanded = false;
                                    SavedInventoryState.SetExpandState(pair.Key, false);
                                    forceCategorySelect = CategoryList[pair.Key];
                                    break;
                                }
                            }
                        }

                        if (keys == Keys.Space)
                        {
                            Qud.API.EquipmentAPI.TwiddleObject(GO, CurrentObject, ref bDone);
                            ResetNameCache(GO);
                        }

                        if (keys == Keys.Tab)
                        {
                            InventoryActionEvent.Check(CurrentObject, GO, CurrentObject, "Look");
                            ResetNameCache(GO);
                        }
                    }

                    if (CurrentCategory != null)
                    {
                        if (keys == Keys.NumPad1 || keys == Keys.D1 || keys == (Keys.Control | Keys.Left) || keys == (Keys.Control | Keys.NumPad4) || keys == (Keys.Control | Keys.Subtract) || keys == (Keys.Control | Keys.OemMinus))
                        {
                            CurrentCategory.Expanded = false;
                            SavedInventoryState.SetExpandState(CurrentCategory.Name, false);
                        }

                        if (keys == Keys.NumPad3 || keys == Keys.D3 || keys == (Keys.Control | Keys.Right) || keys == (Keys.Control | Keys.NumPad6) || keys == (Keys.Control | Keys.Add) || keys == (Keys.Control | Keys.Oemplus))
                        {
                            CurrentCategory.Expanded = true;
                            SavedInventoryState.SetExpandState(CurrentCategory.Name, true);
                        }

                        if (keys == Keys.Space)
                        {
                            CurrentCategory.Expanded = !CurrentCategory.Expanded;
                            SavedInventoryState.ToggleExpandState(CurrentCategory.Name);
                        }
                    }

                    if (keys >= Keys.A && keys <= Keys.Z && CategorySelectionList.ContainsKey(ch))
                    {
                        if (nSelected == ItemMap[(char)ch] && (!CategorySelectionList.ContainsKey(ch) || CategorySelectionList[ch].Category == null))
                        {
                            EquipmentAPI.TwiddleObject(GO, CurrentObject, ref bDone);
                            ResetNameCache(GO);
                        }
                        else
                        {
                            nSelected = ItemMap[(char)ch];
                            if (CategorySelectionList.ContainsKey(ch) && CategorySelectionList[ch].Category != null)
                            {
                                CategorySelectionList[ch].Category.Expanded = !CategorySelectionList[ch].Category.Expanded;
                                SavedInventoryState.ToggleExpandState(CategorySelectionList[ch].Category.Name);
                            }
                        }
                    }
                }
                if (SentEvent != null && !bDone && SentEvent.InterfaceExitRequested())
                {
                    bDone = true;
                }
            }

            ClearLists();

            if (bShowInventoryTiles)
            {
                ImposterUtilities.RestoreImposters(disabledObjectsWithImposters);
            }
            fakeTraderForPriceEval.Obliterate();

            if (keys == Keys.NumPad7)
            {
                GameManager.Instance.PopGameView();
                return(ScreenReturn.Previous);
            }
            if (keys == Keys.NumPad9)
            {
                GameManager.Instance.PopGameView();
                return(ScreenReturn.Next);
            }
            GameManager.Instance.PopGameView();
            return(ScreenReturn.Exit);
        }
Esempio n. 17
0
    void SpawnPrefabs()
    {
        for (int x = 0; x < sizeX; x++)
        {
            for (int y = 0; y < sizeY; y++)
            {
                if (grid[x, y].type == 0)
                {
                    // EMPTY SPACE (ROAD)
                    grid[x, y].occupant = 0;
                    Vector3 pos = new Vector3((x - sizeX / 2) * space, 0, (y - sizeY / 2) * space);
                    //GameObject c = Instantiate(groundPrefabs[Random.Range(0, 2)], pos, Quaternion.identity);

                    int neighbors = 0;
                    if (!CellIsEdge(x, y))
                    {
                        neighbors = Obstacles3x3(x, y, 1);
                    }
                    else
                    {
                        neighbors = 10;
                    }
                    GameObject c = TileMaker.GrassTile(grid[x, y], pos, space);
                    c.transform.SetParent(transform, false);

                    allSceneObjects.Add(c);
                    ArrayUtility.Add(ref openCells, grid[x, y]);
                }
                if (grid[x, y].type == 1)
                {
                    // OBSTACLE I (EMPTY)
                    grid[x, y].occupant = 0;

                    int r = Random.Range(0, 10);
                    if (r < 4)
                    {
                        Vector3    pos = new Vector3((x - sizeX / 2) * space, 0, (y - sizeY / 2) * space);
                        GameObject c   = TileMaker.ObstacleTile(grid[x, y], pos, 1.0f);
                        c.transform.SetParent(transform, false);

                        allSceneObjects.Add(c);
                    }
                }
                if (grid[x, y].type == 2)
                {
                    // OBSTACLE II (MOUNTAINS)
                    grid[x, y].occupant = 0;

                    Vector3    pos = new Vector3((x - sizeX / 2) * space, 0, (y - sizeY / 2) * space);
                    GameObject c   = Instantiate(mountainPrefabs[RNG.Range(0, 3)], pos, RNG.Q90f(Vector3.up));
                    c.transform.SetParent(transform, false);


                    allSceneObjects.Add(c);
                }
                if (grid[x, y].type == 3)
                {
                    // OBSTACLE III
                    grid[x, y].occupant = 0;

                    //Vector3 pos = new Vector3((x - sizeX / 2) * space, 0, (y - sizeY / 2) * space);
                    //GameObject c = Instantiate(obstaclePrefabIII, pos, Quaternion.identity);
                    //c.transform.parent = transform;

                    //allSceneObjects.Add(c);
                }
                if (grid[x, y].type == 4)
                {
                    // START
                    grid[x, y].occupant = 2;

                    Vector3    pos = new Vector3((x - sizeX / 2) * space, 0, (y - sizeY / 2) * space);
                    GameObject c   = Instantiate(startPrefab, pos, Quaternion.identity);
                    c.transform.SetParent(transform, false);


                    allSceneObjects.Add(c);
                }
                if (grid[x, y].type == 5)
                {
                    // END
                    grid[x, y].occupant = 0;

                    Vector3    pos = new Vector3((x - sizeX / 2) * space, 0, (y - sizeY / 2) * space);
                    GameObject c   = Instantiate(endPrefab, pos, Quaternion.identity);
                    c.transform.SetParent(transform, false);


                    allSceneObjects.Add(c);
                }
            }
        }
    }
        private void importImageAsTileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Title = "Import Image As Tile";
                dlg.DefaultExt = "dds";
                dlg.Filter = "DDS Image Files (*.dds)|*.dds|All files (*.*)|*.*";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Cursor saveCursor = this.Cursor;
                    this.Cursor = Cursors.WaitCursor;
                    TileMaker tm = new TileMaker(dlg.FileName, 4);

                    dds = new DDSFile16(tm.Width, tm.Height);
                    tm.FillTile(dds);

                    currentTileName = dlg.FileName;

                    // grab colors from tilemaker

                    ResetAdjust();
                    for (int i = 0; i < 4; i++)
                    {
                        fileColors[i] = baseColors[i] = tm.Colors[i].HSVColor;
                    }

                    UpdateButtons();

                    ColorizeTile();

                    this.Cursor = saveCursor;
                }
            }
        }
Esempio n. 19
0
    Node[,] GenerateTiles(Vector2[] directions, int maxTiles, Node nodeToPlace)
    {
        //Create a new node matrix
        Node[,] newNodes = new Node[maxTiles * 2, maxTiles * 2];
        //If there are no makers, create up to the starting amount
        if (tileMakers.Count <= 0)
        {
            for (int i = 0; i < startingTileMakers; i++)
            {
                TileMaker maker = new TileMaker();
                maker.currentPosition = new Vector2(maxTiles, maxTiles);
                tileMakers.Add(maker);
            }
        }
        //Initialize the current tiles
        int currentTiles = 0;

        //create tiles
        while (currentTiles < maxTiles)
        {
            //for each maker
            for (int i = 0; i < tileMakers.Count; i++)
            {
                //if tiles have reached max, break out
                if (currentTiles >= maxTiles)
                {
                    break;
                }
                //select the tile makers and clone a node at it's position
                TileMaker maker = tileMakers[i];
                newNodes[(int)maker.currentPosition.x, (int)maker.currentPosition.y]          = nodeToPlace.CloneNode();
                newNodes[(int)maker.currentPosition.x, (int)maker.currentPosition.y].position = maker.currentPosition;

                //check for unoccupied positions
                List <Vector2> freePositions = new List <Vector2>();
                for (int j = 0; j < directions.Length; j++)
                {
                    Vector2 check = maker.currentPosition + directions[j];
                    if (newNodes[(int)check.x, (int)check.y] == null)
                    {
                        freePositions.Add(directions[j]);
                    }
                }
                //if there are free positions, use them, else randomly select a position
                if (freePositions.Count > 0)
                {
                    maker.currentPosition += freePositions[UnityEngine.Random.Range(0, freePositions.Count)];
                    currentTiles++;
                }
                else
                {
                    Vector2 dir = directions[UnityEngine.Random.Range(0, directions.Length)];
                    maker.currentPosition += dir;
                }
                //increment tiles

                //Check if a new maker gets generated
                if (UnityEngine.Random.value <= tileMakerSpawnChance && tileMakers.Count < maxTileMakers)
                {
                    Debug.Log("New Maker");
                    TileMaker newMaker = new TileMaker();
                    newMaker.currentPosition = maker.currentPosition;
                    tileMakers.Add(maker);
                }
            }
        }
        return(newNodes);
    }