Пример #1
0
    public GameObject SpawnNode(float x, float y, type_node_value number, int inNodeIndex, SpawnInfo inSpawnInfo)
    {
        GameObject    node;
        Transform     tr;
        NodeComponent nodeComp;

        switch (number)
        {
        case type_node_value.type_node_value_1:
            node = Instantiate(nodePrefabNumber1, new Vector3(x, y, 0.0f), Quaternion.identity);

            nodes.Add(node);
            tr          = node.GetComponent <Transform>();
            tr.position = new Vector3(x, y, 0.0f);
            //                tr.transform.parent = this.transform;

            nodeComp = node.GetComponent <NodeComponent>();
            nodeComp.SetNodeIndex(inNodeIndex);
            nodeComp.SetLoop(loop);

            inSpawnInfo.AddNodeIndex(inNodeIndex);

            return(node);

        case type_node_value.type_node_value_2:
            node = Instantiate(nodePrefabNumber2, new Vector3(x, y, 0.0f), Quaternion.identity);

            nodes.Add(node);
            tr          = node.GetComponent <Transform>();
            tr.position = new Vector3(x, y, 0.0f);
            //                tr.transform.parent = this.transform;

            nodeComp = node.GetComponent <NodeComponent>();
            nodeComp.SetNodeIndex(inNodeIndex);
            nodeComp.SetLoop(loop);

            inSpawnInfo.AddNodeIndex(inNodeIndex);

            return(node);

        case type_node_value.type_node_value_3:
            node = Instantiate(nodePrefabNumber3, new Vector3(x, y, 0.0f), Quaternion.identity);

            nodes.Add(node);
            tr          = node.GetComponent <Transform>();
            tr.position = new Vector3(x, y, 0.0f);
            //                tr.transform.parent = this.transform;

            nodeComp = node.GetComponent <NodeComponent>();
            nodeComp.SetNodeIndex(inNodeIndex);
            nodeComp.SetLoop(loop);

            inSpawnInfo.AddNodeIndex(inNodeIndex);

            return(node);

        case type_node_value.type_node_value_4:
            node = Instantiate(nodePrefabNumber4, new Vector3(x, y, 0.0f), Quaternion.identity);

            nodes.Add(node);
            tr          = node.GetComponent <Transform>();
            tr.position = new Vector3(x, y, 0.0f);
            //                tr.transform.parent = this.transform;

            nodeComp = node.GetComponent <NodeComponent>();
            nodeComp.SetNodeIndex(inNodeIndex);
            nodeComp.SetLoop(loop);

            inSpawnInfo.AddNodeIndex(inNodeIndex);

            return(node);

        case type_node_value.type_node_value_5:
            node = Instantiate(nodePrefabNumber5, new Vector3(x, y, 0.0f), Quaternion.identity);

            nodes.Add(node);
            tr          = node.GetComponent <Transform>();
            tr.position = new Vector3(x, y, 0.0f);
            //                tr.transform.parent = this.transform;

            nodeComp = node.GetComponent <NodeComponent>();
            nodeComp.SetNodeIndex(inNodeIndex);
            nodeComp.SetLoop(loop);

            inSpawnInfo.AddNodeIndex(inNodeIndex);

            return(node);

        case type_node_value.type_node_value_6:
            node = Instantiate(nodePrefabNumber6, new Vector3(x, y, 0.0f), Quaternion.identity);

            nodes.Add(node);
            tr          = node.GetComponent <Transform>();
            tr.position = new Vector3(x, y, 0.0f);
            //                tr.transform.parent = this.transform;

            nodeComp = node.GetComponent <NodeComponent>();
            nodeComp.SetNodeIndex(inNodeIndex);
            nodeComp.SetLoop(loop);

            inSpawnInfo.AddNodeIndex(inNodeIndex);

            return(node);

        case type_node_value.type_node_value_7:
            node = Instantiate(nodePrefabNumber7, new Vector3(x, y, 0.0f), Quaternion.identity);

            nodes.Add(node);
            tr          = node.GetComponent <Transform>();
            tr.position = new Vector3(x, y, 0.0f);
            //                tr.transform.parent = this.transform;

            nodeComp = node.GetComponent <NodeComponent>();
            nodeComp.SetNodeIndex(inNodeIndex);
            nodeComp.SetLoop(loop);

            inSpawnInfo.AddNodeIndex(inNodeIndex);

            return(node);

        case type_node_value.type_node_value_8:
            node = Instantiate(nodePrefabNumber8, new Vector3(x, y, 0.0f), Quaternion.identity);

            nodes.Add(node);
            tr          = node.GetComponent <Transform>();
            tr.position = new Vector3(x, y, 0.0f);
            //                tr.transform.parent = this.transform;

            nodeComp = node.GetComponent <NodeComponent>();
            nodeComp.SetNodeIndex(inNodeIndex);
            nodeComp.SetLoop(loop);

            inSpawnInfo.AddNodeIndex(inNodeIndex);

            return(node);

        case type_node_value.type_node_value_9:
            node = Instantiate(nodePrefabNumber9, new Vector3(x, y, 0.0f), Quaternion.identity);

            nodes.Add(node);
            tr          = node.GetComponent <Transform>();
            tr.position = new Vector3(x, y, 0.0f);
            //                tr.transform.parent = this.transform;

            nodeComp = node.GetComponent <NodeComponent>();
            nodeComp.SetNodeIndex(inNodeIndex);
            nodeComp.SetLoop(loop);

            inSpawnInfo.AddNodeIndex(inNodeIndex);

            return(node);

        case type_node_value.type_node_value_empty:
            node = Instantiate(nodePrefabNumberEmpty, new Vector3(x, y, 0.0f), Quaternion.identity);

            nodes.Add(node);
            tr          = node.GetComponent <Transform>();
            tr.position = new Vector3(x, y, 0.0f);
            //                tr.transform.parent = this.transform;

            nodeComp = node.GetComponent <NodeComponent>();
            nodeComp.SetNodeIndex(inNodeIndex);
            nodeComp.SetLoop(loop);

            inSpawnInfo.AddNodeIndex(inNodeIndex);

            return(node);
        }

        return(null);
    }