Esempio n. 1
0
 public abstract void OnButton(string buttonName, ClickLocation mouseLocation);
Esempio n. 2
0
 public override bool OnLeftClickDown(ClickLocation click)
 {
     return(abilities.OnLeftClickDown(click));
 }
Esempio n. 3
0
 /// <summary>
 /// A shift-right click happens while the unit is selected
 /// </summary>
 /// <returns>
 /// true if the default click behaviour should be ignored. For example see "OnLeftClick"
 /// Note: Currently there is no default right-click behaviour, so it doesn't matter
 /// </returns>
 public virtual bool OnRightShiftClick(ClickLocation click)
 {
     return(false);
 }
Esempio n. 4
0
 /// <summary>
 /// A left click up happens while the unit is selected (actively selected = being the single selected
 /// object or purposefully focused in a group of selections)
 /// </summary>
 /// <returns>
 /// true if the default click behaviour should be ignored.
 /// The default is to start a drag-selection
 /// </returns>
 public virtual bool OnLeftClickDown(ClickLocation click)
 {
     return(false);
 }
Esempio n. 5
0
        private void HandleHotkeys(ClickLocation click)
        {
            // Remove selection
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                if (isSelecting)
                {
                    isSelecting = false;
                }
                else
                {
                    DeselectCurrentSelection();
                }
            }

            foreach (var buttonName in ButtonNames)
            {
                if (Input.GetButtonDown(buttonName))
                {
                    selected.ForEach(controllable => controllable.OnButton(buttonName, click));
                }
            }

            // Center Camera
            if (Input.GetKey(Hotkeys.CenterCamera) && focusedSelected != null)
            {
                cameraController.FocusOn(focusedSelected.transform.gameObject);
            }

            // Tab selection
            if (Input.GetKeyDown(Hotkeys.NextSelection) && selected.Count > 1)
            {
                var oldIndex = selected.IndexOf(focusedSelected);
                var newIndex = oldIndex + 1;
                if (focusedSelected != null)
                {
                    focusedSelected.OnSelect();
                }
                focusedSelected = selected[newIndex == selected.Count ? 0 : newIndex];
                focusedSelected.OnFocusSelect();
            }

            // Revive TODO: remove
            if (Input.GetKeyDown(KeyCode.Keypad0))
            {
                selected.ForEach(controllable => {
                    var health = controllable.transform.gameObject.GetComponent <Damageable>();
                    if (health != null)
                    {
                        health.Revive(0, 2);
                    }
                });
            }

            // Control Groups
            if (Input.GetButtonUp("Select All"))
            {
                DeselectCurrentSelection();
                AddToSelection(FindObjectsOfType <MouseControllable>().ToList(), true);
            }
            for (var i = 1; i <= 5; i++)
            {
                if (!Input.GetButtonUp("Select " + i))
                {
                    continue;
                }
                DeselectCurrentSelection();
                AddToSelection(ControlGroups[i], true);
                if (ValidDoubleTap(i))
                {
                    cameraController.FocusOn(ControlGroups[i][0].gameObject);
                }
                doubleTapGroup = i;
                doubleTapTime  = Time.time;
            }
        }
Esempio n. 6
0
 /// <summary>
 /// </summary>
 /// <param name="click">
 /// The click that caused the event
 /// </param>
 /// <returns>
 /// true if this ability is done
 /// </returns>
 public virtual bool OnLeftClickUp(ClickLocation click, GameObject caster)
 {
     return(true);
 }
Esempio n. 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="click">
 /// The click that caused the event
 /// </param>
 /// <returns>
 /// true if this ability is done
 /// </returns>
 public virtual bool OnLeftClickDown(ClickLocation click, GameObject caster)
 {
     return(false);
 }