Beispiel #1
0
    // 碰到相克的方块后撤退
    void ChangeBlock()
    {
        GameObject      newObject = Instantiate <GameObject>(changeBlock, initBlockPos, Quaternion.identity, transform.parent);
        string          partten   = @"\s.*";
        MatchCollection match     = Regex.Matches(name, partten);
        string          order     = null;

        if (match.Count > 0)
        {
            order = match[0].ToString();
        }
        newObject.name = changeBlock.name + order;
        gameManagerInstance.AddPointToList(gameObject, gameManagerInstance.JigsawBoard);
        Destroy(this.gameObject);

        SaveMove(true, newObject.name, gameManagerInstance.JigsawBoard, gameManagerInstance.pickupBoard);
    }
Beispiel #2
0
    void UndoMove(MoveInf move)
    {
        GameObject block;

        if (move.isChanged)
        {
            GameObject preBlock     = relayBoard.transform.Find(move.blockName).gameObject;
            Vector3    iniPos       = preBlock.GetComponent <blockController>().initBlockPos;
            GameObject blockPrefabs = preBlock.GetComponent <blockController>().changeBlock;
            block = GameObject.Instantiate(blockPrefabs, iniPos, Quaternion.identity, preBlock.transform.parent);
            GameObject.Destroy(preBlock);
            block.GetComponent <blockController>().isChanged = false;
            string          partten = @"\s.*";
            MatchCollection match   = Regex.Matches(preBlock.name, partten);
            string          order   = null;
            if (match.Count > 0)
            {
                order = match[0].ToString();
            }
            block.name = blockPrefabs.name + order;
        }
        else
        {
            block = relayBoard.transform.Find(move.blockName).gameObject;
        }
        blockController controller = block.GetComponent <blockController>();

        if (move.endBoard == manager.JigsawBoard)
        {
            manager.AddPointToList(block, manager.JigsawBoard);
            controller.isAtJigsawBoard = false;
        }
        else
        {
            controller.isAtJigsawBoard = true;
        }
        block.transform.position    = move.sourPos;
        block.transform.eulerAngles = move.sourRoa;
        if (move.sourBoard == manager.JigsawBoard)
        {
            manager.DeletePointFromList(block, manager.JigsawBoard);
            controller.isAtJigsawBoard = true;
        }
        else
        {
            controller.isAtJigsawBoard = false;
        }
    }