Пример #1
0
    public void GenerateFrame()
    {
        dCellType tempT = dCellType.dBlock;
        int       tx = 0, ty = 0;

        while (tempT != dCellType.dFrame)
        {
            tx = Random.Range(0, MapWidth - 1);
            ty = Random.Range(0, MapHeight - 1);
            //Debug.Log(tx + ", " + ty);

            if (map[tx, ty] == dCellType.dNone)
            {
                tempT = dCellType.dFrame;
            }
        }

        map[tx, ty] = dCellType.dFrame;
        GameObject tObj = GameObject.Instantiate((GameObject)(Resources.Load("Prefabs/FramePrefab")));

        if (obj[tx, ty] == null)
        {
            obj[tx, ty] = tObj;
        }
        tObj.transform.position = new Vector3(tx * cellSize + cellSize / 2, ty * cellSize + cellSize / 2, 0);
    }
Пример #2
0
    // 载入裂缝
    public GameObject LoadSkill(dDirection dir, dCellType _t)
    {
        GameObject tem;

        if (_t == dCellType.dCrack_1)
        {
            tem = (GameObject)Resources.Load("Prefabs/crackPrefab");
            tem.GetComponent <Skill>().currentDir = dir;
            tem.GetComponent <SpriteRenderer>().sortingLayerName = "bg";
            return(tem);
        }
        else if (_t == dCellType.dCrack_2)
        {
            tem = (GameObject)Resources.Load("Prefabs/crackPrefab_2");
            tem.GetComponent <Skill>().currentDir = dir;
            tem.GetComponent <SpriteRenderer>().sortingLayerName = "bg";
            return(tem);
        }
        else if (_t == dCellType.dBlock)
        {
            tem = (GameObject)Resources.Load("Prefabs/crackPrefab_3");
            tem.GetComponent <Skill>().currentDir = dir;
            tem.GetComponent <SpriteRenderer>().sortingLayerName = "bg";
            return(tem);
        }
        else
        {
            return(null);
        }
    }
Пример #3
0
    public void Respawn(GameObject player)
    {
        dCellType tempT = dCellType.dFrame;
        int       tx = 0, ty = 0;

        while (tempT != dCellType.dNone)
        {
            tx = Random.Range(0, MapWidth - 1);
            ty = Random.Range(0, MapHeight - 1);
            //Debug.Log(tx + ", " + ty);

            if (map[tx, ty] == dCellType.dFrame)
            {
                tempT = dCellType.dFrame;
            }
            else if (map[tx, ty] == dCellType.dBlock)
            {
                tempT = dCellType.dBlock;
            }
            else if (map[tx, ty] == dCellType.dCrack_1)
            {
                tempT = dCellType.dCrack_1;
            }
            else if (map[tx, ty] == dCellType.dCrack_2)
            {
                tempT = dCellType.dCrack_2;
            }
            else if (map[tx, ty] == dCellType.dItem)
            {
                tempT = dCellType.dItem;
            }
            else if (map[tx, ty] == dCellType.dNone)
            {
                tempT = dCellType.dNone;
            }
        }


        player.transform.position = new Vector3(tx * cellSize + cellSize / 2, ty * cellSize + cellSize / 2, 0);
    }