示例#1
0
    public DragObject createElementFromPrefab(PuzzleProgrammingElement puzzleElement)
    {
        //TODO anpassungen sodass richtig erzeugt wird: Farbe etc.
        GameObject instantiated = Instantiate(getPrefabForPuzzleProgrammingElement(puzzleElement));

        instantiated.transform.position = new Vector3(puzzleElement.positionX, puzzleElement.positionY, puzzleElement.positionZ);
        instantiated.GetComponent <DragObject>().gameBoard = gameObject;
        instantiated.GetComponent <DragObject>().setElementId(puzzleElement.id);

        if (puzzleElement.text != null && puzzleElement.text.Length > 0)
        {
            instantiated.GetComponent <DragObject>().element.descriptionText = puzzleElement.text;
        }

        instantiated.GetComponent <DragObject>().isLocked = puzzleElement.isLocked;

        return(instantiated.GetComponent <DragObject>());
    }
示例#2
0
    private GameObject getPrefabForPuzzleProgrammingElement(PuzzleProgrammingElement puzzleProgrammingElement)
    {
        switch (puzzleProgrammingElement.type)
        {
        case "variable_filled_text":     // TODO create prefabs
            return(Resources.Load("prefabVarFilledText", typeof(GameObject)) as GameObject);

        case "variable_filled_number":     // TODO create prefabs
            return(Resources.Load("prefabVarFilledNumber", typeof(GameObject)) as GameObject);

        case "variable_filled_bool":     // TODO create prefabs
            return(Resources.Load("prefabVarFilledBool", typeof(GameObject)) as GameObject);

        case "interval_filled":     // TODO create prefabs
            return(Resources.Load("prefabIntervalFilled", typeof(GameObject)) as GameObject);

        case "print()":
            return(Resources.Load("prefabPrintElement", typeof(GameObject)) as GameObject);

        case "variable":
            return(Resources.Load("prefabVarElement", typeof(GameObject)) as GameObject);

        case "number":
            return(Resources.Load("prefabNumberElement", typeof(GameObject)) as GameObject);

        case "text":
            return(Resources.Load("prefabTextElement", typeof(GameObject)) as GameObject);

        case "bool":
            return(Resources.Load("prefabBoolElement", typeof(GameObject)) as GameObject);

        case "for":
            return(Resources.Load("prefabForElement", typeof(GameObject)) as GameObject);

        case "while":
            return(Resources.Load("prefabWhileElement", typeof(GameObject)) as GameObject);

        case "==":
            return(Resources.Load("prefabEqualsElement", typeof(GameObject)) as GameObject);

        case "&&":
            return(Resources.Load("prefabAndElement", typeof(GameObject)) as GameObject);

        case "||":
            return(Resources.Load("prefabOrElement", typeof(GameObject)) as GameObject);

        case "!":
            return(Resources.Load("prefabNotElement", typeof(GameObject)) as GameObject);

        case "interval":
            return(Resources.Load("prefabIntervalElement", typeof(GameObject)) as GameObject);

        case "end":
            return(Resources.Load("prefabEndElement", typeof(GameObject)) as GameObject);

        case "if":
            return(Resources.Load("prefabIfElement", typeof(GameObject)) as GameObject);

        case "!=":
            return(Resources.Load("prefabNotEqualsElement", typeof(GameObject)) as GameObject);

        case "*=":
            return(Resources.Load("prefabMultiplyEqualsElement", typeof(GameObject)) as GameObject);

        default:
            throw new ArgumentOutOfRangeException("Unknown element type: " + puzzleProgrammingElement.type);
        }
    }