Exemple #1
0
    private void HandleFetchTileFromPos(GD2Lib.Event p_event, object[] p_params)
    {
        if (GD2Lib.Event.TryParseArgs(out Vector3 p_pos, out TileType p_type, out string p_raisingObject, p_params))
        {
            Tile i = FindTileFromPos(p_pos);

            if (p_type == TileType.CLICKED || p_type == TileType.ATTACKED)
            {
                p_raisingObject = string.Empty;                                                            //if it was clicked, we want all objects to update their m_clickedTile
            }
            //send back the index of the given tile and dont do it if pos isnt matching any of the tile's positions
            if (m_onReturnTile != null && i.pos != Vector3.zero)
            {
                m_onReturnTile.Raise(i, p_type, p_raisingObject);
            }
            else
            {
                Debug.LogError("This is not a tile position");
            }
        }
        else
        {
            Debug.LogError("Invalid type of argument!");
        }
    }
Exemple #2
0
 //Get the tile found by the On fetch tile event
 private void HandleGetTile(GD2Lib.Event p_event, object[] p_params)
 {
     if (GD2Lib.Event.TryParseArgs(out Tile tile, p_params))
     {
         //reset current Tile before changing
         m_currentTile.isEmpty = true;
         m_currentTile         = tile;
         m_currentTile.isEmpty = false;
         //Debug.Log(m_currentTile.pos);
     }
     else
     {
         Debug.LogError("Invalid type of argument!");
     }
 }
Exemple #3
0
    private void HandleFetchTileFromIndex(GD2Lib.Event p_event, object[] p_params)
    {
        if (GD2Lib.Event.TryParseArgs(out int p_index, out TileType p_type, p_params))
        {
            //Debug.Log(p_index);

            Tile j = ReturnTileFromIndex(p_index);


            if (m_onReturnTile != null && j.pos != Vector3.zero)
            {
                m_onReturnTile.Raise(j, p_type, string.Empty);
            }
            else
            {
                Debug.LogError("Index out of bounds cant move there");
            }
        }
        else
        {
            Debug.LogError("Invalid type of argument!");
        }
    }
Exemple #4
0
    /// <summary>
    /// Get the tile found by the On fetch tile event
    /// </summary>
    private void HandleGetTile(GD2Lib.Event p_event, object[] p_params)
    {
        if (GD2Lib.Event.TryParseArgs(out Tile p_tile, out TileType p_type, out string p_raisingObject, p_params))
        {
            if (p_type == TileType.CLICKED || p_type == TileType.ATTACKED) // returned tile from clicking
            {
                //raised by the SelectionManager script
                //given by the Tilemanager .cs
                m_clickedTile = p_tile;
            }
            else if (p_type == TileType.CURRENT && p_raisingObject == gameObject.name) // the tile the object is standing on
            {
                //reset current Tile before changing
                m_currentTile.isEmpty = true;
                m_currentTile         = p_tile;
                m_currentTile.isEmpty = false;
            }
            else if (p_type == TileType.ADJACENT) //if ADJACENT we ask to update the nextTile
            {
                //Debug.Log(p_tile.pos);
                m_nextTile = p_tile;

                LookForward();
            }
            //else if(p_type == TileType.ATTACKED)
            //{
            //    // nextTile from there
            //    // and clicked tile becomes this one adjacent to the original clic


            //}
        }
        else
        {
            Debug.LogError("Invalid type of argument!");
        }
    }
Exemple #5
0
    private void HandleMovement(GD2Lib.Event p_event, object[] p_params)
    {
        if (GD2Lib.Event.TryParseArgs(out TileType p_type, p_params))
        {
            if (m_isSelected) //if this unit is selected
            {
                if (m_clickedTile.isEmpty)
                {
                    // ?
                    //Debug.Log(base.m_clickedTile.go.name);

                    MoveTo(p_type);
                }
                else
                {
                    Debug.Log("it's not empty");
                }
            }
        }
        else
        {
            Debug.LogError("Invalid type of argument!");
        }
    }