private void ControlSystem()
        {
            DaySchedule currentDaySchedule = GrowingPlant.GrowingPlan[CurrentDay];

            foreach (var sensor in PassiveSensors)
            {
                var sensorShcedule = currentDaySchedule[sensor.Area];
                var UISensor       = UIElements.Where(e => e.Id == sensor.Id).FirstOrDefault();
                UISensor.CurrentState = sensor.GetData().ToString();
                if (Math.Abs(sensor.GetData() - sensorShcedule.OptimalValue) > sensorShcedule.MaxDeviation)
                {
                    foreach (var device in Devices)
                    {
                        if (device.Area == sensor.Area)
                        {
                            device.TurnOn(sensorShcedule.OptimalValue);
                            UIElements.Where(e => e.Id == device.Id).ToList().ForEach(e => e.CurrentState = "Active");
                        }
                    }
                }
                else
                {
                    foreach (var device in Devices)
                    {
                        if (device.Area == sensor.Area)
                        {
                            device.TurnOff();
                            UIElements.Where(e => e.Id == device.Id).ToList().ForEach(e => e.CurrentState = "Off");
                        }
                    }
                }
            }
        }
Example #2
0
 UiElementTransition
     (UiElementTransitionType type,
     UIElements targets)
 {
     this.Type    = type;
     this.Targets = targets;
 }
Example #3
0
        public void EnableButton(Rect rect)
        {
            if (VehicleMod.selectedDef is null)
            {
                Log.Error($"SelectedDef is null while trying to create Enable button for VehicleDef.");
                return;
            }
            var gameFont = Text.Font;

            Text.Font = GameFont.Medium;
            FieldInfo     enabledField      = AccessTools.Field(typeof(VehicleDef), nameof(VehicleDef.enabled));
            SaveableField saveableField     = new SaveableField(VehicleMod.selectedDef, enabledField);
            bool          enabled           = (bool)fieldSettings[VehicleMod.selectedDef.defName][saveableField].First;
            string        text              = enabled ? "VehicleEnabled".Translate() : "VehicleDisabled".Translate();
            Vector2       size              = Text.CalcSize(text);
            Color         textColor         = enabled ? Color.green : Color.red;
            Rect          enabledButtonRect = new Rect(rect.x, rect.y, size.x, size.y);

            TooltipHandler.TipRegion(enabledButtonRect, "VehicleEnableButtonTooltip".Translate());
            if (UIElements.ClickableLabel(enabledButtonRect, text, Color.yellow, textColor, GameFont.Medium))
            {
                fieldSettings[VehicleMod.selectedDef.defName][saveableField] = new SavedField <object>(!enabled);
            }
            Text.Font = gameFont;
        }
        RetrieveManager <ManagerType>
            (UIElements element)
            where ManagerType : Component
        {
            Type ExpectedManagerType = element.ManagerClass();

            MyContract.RequireArgument(
                typeof(ManagerType) == ExpectedManagerType,
                "is expected type",
                "ManagerType: " + typeof(ManagerType).Name
                );

            MyContract.RequireField
            (
                this.Contains(element),
                "contains the element " + element.ToString(),
                "RegisteredObjects"
            );

            ManagerType Manager
                = RegisteredObjects[(int)element].GetComponent <ManagerType>();

            MyContract.RequireFieldNotNull(
                Manager,
                typeof(ManagerType).Name
                + " component of GameObject "
                + element.ToString()
                );
            return(Manager);
        }
Example #5
0
        public override void Start()
        {
            UIElements.Clear();
            Console.Clear();
            Console.CursorVisible = false;

            UIElements.Add(new UIText("LoadAndSave", $"select a game to load or enter filename for new savegame", 10, 5, true));
            UIElements.Add(new UIInput("Filename", "Filename", 10, 7, true, () => { }));
            UIElements.Add(new UIButton("Load", "Load", 10, 11, true, () => { LoadGame(UIElements[1].input); }));
            UIElements.Add(new UIButton("Save", "Save", 10, 12, true, () => { SaveGame(UIElements[1].input + ".xml"); }));

            UIElements.Add(new UIText("Found", $"found savegames:", 30, 9, true));
            fileNames = Directory.GetFiles(@".\", "*.xml");

            for (int i = 0; i < 10; i++)
            {
                //int e = new int();
                //e = i;
                //UIElements.Add(new UIButton($"File {i}", $"{fileNames[i]}", 30, 11 + i, true, () => { if (UIElements[1].input == fileNames[e]) LoadGame(UIElements[1].input); else UIElements[1].input = fileNames[e]; }));
                UIElements.Add(new UIButton($"File {i}", $"{i}.", 30, 11 + i, true, () => { }));
            }

            cursor = new UICursor("Cursor", " ", 12, 7, true, () => { }); // TODO: set cursor at input position
            UIElements.Add(cursor);
            activeElement = 1;
            ListFiles();
        }
Example #6
0
 private void UpdateUIElements(GameTime gameTime)
 {
     foreach (var element in UIElements.ToArray())
     {
         element.Update(gameTime);
     }
 }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uiElement"></param>
        /// <returns>
        /// Manager class if it has one, null otherwise
        /// </returns>
        public static Type ManagerClass(this UIElements uiElement)
        {
            switch (uiElement)
            {
            case UIElements.MainMenu:
                return(typeof(MainMenuUIManager));

            case UIElements.SettingsMenu:
                return(typeof(SettingsMenuUIManager));

            case UIElements.GameplayUI:
                return(typeof(GameplayUIManager));

            case UIElements.InGameMenu:
                return(typeof(InGameMenuManager));

            case UIElements.OrreryUI:
                return(typeof(OrreryUIManager));

            case UIElements.Scoreboard:
                return(typeof(ScoreboardUiManager));

            case UIElements.Respawn:
                return(typeof(RespawnUIManager));

            case UIElements.PingDisplay:
                return(typeof(PingTester));

            default:
                return(null);
            }
        }
Example #8
0
        public static AnimationObject Create(NVector pos)
        {
            var ani = Instantiate(UIElements.Get().animationHelper, GameMgmt.Get().newMap[pos.level].effects.transform).GetComponent <AnimationObject>();

            ani.transform.position = new Vector3(pos.x + 0.5f, pos.y + 0.5f);
            return(ani);
        }
        public void SetOperations(Operations op)
        {
            MyUIs.Clear();
            switch (op)
            {
            case Operations.gurnist:
                break;

            case Operations.Starting:
                UIElements u = new UIElements();
                u = UIElements.ShowGetMyReports;
                MyUIs.Add(u);
                break;

            case Operations.RetrieveReports:
                break;

            case Operations.ScheduleReports:
                break;

            case Operations.ShowHits:
                break;

            case Operations.ShowParameters:
                break;

            case Operations.ShowScheduledItems:
                break;

            default:
                break;
            }
        }
Example #10
0
 private void SetOrbitDetails(Orbit orbit)
 {
     apoapsis.text     = UIElements.FormatKM(orbit.ApoApsis);
     periapsis.text    = UIElements.FormatKM(orbit.PeriApsis);
     eccentricity.text = orbit.Eccentricity.ToString();
     period.text       = UIElements.FormatPeriod(orbit.Period);
     speed.text        = UIElements.FormatSpeed(orbit.MeanMotion);
 }
        private void OnCanvasMouseMove(object send, MouseEventArgs e)
        {
            Point p  = e.GetPosition(Canvas);
            var   rc = UIElements.Last() as RectangleControl;

            rc.RectWidth  = p.X - rc.RectX;
            rc.RectHeight = p.Y - rc.RectY;
        }
 public TargetedDialogBox(SmallPlayerUI target, UIElements.SimpleButton button, float distanceFromMessage,
     string message, Rectangle messageArea, UIElements.StretchableImage back)
     : base(button, message, messageArea, back)
 {
     _target = target;
     _distFromMes = distanceFromMessage;
     followTarget();
 }
Example #13
0
        internal void RemoveFromUICollection(UIElementCollection collection)
        {
            foreach (var uiElement in UIElements)
            {
                collection.Remove(uiElement);
            }

            UIElements.Clear();
        }
Example #14
0
 RequestTransition
     (UiElementTransitionType transitionType,
     UIElements targets)
 {
     TransitionRequester.RequestTransition(
         transitionType,
         targets
         );
 }
Example #15
0
        /// <summary>
        /// Instantiates the UIController, which will handle advanced UI interactions and host
        /// the TabularModelHandler from the TOMWrapper library.
        /// </summary>
        public void SetupUIController()
        {
            var elements = new UIElements()
            {
                FormMain            = this,
                TreeView            = tvModel,
                PropertyGrid        = propertyGrid1,
                ExpressionEditor    = txtExpression,
                ScriptEditor        = txtAdvanced,
                ErrorLabel          = lblErrors,
                StatusLabel         = lblStatus,
                BpaLabel            = lblBpaRules,
                StatusExLabel       = lblScriptStatus,
                OpenBimDialog       = dlgOpenFile,
                CurrentMeasureLabel = lblCurrentMeasure,
                ModelMenu           = modelToolStripMenuItem,
                PerspectiveSelector = cmbPerspective,
                TranslationSelector = cmbTranslation,
                ToolsMenu           = toolsToolStripMenuItem,
                DynamicMenu         = dynamicToolStripMenuItem,
                ExpressionSelector  = cmbExpressionSelector
            };

            // The UIController class sets up all bindings and event handlers needed for UI
            // interaction, once we pass it a reference to the main UI elements. This is not
            // really a "loose coupling" between UI and model code, but it helps to keep the
            // code nicely separated.
            UI              = new UIController(elements);
            UI.ModelLoaded += UI_ModelLoaded;

            actToggleInfoColumns.Checked = Preferences.Current.View_MetadataInformation;
            UI.SetInfoColumns(actToggleInfoColumns.Checked);
            actToggleDisplayFolders.Checked = Preferences.Current.View_DisplayFolders;
            actToggleHidden.Checked         = Preferences.Current.View_HiddenObjects;
            actToggleMeasures.Checked       = Preferences.Current.View_Measures;
            actToggleColumns.Checked        = Preferences.Current.View_Columns;
            actToggleHierarchies.Checked    = Preferences.Current.View_Hierarchies;
            actTogglePartitions.Checked     = Preferences.Current.View_Partitions;
            actToggleAllObjectTypes.Checked = Preferences.Current.View_AllObjectTypes;
            actToggleOrderByName.Checked    = !Preferences.Current.View_SortAlphabetically;

            actSearchChild.Checked  = Preferences.Current.View_SearchResults == SearchResultOption.ByChild;
            actSearchParent.Checked = Preferences.Current.View_SearchResults == SearchResultOption.ByParent;
            actSearchFlat.Checked   = Preferences.Current.View_SearchResults == SearchResultOption.Flat;

            // Assign column widths from preferences:
            foreach (var cp in Preferences.Current.View_ColumnPreferences)
            {
                var column = elements.TreeView.Columns.FirstOrDefault(c => c.Header == cp.Name);
                if (column != null)
                {
                    column.Width = cp.Width;
                }
            }

            actViewOptions_Execute(this, null);
        }
Example #16
0
        public Button CreateImageButton(Transform transform, Player player, IMapUI text)
        {
            Button button = UIElements.CreateImageButton(LClass.s.Button(id).Sprite(player), transform, () => { Call(player); }, Sound);

            UIHelper.HoverEnter(button, () => text.ShowPanelMessage(LSys.tem.inputs.GameButtonName(this)),
                                () => text.ShowPanelMessage(""));

            return(button);
        }
        public void UpdateUISensorsInformation()
        {
            foreach (var passiveSensor in PassiveSensors)
            {
                UIElements.Where(e => e.Id == passiveSensor.Id).FirstOrDefault().CurrentState = passiveSensor.GetData().ToString();
            }

            // TODO later implement Active sensors
        }
Example #18
0
 private string button_name_errmsg(UIElements button_element,
                                   String intended_name)
 {
     return("The "
            + button_element.ToString()
            + " has not been set up correctly in the editor.\n"
            + "Please set its output name to its proper value: \""
            + intended_name
            + "\"");
 }
Example #19
0
        /// <summary>
        /// Populates the UI elements
        /// </summary>
        protected virtual void PopulateUIElements()
        {
            UIElements.Clear();
            UIElements.Add(new SaveButtonUIElement());

            if (IsEditable)
            {
                UIElements.Add(new PublishButtonUIElement());
            }
        }
Example #20
0
        /// <summary>
        /// Allows us to use the UIElement "all" as necessary
        /// (we already have none included but all seems to cause problems
        /// [if it doesn't cause problems just add it back in])
        /// </summary>
        private void InitialiseUIElementAll()
        {
            Array allUIElementValues = Enum.GetValues(typeof(UIElements));

            UIElement_ALL = UIElements.None;
            foreach (UIElements e in allUIElementValues)
            {
                UIElement_ALL |= e;
            }
        }
Example #21
0
 public SimpleButton(UIElements.StretchableImage texture, Rectangle area, string text)
     : base()
 {
     _text = text;
     _area = area;
     _position = Utils.pointToVector2(_area.Center);
     _width = _area.Width;
     _height = _area.Height;
     _buttonTexture = texture;
 }
Example #22
0
        void RefreshUIBox()
        {
            _queueRefresh = false;
            UIElements.Clear();
            int cursor = 0;

            _weaponBoxes = new List <UI_WeaponEquipBox>();

            int _index = 0;

            foreach (Weapon w in A3RData.SelectedPlayer.Character.WeaponList)
            {
                UI_WeaponEquipBox _weaponBox = new UI_WeaponEquipBox(Camera, A3RData,
                                                                     new Vector(Pos.X + 20, Pos.Y + cursor * (50 + 15) + 20), OnInventoryEvent);
                _weaponBox.HeldWeapon  = w;
                _weaponBox.IsActive    = true;
                _weaponBox.IsInventory = false;
                _weaponBox.WeaponIndex = _index;

                cursor++;
                _weaponBoxes.Add(_weaponBox);
                AddElement(_weaponBox);
                _index++;
            }
            AddElement(new UI_Line(Camera, new Vector(Pos.X + 20, Pos.Y + cursor * 65 + 20),
                                   new Vector(Pos.X + _width - 20, Pos.Y + cursor * 65 + 20)));
            AddElement(new UI_Text(Camera, Pos.X + 30, Pos.Y + cursor * 65 + 35, Color.White, SwinGame.FontNamed("winnerFont"),
                                   "Inventory"));
            cursor++;

            _index = 0;
            foreach (Weapon w in A3RData.SelectedPlayer.Character.Inventory)
            {
                UI_WeaponEquipBox _weaponBox = new UI_WeaponEquipBox(Camera, A3RData,
                                                                     new Vector(Pos.X + 20, Pos.Y + cursor * (50 + 15) + 20), OnInventoryEvent);
                _weaponBox.HeldWeapon  = w;
                _weaponBox.IsActive    = false;
                _weaponBox.IsInventory = true;
                _weaponBox.WeaponIndex = _index;

                cursor++;

                _weaponBoxes.Add(_weaponBox);
                AddElement(_weaponBox);
                _index++;
            }
            cursor++;

            UI_WeaponEquipBox _sellBox = new UI_WeaponEquipBox(Camera, A3RData,
                                                               new Vector(Pos.X + 20, Pos.Y + cursor * (50 + 15) + 20), OnInventoryEvent);

            _sellBox.WeaponIndex = -1;
            _sellBox.IsSellBox   = true;
            AddElement(_sellBox);
        }
        protected override void OnActivate()
        {
            ListBoxElements = new BindableCollection <FrameworkElement>();
            elements        = new UIElements();
            Button btn   = elements.CreateButton();
            var    style = Application.Current.TryFindResource("AddImageButton") as Style;

            btn.Style  = style;
            btn.Click += new RoutedEventHandler(AddRectengle);
            ListBoxElements.Add(btn);
        }
Example #24
0
        public void TransitionUIElementsBacktrack()
        {
            MyContract.RequireField(UITransitionHistory.Count > 0,
                                    "has at least one entry",
                                    "UITransitionHistory");
            UIElements PreviousState = UITransitionHistory.Pop();

            showUIElementFromFlags(false, ActiveUIElements & ~PersistentUIElements);
            showUIElementFromFlags(true, PreviousState);
            ActiveUIElements = PreviousState;
        }
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Target"))
        {
            ScoreInfo = GameObject.Find("Game Controller");
            UIElements ScoreUpdate = ScoreInfo.GetComponent <UIElements>();
            ScoreUpdate.UpdateScore(m_Team);
            other.gameObject.SetActive(false);

            ResetBullet();
        }
    }
        RequestTransition
            (UiElementTransitionType transitionType,
            UIElements targets)
        {
            UiElementTransition RequestedTransition
                = new UiElementTransition(
                      transitionType,
                      targets
                      );

            UiTransitionRequest(RequestedTransition);
        }
Example #27
0
    void Awake()
    {
        instance = this;

        totalTime    = 300.0f;
        currentTime  = totalTime;
        uiTimer.text = totalTime.ToString();

        if (endUI == null)
        {
            Debug.Log("THERE IS NO END UI");
        }
    }
        private void ExcuteAddPathCmd()
        {
            mode = 0;
            if (Canvas == null)
            {
                var ue = new UIElement();
                UIElements.Add(ue);
                Canvas = (Canvas)VisualTreeHelper.GetParent(ue);
                UIElements.Clear();
            }


            Canvas.PreviewMouseLeftButtonDown += OnCanvasMouseLeftButtonDown;
        }
Example #29
0
        private void showUIElementFromFlags(bool show, UIElements elements)
        {
            Array             allUIElementValues = Enum.GetValues(typeof(UIElements));
            List <UIElements> args = new List <UIElements>();

            foreach (UIElements e in allUIElementValues)
            {
                if ((e & elements) > 0)
                {
                    args.Add(e);
                }
            }
            showUIElement(show, args.ToArray());
        }
        public void AddNewElement(UIElement uIElement)
        {
            uIElement.Id = _item_counter;
            UIElements.Add(uIElement);
            IDevice device = _deviceFactory.CreateDevice(uIElement.DeviceType, _item_counter);

            device.Position = uIElement.Position;
            switch (uIElement.DeviceType)
            {
            case DeviceType.Device:
                Device temp_device = (Device)device;
                switch (uIElement.Area)
                {
                case Area.AirTemperature:
                    temp_device.Command = _commandFactory.CreateAirTemperatureHeaterCommand();
                    break;

                case Area.WaterTemperature:
                    temp_device.Command = _commandFactory.CreateWaterTemperatureHeaterCommand();
                    break;

                case Area.Nutrient:
                    temp_device.Command = _commandFactory.CreateNutrientRegulatorCommand();
                    break;

                case Area.Acid:
                    temp_device.Command = _commandFactory.CreateAcidRegulatorCommand();
                    break;

                default:
                    throw new NotImplementedException();
                }
                Devices.Add(temp_device);
                break;

            case DeviceType.ActiveSensor:
                ActiveSensors.Add(device as ActiveSensor);
                break;

            case DeviceType.PasssiveSensor:
                PassiveSensors.Add(device as PassiveSensor);
                break;

            default:
                throw new NotImplementedException();
            }
            _item_counter++;
        }
Example #31
0
        /// <summary>
        /// Adds a UI Element and makes it interactable if it implements <see cref="IInteractable"/> and scrollable if it implements <see cref="IScrollable"/>.
        /// </summary>
        /// <typeparam name="T">UIElement descendant of type T.</typeparam>
        /// <param name="uiElement">The UI Element to add.</param>
        /// <returns>Returns the craeted UI Element.</returns>
        public T AddUIElement <T>(T uiElement) where T : UIElement
        {
            UIElements.Add(uiElement);

            if (uiElement is IInteractable interactable)
            {
                Interactables.Add(interactable);
            }

            if (uiElement is IScrollable scrollable)
            {
                Scrollables.Add(scrollable);
            }

            return(uiElement);
        }
Example #32
0
    //Saves the game
    public static void SaveGame(UIElements ui)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/gamesave.save";
        FileStream      file      = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData(ui);

        formatter.Serialize(file, data);
        file.Close();

        Debug.Log("Game Saved at: " + Application.persistentDataPath);
        Debug.Log("Health: " + data.health);
        Debug.Log("Score: " + data.score);
        Debug.Log("Time: " + data.time);
        Debug.Log("Position: x = " + PlayerBehavior.savePosition[0] + ", y = " + PlayerBehavior.savePosition[1] + ", z = " + PlayerBehavior.savePosition[2]);
    }
Example #33
0
 public MessageDialogBox(string content, Rectangle area, UIElements.StretchableImage back)
 {
     _backTexture = back;
     _message = Utils.fitText(content, MyGame.BasicFont, area);
     updateArea();
 }
Example #34
0
 public ButtonDialogBox(UIElements.SimpleButton button, string message, Rectangle messageArea, UIElements.StretchableImage back)
     : base(message, messageArea, back)
 {
     _button = button;
 }
 public ConditionalDialogBox(Utils.conditionChecker checker, string content, Rectangle area, UIElements.StretchableImage back)
     : base(content, area, back)
 {
     _conditionTest = checker;
 }