Exemple #1
0
    public void ReloadButtons()
    {
        for (int i = 0; i < transform.childCount; i++)
        {
            Destroy(transform.GetChild(i).gameObject);
        }

        for (int i = 0; i < manager.UnplacedObjects.Count; i++)
        {
            GameObject     button   = Instantiate(ObjectButtonPrefab, transform);
            SelectorButton selector = button.GetComponent <SelectorButton>();

            if (selector == null)
            {
                Debug.LogError("No selector button on button prefab");
                Destroy(button);
                break;
            }
            button.name          = "Selector button " + i;
            selector.icon.sprite = iconSet.FindIcon(manager.UnplacedObjects[i].GetType());
            selector.id          = i;
            selector.displayer   = this;
            selector.SetOrientation(manager.UnplacedObjects[i].Orientation);
            selector.SetMovability(manager.UnplacedObjects[i].CanMove, manager.UnplacedObjects[i].CanRotate);
        }
    }
Exemple #2
0
        private async void SelectorOption_Tapped(object sender, System.EventArgs e)
        {
            if (!(sender is View view))
            {
                return;
            }

            var index = Grid.GetColumn(view);

            SelectorButton.TranslateTo(index * view.Width, 0, AnimationDuration, Easing.CubicInOut).FireAndForget();

            await SelectorButtonLabel.FadeTo(0, AnimationDuration / 2);

            SelectorButtonLabel.Text = index == 1 ? "New" : "Existing";
            await SelectorButtonLabel.FadeTo(1, AnimationDuration / 2);

            var revealForm = index == 0 ? LoginForm : SignupForm;
            var hideForm   = revealForm == LoginForm ? SignupForm : LoginForm;
            var direction  = revealForm == LoginForm ? 1 : -1;

            await Task.WhenAll(
                hideForm.TranslateTo(direction * 200, 0, AnimationDuration, Easing.SinOut),
                hideForm.FadeTo(0, AnimationDuration));

            hideForm.IsVisible = false;

            revealForm.TranslationX = -direction * 200;
            revealForm.IsVisible    = true;

            await Task.WhenAll(
                revealForm.TranslateTo(0, 0, AnimationDuration, Easing.SinOut),
                revealForm.FadeTo(1, AnimationDuration));
        }
Exemple #3
0
    void AddSongButton(Song song)
    {
        // Creamos una nueva variable newButton, instanciamos el botón a partir del prefab y
        // le asignamos el transform parent como parent del mismo
        SelectorButton newButton = Instantiate(selectorPrefab, buttonsParent);

        // Agregamos el botón a la lista, es probable que no haga falta
        selectorButtons.Add(newButton);

        // Llamamos el método del Selector para asignarle una canción
        newButton.SetSong(song);
    }
Exemple #4
0
    private void AddButton(SelectorButton action)
    {
        GameObject obj;

        if (objectPool.TryGetNextObject(Vector3.zero, Quaternion.identity, out obj))
        {
            var btn = obj.GetComponent <CustomUIButton>();

            btn.ClearListeners();
            btn.AddClickListener(CloseSelector);
            btn.AddClickListener(action.action);
            btn.SetText(action.title);

            obj.transform.SetParent(buttonContainer.transform, false);
            obj.transform.SetAsLastSibling();
        }
    }
Exemple #5
0
        private void RefreshFileListAction()
        {
            // get the list of FileObjects
            _initialObjectsList = new List <FileListItem>();
            switch (Config.Instance.FileExplorerViewMode)
            {
            case 0:
                _initialObjectsList = FileExplorer.ListFileOjectsInDirectory(ProEnvironment.Current.BaseLocalPath);
                break;

            case 1:
                _initialObjectsList = FileExplorer.ListFileOjectsInDirectory(ProEnvironment.Current.BaseCompilationPath);
                break;

            case 2:
                foreach (var dir in ProEnvironment.Current.GetProPathDirList)
                {
                    _initialObjectsList.AddRange(FileExplorer.ListFileOjectsInDirectory(dir, false, false));
                }
                break;

            default:
                // get the list of FileObjects
                Regex regex    = new Regex(@"\\\.");
                var   fullList = new HashSet <string>(StringComparer.CurrentCultureIgnoreCase);
                fullList.Add(ProEnvironment.Current.BaseLocalPath);
                if (!fullList.Contains(ProEnvironment.Current.BaseCompilationPath))
                {
                    fullList.Add(ProEnvironment.Current.BaseCompilationPath);
                }
                // base local path
                if (Directory.Exists(ProEnvironment.Current.BaseLocalPath))
                {
                    foreach (var directory in Directory.GetDirectories(ProEnvironment.Current.BaseLocalPath, "*", SearchOption.AllDirectories))
                    {
                        if (!fullList.Contains(directory) && (!Config.Instance.FileExplorerIgnoreUnixHiddenFolders || !regex.IsMatch(directory)))
                        {
                            fullList.Add(directory);
                        }
                    }
                }
                // base compilation path
                if (Directory.Exists(ProEnvironment.Current.BaseCompilationPath))
                {
                    foreach (var directory in Directory.GetDirectories(ProEnvironment.Current.BaseCompilationPath, "*", SearchOption.AllDirectories))
                    {
                        if (!fullList.Contains(directory) && (!Config.Instance.FileExplorerIgnoreUnixHiddenFolders || !regex.IsMatch(directory)))
                        {
                            fullList.Add(directory);
                        }
                    }
                }
                // for each dir in propath
                foreach (var directory in ProEnvironment.Current.GetProPathDirList)
                {
                    if (!fullList.Contains(directory) && (!Config.Instance.FileExplorerIgnoreUnixHiddenFolders || !regex.IsMatch(directory)))
                    {
                        fullList.Add(directory);
                    }
                }
                foreach (var path in fullList)
                {
                    _initialObjectsList.AddRange(FileExplorer.ListFileOjectsInDirectory(path, false));
                }
                break;
            }

            // apply custom sorting
            _initialObjectsList.Sort(new FilesSortingClass());

            try {
                // delete any existing buttons
                if (_displayedTypes != null)
                {
                    foreach (var selectorButton in _displayedTypes)
                    {
                        selectorButton.Value.ButtonPressed -= HandleTypeClick;
                        if (Controls.Contains(selectorButton.Value))
                        {
                            Controls.Remove(selectorButton.Value);
                        }
                        selectorButton.Value.Dispose();
                    }
                }

                // get distinct types, create a button for each
                int xPos = 59;
                int yPox = Height - 28;
                _displayedTypes = new Dictionary <FileType, SelectorButton <FileType> >();
                foreach (var type in _initialObjectsList.Select(x => x.Type).Distinct())
                {
                    var but = new SelectorButton <FileType> {
                        BackGrndImage        = Utils.GetImageFromStr(Utils.GetExtensionImage(type.ToString(), true)),
                        Activated            = true,
                        Size                 = new Size(24, 24),
                        TabStop              = false,
                        Location             = new Point(xPos, yPox),
                        Type                 = type,
                        AcceptsRightClick    = true,
                        Anchor               = AnchorStyles.Left | AnchorStyles.Bottom,
                        HideFocusedIndicator = true
                    };
                    but.ButtonPressed += HandleTypeClick;
                    toolTipHtml.SetToolTip(but, "Type of item : <b>" + type + "</b>:<br><br><b>Left click</b> to toggle on/off this filter<br><b>Right click</b> to filter for this type only");
                    _displayedTypes.Add(type, but);
                    Controls.Add(but);
                    xPos += but.Width;
                }

                // label for the number of items
                TotalItems   = _initialObjectsList.Count;
                nbitems.Text = TotalItems + StrItems;
                fastOLV.SetObjects(_initialObjectsList);

                ApplyFilter();
            } catch (Exception e) {
                ErrorHandler.ShowErrors(e, "Error while showing the list of files");
            }
        }
            public DevStatus()
            {
                bufRButton = new SelectorButton[NUM_OF_NORMAL_CLIENTS];
                bufCButton = new SelectorButton[NUM_OF_EXTENDED_CLIENTS];
                for (int i = 0; i < bufRButton.Length;i++ )
                {
                    bufRButton[i] = new SelectorButton();
                }

                for (int i = 0; i < bufCButton.Length; i++)
                {
                    bufCButton[i] = new SelectorButton();
                }
            }
    //в авейке все это работает плохо
    void Start()
    {
        _gameObject = gameObject;
        _transform = transform;
        uimanager = GameObject.Find("UIManager").GetComponent<UIManager>();
        uimanager.OnCall_USelector += MoveandAppeare;
        uimanager.OnCall_USelector += ShowRadius; //показываем радиус текущей башни
        uimanager.OnPress_UButton += ShowRadius_next; //показываем радиус апгрейда
        uimanager.OnCloseGUI += Disappeare;
        uimanager.OnCloseGUI += HideRadius;
        uimanager.OnPress_UAButton += Change;
        _weaponmanager = _camera.GetComponent<WeaponManager>();
        _resourceManager = _camera.GetComponent<ResourceManager>();
        up_button = _transform.GetChild(0).GetComponent<SelectorButton>();
        sell_button = _transform.GetChild(1).GetComponent<SelectorButton>();

        radiusGM = GameObject.Find("Radius");
        radiusT = radiusGM.transform;

        _gameObject.SetActive(false);
    }
Exemple #8
0
 public void Select(SelectorButton button)
 {
     _selected         = button;
     _isSelectorMoving = true;
     _selectedRT       = button.GetComponent <RectTransform>();
 }
    public void SelectorClicked(SelectorButton button)
    {
        SubSelector concerned = button.parent as SubSelector;

        if (concerned == null)
        {
            return;
        }
        byte option = button.num;

        bool multiple = concerned.targets.Length > 1;

        for (int i = 0; i < concerned.targets.Length; i++)
        {
            // Check Flags
            if (i != 0 && (button.flags >> 1) % 2 == 0)
            {
                // single vessel only
                goto LOOPEND;
            }
            if (i == 0 && button.flags % 2 == 1)
            {
                // use pinlabel
                Debug.Log(DeveloppmentTools.LogIterable(concerned.targets));
                concerned_objects = concerned.targets;
                lasting_command   = button.function;
            }

            IMarkerParentObject parentObject = concerned.targets[i];
            var ship = parentObject as Ship;

            SelectorOptions options = concerned.options;

            switch (button.function)
            {
//  +-----------------------------------------------------------------------------------------------------------------------+
//	|									Reference																			|
//  +-----------------------------------------------------------------------------------------------------------------------+
            case 0x0c:
// Set Camera ---------------------------------------------------------------------------------------------------------------
                SceneGlobals.ReferenceSystem.Offset += parentObject.Position - SceneGlobals.ReferenceSystem.Position;
                goto LOOPEND;

            case 0x0d:
// Set Reference ------------------------------------------------------------------------------------------------------------
                SceneGlobals.map_core.CurrentSystem = new ReferenceSystem(parentObject.Position);
                goto LOOPEND;

            case 0x0e:
// Lock Reference -----------------------------------------------------------------------------------------------------------
                Vector3     offset    = Vector3.zero;
                SceneObject scene_obj = parentObject as SceneObject;
                if (parentObject is SceneObject)
                {
                    offset = SceneGlobals.ReferenceSystem.Position - scene_obj.Position;
                    SceneGlobals.ReferenceSystem = new ReferenceSystem(scene_obj);
                }
                else if (parentObject is ITargetable)
                {
                    offset = SceneGlobals.ReferenceSystem.Position - parentObject.Position;
                    Target tgt = (parentObject as ITargetable).Associated;
                    SceneGlobals.ReferenceSystem = new ReferenceSystem(tgt);
                }

                SceneGlobals.ReferenceSystem.Offset = offset;
                goto LOOPEND;

            case 0x0f:
// Lock & Set ---------------------------------------------------------------------------------------------------------------
                if (parentObject is SceneObject)
                {
                    SceneGlobals.ReferenceSystem = new ReferenceSystem(parentObject as SceneObject);
                }
                else if (parentObject is ITargetable)
                {
                    SceneGlobals.ReferenceSystem = new ReferenceSystem((parentObject as ITargetable).Associated);
                }
                goto LOOPEND;

            case 0x19:
// Match Velocity Closest ---------------------------------------------------------------------------------------------------
                if (parentObject is ITargetable)
                {
                    foreach (IMarkerParentObject impo in MapCore.Active.selection)
                    {
                        Ship ship01 = impo as Ship;
                        if (ship01 != null && ship01.Friendly)
                        {
                            ship01.low_ai.MatchVelocityNearTarget((parentObject as ITargetable).Associated);
                        }
                    }
                }
                goto LOOPEND;

            case 0x1a:
// Match Velocity -----------------------------------------------------------------------------------------------------------
                if (parentObject is IPhysicsObject)
                {
                    foreach (IMarkerParentObject impo in MapCore.Active.selection)
                    {
                        Ship ship01 = impo as Ship;
                        if (ship01 != null && ship01.Friendly)
                        {
                            ship01.low_ai.MatchVelocity((parentObject as ITargetable).Associated);
                        }
                    }
                }
                goto LOOPEND;

            case 0x1b:
// Attack -------------------------------------------------------------------------------------------------------------------
                if (parentObject is ITargetable)
                {
                    Target self_tgt = (parentObject as ITargetable).Associated;
                    foreach (IMarkerParentObject impo in MapCore.Active.selection)
                    {
                        Ship ship01 = impo as Ship;
                        if (ship01 != null && ship01.Friendly)
                        {
                            ship01.low_ai.Attack(self_tgt);
                        }
                    }
                }
                goto LOOPEND;

            case 0x1c:
// TurretAttack -------------------------------------------------------------------------------------------------------------
                if (parentObject is ITargetable)
                {
                    Target self_tgt = (parentObject as ITargetable).Associated;
                    foreach (IMarkerParentObject impo in MapCore.Active.selection)
                    {
                        Ship ship01 = impo as Ship;
                        if (ship01 != null && ship01.Friendly)
                        {
                            ship01.low_ai.TurretAttack(self_tgt);
                        }
                    }
                }
                goto LOOPEND;

            case 0x1d:
// Aim Here -----------------------------------------------------------------------------------------------------------------
                SceneGlobals.Player.TurretAim = parentObject;
                goto LOOPEND;

            case 0x1e:
// Target Part --------------------------------------------------------------------------------------------------------------

                goto LOOPEND;

            case 0x1f:
// Set Target ---------------------------------------------------------------------------------------------------------------
                if (parentObject is ITargetable)
                {
                    Target tgt = (parentObject as ITargetable).Associated;
                    SceneGlobals.Player.Target = tgt;
                }
                goto LOOPEND;

//  +-----------------------------------------------------------------------------------------------------------------------+
//  |										Info																			|
//  +-----------------------------------------------------------------------------------------------------------------------+
            case 0x2e:
// Ship Information ---------------------------------------------------------------------------------------------------------
                if (i != 0)
                {
                    goto LOOPEND;
                }
                concerned.SpawnChild("Ship Information", new string [] {
                    ship.Mass.ToString("Mass: 0.0 t"),
                    string.Format("HP: {0:0.0} / {1:0.0}", ship.HP, ship.tot_hp),
                });
                goto LOOPEND;

            case 0x2f:
// OS -----------------------------------------------------------------------------------------------------------------------
                goto LOOPEND;
//  +-----------------------------------------------------------------------------------------------------------------------+
//  |									Command																				|
//  +-----------------------------------------------------------------------------------------------------------------------+

// Match Velocity Closest ---------------------------------------------------------------------------------------------------
            case 0x29:

                goto LOOPEND;

// Match Velocity -----------------------------------------------------------------------------------------------------------
            case 0x3a:

                goto LOOPEND;

            case 0x3b:
// Flee ---------------------------------------------------------------------------------------------------------------------
                ship.low_ai.Flee();
                goto LOOPEND;

            case 0x3c:
// Idle ---------------------------------------------------------------------------------------------------------------------
                ship.low_ai.Idle();
                goto LOOPEND;

            case 0x3d:
// Attack -------------------------------------------------------------------------------------------------------------------

                goto LOOPEND;

            case 0x3e:
// TurretAttack -------------------------------------------------------------------------------------------------------------

                goto LOOPEND;

            case 0x3f:
// Control ------------------------------------------------------------------------------------------------------------------
                if (parentObject is Ship)
                {
                    SceneGlobals.Player = parentObject as Ship;
                }
                goto LOOPEND;

            default: goto LOOPEND;
            }
            LOOPEND :;
        }
    }