Пример #1
0
    public void EventStart()
    {
        GameObject trapObject = Instantiate(trapPrefabs[TrapType]);//生成TrapType陷阱

        trap = trapObject.GetComponent <Trap>();
        trap.Init(TrapType);

        Vector3 pos = new Vector3(Random.Range(area[0], area[1]), Random.Range(area[2], area[3]), 0f);

        if (TrapType == 3)
        {
            pos = Vector3.zero;
        }

        trap.EnableEntity(pos);
        switch (dirNum)
        {
        case Dir.None:
            dir = Vector3.zero;  //无
            break;

        case Dir.E:
            dir = Vector3.right;  //东
            break;

        case Dir.S:
            dir = Vector3.down;  //南
            break;

        case Dir.W:
            dir = Vector3.left;  //西
            break;

        case Dir.N:
            dir = Vector3.up;  //北
            break;

        default:
            break;
        }
        trap.dir = dir;
    }