Beispiel #1
0
        public override void LoadState(PluginDataWrapper pluginData)
        {
            var reader = pluginData.GetReaderForWrappedSequentialData();

            healthBar = HealthBarControl.Load(Level, Building, reader);


            clicker          = Building.GetDefaultComponent <Clicker>();
            clicker.Clicked += KeepClicked;
            window           = Building.Player == Level.HumanPlayer ? new KeepWindow(this) : null;

            CreatePathfindingNodes();
        }
Beispiel #2
0
            public KeepWindowInstance(KeepWindow keepWindow)
            {
                this.keepWindow      = keepWindow;
                this.spawningButtons = new Dictionary <UIElement, SpawnableUnitTypePlugin>();
                var packageUI = ((LevelInstancePluginBase)Keep.Level.Plugin).PackageUI;

                packageUI.LoadLayoutToUI("Assets/UI/KeepWindow.xml", "Assets/UI/UIStyle.xml");

                this.holder     = packageUI.PackageRoot.GetChild("KeepWindowHolder");
                this.window     = (Window)holder.GetChild("KeepWindow");
                this.hideButton = (Button)window.GetChild("HideButton");
                this.container  = window.GetChild("Container");

                try {
                    if (!Keep.Level.EditorMode)
                    {
                        using (var styleFile = packageUI.GetStyleFile()) {
                            foreach (var unitTypeName in KeepType.SpawnedUnits)
                            {
                                var unitType = this.Keep.Level.Package.GetUnitType(unitTypeName);

                                var button = container.CreateButton();
                                button.SetStyle("SpawningButton", styleFile);
                                button.Texture       = Keep.Level.Package.UnitIconTexture;
                                button.ImageRect     = unitType.IconRectangle;
                                button.HoverOffset   = new IntVector2(unitType.IconRectangle.Width(), 0);
                                button.PressedOffset = new IntVector2(unitType.IconRectangle.Width() * 2, 0);

                                var unitTypePlugin = ((SpawnableUnitTypePlugin)unitType.Plugin);
                                spawningButtons.Add(button, unitTypePlugin);
                            }
                        }
                    }
                }
                catch (Exception) {
                    Dispose();
                    throw;
                }

                RegisterHandlers();

                window.Visible = false;
            }