コード例 #1
0
ファイル: Selectable.cs プロジェクト: WeArePawns/Articoding
    public void OnMouseButtonDown(int index)
    {
        if (index != 0)
        {
            return;
        }
        if (!board.GetOrbitCamera().IsReset())
        {
            return;
        }

        BoardObject boardObject = Instantiate(myBoardObject, transform.position, Quaternion.identity);

        boardObject.transform.localScale = transform.lossyScale;
        Destroy(boardObject.gameObject.GetComponent <Selectable>());
        DraggableObject draggable = boardObject.gameObject.AddComponent <DraggableObject>();

        draggable.SetBoard(board);
        draggable.SetArgumentLoader(argumentLoader);
        draggable.SetCameraInput(board.GetMouseInput());
        draggable.SetOrbitCamera(board.GetOrbitCamera());

        string name = boardObject.GetName();

        TrackerAsset.Instance.setVar("element_type", name.ToLower());
        TrackerAsset.Instance.setVar("element_name", boardObject.GetNameWithIndex().ToLower());
        TrackerAsset.Instance.setVar("action", "create");
        TrackerAsset.Instance.GameObject.Interacted(boardObject.GetID());

        draggable.OnMouseButtonDown(index);
    }
コード例 #2
0
ファイル: BoardManager.cs プロジェクト: WeArePawns/Articoding
    public bool AddBoardObject(int x, int y, BoardObject boardObject)
    {
        if (IsInBoardBounds(x, y) && boardObject != null)
        {
            bool placed = board[x, y].PlaceObject(boardObject);
            if (!placed)
            {
                return(false);
            }

            if (boardObject.transform.parent != elementsParent)
            {
                boardObject.transform.SetParent(elementsParent);
                boardObject.SetBoard(this);
            }
            if (elementPositions != null)
            {
                string name = boardObject.GetNameAsLower();
                if (!elementPositions.ContainsKey(name))
                {
                    elementPositions[name] = new List <Vector2Int>();
                }

                elementPositions[name].Add(new Vector2Int(x, y));
                boardObject.SetIndex(elementPositions[name].Count);

                FollowingText text = boardObject.GetComponent <FollowingText>();
                if (text != null)
                {
                    text.SetName(boardObject.GetNameWithIndex());
                }
            }

            if (boardModifiable)
            {
                DraggableObject drag = boardObject.gameObject.GetComponent <DraggableObject>();
                if (drag == null)
                {
                    drag = boardObject.gameObject.AddComponent <DraggableObject>();
                    drag.SetBoard(this);
                    drag.SetArgumentLoader(argLoader);
                    drag.SetCameraInput(cameraInput);
                    drag.SetOrbitCamera(orbitCamera);
                    drag.SetLastPos(new Vector2Int(x, y));
                }
                drag.SetModifiable(objectsModifiable);
            }
            return(placed);
        }
        return(false);
    }