Example #1
0
 public void RemoveActionEvent(ToolEvent eve)
 {
     if (mGather.mTActions != null)
     {
         mGather.mTActions.Remove(eve);
     }
 }
Example #2
0
    public override void LeftDrag(ToolEvent te)
    {
        if (GlobalData.IsInPlayMode() || !m_LeftBusy)
        {
            return;
        }

        PaintHelper(te, GlobalData.GetSelectedPrimaryTile());
    }
Example #3
0
    public override void RightDrag(ToolEvent te)
    {
        if (GlobalData.IsInPlayMode() || !m_RightBusy)
        {
            return;
        }

        PaintHelper(te, GlobalData.GetSelectedSecondaryTile());
    }
Example #4
0
    public override void LeftDrag(ToolEvent te)
    {
        if (GlobalData.IsInPlayMode() || !m_LeftBusy)
        {
            return;
        }

        DragHelper(te);
    }
Example #5
0
    public void UpdateRightDrag(ToolEvent te)
    {
        if (m_ActiveTool.m_ToolID == Tools.HAND)
        {
            return;
        }

        OnRightDrag(te);
    }
Example #6
0
    public override void RightPointerUp(ToolEvent te)
    {
        if (GlobalData.IsInPlayMode() || !m_RightBusy)
        {
            return;
        }

        m_RightBusy = false;
        PointerUpHelper(te.GridIndex, GlobalData.GetSelectedSecondaryTile());
    }
Example #7
0
    public override void LeftPointerUp(ToolEvent te)
    {
        if (GlobalData.IsInPlayMode() || !m_LeftBusy)
        {
            return;
        }

        m_LeftBusy = false;
        EndBatch();
    }
Example #8
0
 public void AddActionEvent(ToolEvent eve)
 {
     if (mGather.mTActions == null)
     {
         mGather.mTActions = eve;
     }
     else
     {
         mGather.mTActions.Add(eve);
     }
 }
Example #9
0
    public override void RightPointerDown(ToolEvent te)
    {
        if (GlobalData.IsInPlayMode() || m_LeftBusy || m_RightBusy)
        {
            return;
        }

        m_RightBusy = true;
        BeginBatch();
        PaintHelper(te, GlobalData.GetSelectedSecondaryTile());
    }
Example #10
0
 internal void RemoveEvent(ToolEvent call)
 {
     if (call != null)
     {
         HandleEvent he  = null;
         string      key = call.GetName();
         if (mImEvents.TryGetValue(key, out he))
         {
             he.RemoveActionEvent(call);
         }
     }
 }
Example #11
0
    void LeftHelper(ToolEvent te)
    {
        // if we're in play mode, scram
        if (GlobalData.IsInPlayMode())
        {
            return;
        }

        var primaryTileType = GetTileTypeFromEvent(te);

        GlobalData.SetPrimarySelectedTile(primaryTileType);
    }
Example #12
0
    public override void LeftPointerDown(ToolEvent te)
    {
        // update the pointer down position --
        // this will be used as the minBounds for the outliner

        m_vecPointerDownPosition    = te.GridIndex;
        m_vecPointerDragEndPosition = te.GridIndex;

        SetOutlinerToDefaultColors();
        Outline();
        PrintStatusMessage();
    }
Example #13
0
        private void _AddTEvent(ToolEvent eve)
        {
            string      key = eve.GetName();
            HandleEvent he  = null;

            if (!mImEvents.TryGetValue(key, out he))
            {
                he = new HandleEvent();
                mImEvents.Add(key, he);
            }
            he.AddActionEvent(eve);
        }
Example #14
0
    //public override void RightDrag(ToolEvent te)
    //{
    //  var gridIndex = te.GridIndex;

    //  if (m_State == State.Idle)
    //  {
    //    // This... cannot be....!!!!!
    //  }
    //  else if (m_State == State.SelectingForModification)
    //  {
    //    var shouldPrint = m_PointerDragEndPosition != gridIndex;
    //    m_PointerDragEndPosition = gridIndex;

    //    Outline(m_ModificationOutliner);

    //    if (shouldPrint)
    //      PrintBoxDimensionsMessage();
    //  }
    //  else if (m_State == State.ReadyToModify)
    //  {
    //    m_PointerDragEndPosition = gridIndex;

    //    var difference = m_PointerDragEndPosition - m_PointerDownPosition;
    //    MoveAnchor(m_AnchorStartingIndex + difference);
    //  }
    //}


    public override void LeftPointerUp(ToolEvent te)
    {
        var gridIndex = te.GridIndex;

        if (m_State == State.Idle)
        {
            // This... cannot be....!!!!!
        }
        else if (m_State == State.SelectingForCreation)
        {
            m_PointerDragEndPosition = gridIndex;

            Outline(m_CreationOutliner);
            GatherSelectedElements();

            if (m_SelectedElements.Count == 0)
            {
                EnterIdle();
            }
            else
            {
                EnterPlacingAnchorPoint();
            }
        }
        else if (m_State == State.PlacingAnchorPoint)
        {
            m_AnchorIndex = gridIndex;

            EnterPlacingPathPoints();
        }
        else if (m_State == State.PlacingPathPoints)
        {
            if (m_Path.Count == 0)
            {
                return;
            }
            var currentPathPoint = m_Path[m_Path.Count - 1] - m_AnchorIndex;
            UpdateCurrentPathPoint(gridIndex);

            if (currentPathPoint != gridIndex)
            {
                PrintPathPointPositionsMessage();
            }
        }
        //else if (m_State == State.ModifyingPathPoint)
        //{
        //  // TODO: this is a terrible hack but I gotta go with it for now
        //  foreach (var icon in m_NodeIcons)
        //    Destroy(icon);

        //  EnterReadyToModify();
        //}
    }
Example #15
0
    void RightHelper(ToolEvent te)
    {
        // if we're in play mode, scram
        if (GlobalData.IsInPlayMode())
        {
            return;
        }

        var secondaryTileType = GetTileTypeFromEvent(te);

        GlobalData.SetSecondarySelectedTile(secondaryTileType);
    }
Example #16
0
    public override void RightPointerDown(ToolEvent te)
    {
        if (GlobalData.IsInPlayMode() || m_LeftBusy || m_RightBusy)
        {
            return;
        }

        m_RightBusy = true;
        BeginBatch();
        m_StartIndex = te.GridIndex;
        DragHelper(te);
        PrintStatusMessage();
    }
Example #17
0
    void DragHelper(ToolEvent te)
    {
        // outline
        var shouldPrint = m_EndIndex != te.GridIndex;

        m_EndIndex = te.GridIndex;
        Outline();

        if (shouldPrint)
        {
            PrintStatusMessage();
        }
    }
Example #18
0
    public override void LeftDrag(ToolEvent te)
    {
        var shouldPrint = m_vecPointerDragEndPosition != te.GridIndex;

        // update the end position every drag
        m_vecPointerDragEndPosition = te.GridIndex;

        Outline();

        if (shouldPrint)
        {
            PrintStatusMessage();
        }
    }
Example #19
0
    private ToolEvent PrepareEvent(PointerEventData e)
    {
        var eventScreenPosition        = e.position;
        var eventScreenPositionVector3 = new Vector3(e.position.x, e.position.y, 0);
        var eventWorldPosition         = m_Camera.ScreenToWorldPoint(eventScreenPositionVector3);
        var xInt              = Mathf.RoundToInt(eventWorldPosition.x);
        var yInt              = Mathf.RoundToInt(eventWorldPosition.y);
        var gridIndex         = new Vector2Int(xInt, yInt);
        var tileWorldPosition = new Vector3(gridIndex.x, gridIndex.y, 0);

        var te = new ToolEvent();

        te.EventScreenPosition = eventScreenPosition;
        te.EventWorldPosition  = eventWorldPosition;
        te.TileWorldPosition   = tileWorldPosition;
        te.GridIndex           = gridIndex;
        te.Button      = e.button;
        te.EventCamera = m_Camera;

        return(te);
    }
Example #20
0
    // TODO: gotta fix this as ASAP as possible
    // but for now, it's borken, so I gotta comment
    // everything out

    //public override void RightPointerDown(ToolEvent te)
    //{
    //  var gridIndex = te.GridIndex;

    //  if (m_State == State.Idle)
    //  {
    //    m_PointerDownPosition = gridIndex;
    //    m_PointerDragEndPosition = gridIndex;

    //    Outline(m_ModificationOutliner);
    //    EnterSelectingForModification();
    //    PrintBoxDimensionsMessage();
    //  }
    //  else if (m_State == State.ReadyToModify)
    //  {
    //    m_PointerDownPosition = gridIndex;
    //    m_PointerDragEndPosition = gridIndex;
    //    m_AnchorStartingIndex = m_AnchorIndex;

    //    PrintAnchorPointPositionMessage();
    //  }
    //}


    public override void LeftDrag(ToolEvent te)
    {
        var gridIndex = te.GridIndex;

        if (m_State == State.Idle)
        {
            // This... cannot be....!!!!!
        }
        else if (m_State == State.SelectingForCreation)
        {
            var shouldPrint = m_PointerDragEndPosition != gridIndex;
            m_PointerDragEndPosition = gridIndex;

            Outline(m_CreationOutliner);

            if (shouldPrint)
            {
                PrintBoxDimensionsMessage();
            }
        }
        else if (m_State == State.PlacingAnchorPoint)
        {
            MoveAnchor(gridIndex);
        }
        else if (m_State == State.PlacingPathPoints)
        {
            var currentPathPoint = m_Path[m_Path.Count - 1] - m_AnchorIndex;
            UpdateCurrentPathPoint(gridIndex);

            if (currentPathPoint != gridIndex)
            {
                PrintPathPointPositionsMessage();
            }
        }
        //else if (m_State == State.ModifyingPathPoint)
        //{
        //  MovePathPoint(gridIndex);
        //}
    }
    /**
     * FUNCTION NAME: UpdateActiveTool
     * DESCRIPTION  : Update the active tool due to the camera moving in some way.
     * INPUTS       : None
     * OUTPUTS      : None
     **/
    void UpdateActiveTool()
    {
        ToolEvent te = new ToolEvent();

        //Button setting.
        if (Input.GetMouseButton((int)PointerEventData.InputButton.Left))
        {
            te.Button = PointerEventData.InputButton.Left;
        }
        else if (Input.GetMouseButton((int)PointerEventData.InputButton.Right))
        {
            te.Button = PointerEventData.InputButton.Right;
        }
        else
        {
            return;
        }

        te.EventScreenPosition = Input.mousePosition;
        Vector3 eventScreenPositionVector3 = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);

        te.EventWorldPosition = m_Camera.ScreenToWorldPoint(eventScreenPositionVector3);
        int xInt = Mathf.RoundToInt(te.EventWorldPosition.x);
        int yInt = Mathf.RoundToInt(te.EventWorldPosition.y);

        te.GridIndex         = new Vector2Int(xInt, yInt);
        te.TileWorldPosition = new Vector3(te.GridIndex.x, te.GridIndex.y, 0);

        if (te.Button == PointerEventData.InputButton.Left)
        {
            m_ToolsPalette.UpdateLeftDrag(te);
        }
        else if (te.Button == PointerEventData.InputButton.Right)
        {
            m_ToolsPalette.UpdateRightDrag(te);
        }
    }
Example #22
0
    public override void LeftPointerDown(ToolEvent te)
    {
        var gridIndex = te.GridIndex;

        if (m_State == State.Idle)
        {
            m_PointerDownPosition    = gridIndex;
            m_PointerDragEndPosition = gridIndex;

            Outline(m_CreationOutliner);
            EnterSelectingForCreation();
            PrintBoxDimensionsMessage();
        }
        else if (m_State == State.SelectingForCreation)
        {
            // This... cannot be....!!!!!
        }
        else if (m_State == State.PlacingAnchorPoint)
        {
            SetAnchor(gridIndex);
        }
        else if (m_State == State.PlacingPathPoints)
        {
            AddNewPathPoint(gridIndex);
        }
        //else if (m_State == State.ReadyToModify)
        //{
        //  var index = GetPathIndexAtGridIndex(gridIndex);

        //  if (index != null)
        //  {
        //    m_IndexBeingModified = index.Value;
        //    EnterModifyingPathPoint();
        //  }
        //}
    }
Example #23
0
 public virtual void RightPointerUp(ToolEvent te)
 {
 }
Example #24
0
 void PaintHelper(ToolEvent te, TileType tileType)
 {
     AddRequest(te.GridIndex, tileType, cloning: false);
 }
Example #25
0
 public void Remove(ToolEvent eve)
 {
     mEvent -= (((TAction <T>)eve).mEvent);
 }
Example #26
0
 public void EraseTile(ToolEvent te, Element oldTile)
 {
     EraseTileHelper(te.GridIndex, oldTile.m_GameObject);
 }
Example #27
0
 public void Add(ToolEvent eve)
 {
     mEvent += (((TAction <T>)eve).mEvent);
 }
Example #28
0
 public virtual void LeftDrag(ToolEvent te)
 {
 }
Example #29
0
 public static void Send(object sender, ToolEventArgs e)
 {
     ToolEvent?.Invoke(sender, e);
 }
Example #30
0
 public virtual void RightDrag(ToolEvent te)
 {
 }