Ejemplo n.º 1
0
 void OnPointerUp(ScreenJoystick joystick)
 {
     Debug.Log("OnPointerUp");
     if (joystick.IsValidDrag)
     {
         if (_focusedUnit.CurrentSelectedWeapon && !_focusedUnit.CurrentSelectedWeapon.Info.Automatic)
         {
             _focusedUnit.Fire(joystick.WorldActualDisplacement);
         }
     }
 }
Ejemplo n.º 2
0
 void OnPointerUp(ScreenJoystick joystick)
 {
     Debug.Log("OnPointerUp");
     if (joystick.IsValidDrag)
     {
         if (_focusedUnit.CurrentSelectedWeapon && !_focusedUnit.CurrentSelectedWeapon.Info.Automatic)
         {
             _focusedUnit.Fire(joystick.WorldActualDisplacement);
         }
     }
 }
Ejemplo n.º 3
0
 public void Init(Unit unit, Camera controlCamera, JoystickFeedbackGizmo feedbackGizmo, StraightWeaponGizmo straightWeaponGizmo)
 {
     _focusedUnit   = unit;
     _feedbackGizmo = feedbackGizmo;
     _joystick      = GetComponent <ScreenJoystick>();
     _joystick.Init(controlCamera);
     _joystick.GetWorldDragStartPointMethod = () => unit.Position;
     _joystick.OnPointerStayEvent           = OnPointerStay;
     _joystick.OnPointerUpEvent             = OnPointerUp;
     _feedbackGizmo.Init(_joystick, unit.transform);
     straightWeaponGizmo.Init(_joystick, _focusedUnit);
 }
Ejemplo n.º 4
0
 public void Init(Unit unit, Camera controlCamera, JoystickFeedbackGizmo feedbackGizmo)
 {
     _focusedUnit = unit;
     _feedbackGizmo = feedbackGizmo;
     _joystick = GetComponent<ScreenJoystick>();
     _joystick.Init(controlCamera);
     _joystick.GetWorldDragStartPointMethod = () => unit.Position;
     _joystick.OnPointerDownEvent = OnPointerDown;
     _joystick.OnPointerStayEvent = OnPointerStay;
     _joystick.OnPointerUpEvent = OnPointerUp;
     _feedbackGizmo.Init(_joystick, unit.transform);
 }
Ejemplo n.º 5
0
 void OnPointerStay(ScreenJoystick joystick)
 {
     var worldAimingDisplacement = joystick.WorldAimingDisplacement;
     if (worldAimingDisplacement != Vector3.zero) _focusedUnit.transform.forward = worldAimingDisplacement;
     if (joystick.State == ScreenJoystick.StateEnum.ValidDragging)
     {
         if (_focusedUnit.CurrentSelectedWeapon && _focusedUnit.CurrentSelectedWeapon.Info.Automatic)
         {
             _focusedUnit.Fire(joystick.WorldActualDisplacement);
         }
     }
 }
Ejemplo n.º 6
0
 void OnPointerUp(ScreenJoystick joystick)
 {
     Debug.Log("OnPointerUp");
     if (joystick.IsValidDrag)
     {
         var index = PickupSelectedSite(joystick.WorldActualDisplacement);
         if (index >= 0)
         {
             var site = SortArray[index].GetBunkerSite(BattleEngine.Instance.BunkerList);
             _focusedUnit.SetDestination(site);
         }
     }
 }
Ejemplo n.º 7
0
    void OnPointerStay(ScreenJoystick joystick)
    {
        var worldAimingDisplacement = joystick.WorldAimingDisplacement;

        if (worldAimingDisplacement != Vector3.zero)
        {
            _focusedUnit.transform.forward = worldAimingDisplacement;
        }
        if (joystick.State == ScreenJoystick.StateEnum.ValidDragging)
        {
            if (_focusedUnit.CurrentSelectedWeapon && _focusedUnit.CurrentSelectedWeapon.Info.Automatic)
            {
                _focusedUnit.Fire(joystick.WorldActualDisplacement);
            }
        }
    }
Ejemplo n.º 8
0
    void OnPointerDown(ScreenJoystick joystick)
    {
        Debug.Log("OnPointerDown");
        _lastHighlightSite = null;
        SortNearbySites();
        var allBunkerList = BattleEngine.Instance.BunkerList;

        foreach (var bunker in allBunkerList)
        {
            bunker.Gizmo.HideAndDehighlightAllSiteButtons();
        }
        for (int i = 0; i < SortedCount; i++)
        {
            var e = SortArray[i];
            allBunkerList[e.BunkerIndex].Gizmo.ShowHideSiteButton(e.SiteIndex, true);
        }
    }
Ejemplo n.º 9
0
    void OnPointerStay(ScreenJoystick joystick)
    {
        if (joystick.IsValidDrag)
        {
            //肯定已经SortNearbySites()过了。当然如果在移动中,可能需要重新计算
            var index = PickupSelectedSite(joystick.WorldActualDisplacement);
            if (index >= 0)
            {
                var site = SortArray[index].GetBunkerSite(BattleEngine.Instance.BunkerList);
                if (site != _lastHighlightSite)
                {
                    var allBunkerList = BattleEngine.Instance.BunkerList;
                    for (int i = 0; i < SortedCount; i++)
                    {
                        var e = SortArray[i];
                        allBunkerList[e.BunkerIndex].Gizmo.HighlightAllSiteButtons(false);
                    }

                    _lastHighlightSite = site;
                    var gizmo = site.Bunker.Gizmo;
                    gizmo.HighlightSiteButton(site.ID, true);
                }
            }
        }
        else
        {
            if (_lastHighlightSite)
            {
                var allBunkerList = BattleEngine.Instance.BunkerList;
                for (int i = 0; i < SortedCount; i++)
                {
                    var e = SortArray[i];
                    allBunkerList[e.BunkerIndex].Gizmo.HighlightAllSiteButtons(false);
                }
                _lastHighlightSite = null;
            }
        }
    }
Ejemplo n.º 10
0
 public void Init(ScreenJoystick joystick, Unit unit)
 {
     Joystick = joystick;
     _focusUnit = unit;
 }
 public void Init(ScreenJoystick joystick, Transform centerObject)
 {
     Joystick     = joystick;
     CenterObject = centerObject;
 }
Ejemplo n.º 12
0
 void OnPointerUp(ScreenJoystick joystick)
 {
     Debug.Log("OnPointerUp");
     if (joystick.IsValidDrag)
     {
         var index = PickupSelectedSite(joystick.WorldActualDisplacement);
         if (index >= 0)
         {
             var site = SortArray[index].GetBunkerSite(BattleEngine.Instance.BunkerList);
             _focusedUnit.SetDestination(site);
         }
     }
 }
Ejemplo n.º 13
0
    void OnPointerStay(ScreenJoystick joystick)
    {
        if (joystick.IsValidDrag)
        {
            //肯定已经SortNearbySites()过了。当然如果在移动中,可能需要重新计算
            var index = PickupSelectedSite(joystick.WorldActualDisplacement);
            if (index >= 0)
            {
                var site = SortArray[index].GetBunkerSite(BattleEngine.Instance.BunkerList);
                if (site != _lastHighlightSite)
                {
                    var allBunkerList = BattleEngine.Instance.BunkerList;
                    for (int i = 0; i < SortedCount; i++)
                    {
                        var e = SortArray[i];
                        allBunkerList[e.BunkerIndex].Gizmo.HighlightAllSiteButtons(false);
                    }

                    _lastHighlightSite = site;
                    var gizmo = site.Bunker.Gizmo;
                    gizmo.HighlightSiteButton(site.ID, true);
                }
            }
        }
        else
        {
            if (_lastHighlightSite)
            {
                var allBunkerList = BattleEngine.Instance.BunkerList;
                for (int i = 0; i < SortedCount; i++)
                {
                    var e = SortArray[i];
                    allBunkerList[e.BunkerIndex].Gizmo.HighlightAllSiteButtons(false);
                }
                _lastHighlightSite = null;
            }
        }
    }
Ejemplo n.º 14
0
 void OnPointerDown(ScreenJoystick joystick)
 {
     Debug.Log("OnPointerDown");
     _lastHighlightSite = null;
     SortNearbySites();
     var allBunkerList = BattleEngine.Instance.BunkerList;
     foreach (var bunker in allBunkerList)
     {
         bunker.Gizmo.HideAndDehighlightAllSiteButtons();
     }
     for (int i = 0; i < SortedCount; i++)
     {
         var e = SortArray[i];
         allBunkerList[e.BunkerIndex].Gizmo.ShowHideSiteButton(e.SiteIndex, true);
     }
 }
Ejemplo n.º 15
0
 public void Init(ScreenJoystick joystick, Unit unit)
 {
     Joystick   = joystick;
     _focusUnit = unit;
 }