示例#1
0
    private static bool AddNewRoom()
    {
        //Random pick a new **non-start** room,todo
        DRoom _room = RoomPresetsManager.GetInstance().RandomPicking().GetRoomInfo();

        //DRoom _room = RoomPresetsManager.GetInstance().GetPreset(0).GetRoomInfo();

        foreach (DDoor _opendoor in m_OpeningDoorList)
        {
            foreach (DDoor _door in _room.d_DoorList)
            {
                if (_door.CheckPair(_opendoor))
                {
                    if (CheckRoom(_room, _door, _opendoor.d_ptGlobalPos))
                    {
                        RegisterNewRoom(_room, _door, _opendoor.d_ptGlobalPos);

                        return(true);
                    }
                }
            }
        }

        return(false);
    }
示例#2
0
 public static RoomPresetsManager GetInstance()
 {
     if (_inst == null)
     {
         _inst = new RoomPresetsManager();
     }
     return(_inst);
 }
示例#3
0
    //todo
    public static Stage NewMap(int times)
    {
        Clear();
        //Random pick a **start** room and register it;
        DRoom _room = RoomPresetsManager.GetInstance().RandomPicking().GetRoomInfo();

        //DRoom _room = RoomPresetsManager.GetInstance().GetPreset(0).GetRoomInfo();
        RegisterNewRoom(_room, _room.d_DoorList.First.Value, new DPointN(0, 0));

        for (int i = 0; i < times; i++)
        {
            AddNewRoom();
            if (m_OpeningDoorList.Count == 0)
            {
                Debug.Log(i);
                break;
            }
        }


        //make map

        Rect  _rct   = GetMapRect();
        Stage _stage = new Stage((int)_rct.width, (int)_rct.height);

        foreach (DSavedRoom _svroom in m_RoomList)
        {
            DRoomPreset _preset = RoomPresetsManager.GetInstance().GetPreset(_svroom.d_ID);
            if (_preset == null)
            {
                continue;
            }

            int _x = (int)_svroom.d_Rect.x - (int)_rct.x;
            int _y = (int)_svroom.d_Rect.y - (int)_rct.y;
            int _w = (int)_svroom.d_Rect.width + 1;
            int _h = (int)_svroom.d_Rect.height + 1;

            for (int i = 0; i < _w; i++)
            {
                for (int j = 0; j < _h; j++)
                {
                    int _mapPos    = (_x + i) + (_y + j) * (int)_rct.width;
                    int _presetPos = i + j * _w;

                    DCell _cell = _preset.d_Data[_presetPos];
                    if (_cell.d_bIsDoor)
                    {
                        _stage.GetMap()[_mapPos] = new DCell(0, false, true, false);
                    }
                    else
                    {
                        _stage.GetMap()[_mapPos] = _cell;
                    }
                }
            }
        }
        //Add ClosedDoors to data
        foreach (DDoor _door in m_ClosedDoorList)
        {
            int _x      = _door.d_ptGlobalPos.x - (int)_rct.x;
            int _y      = _door.d_ptGlobalPos.y - (int)_rct.y;
            int _mapPos = _x + _y * (int)_rct.width;
            _stage.GetMap()[_mapPos] = new DCell(0, true, false, false);//get data from DDoor?todo
        }

        return(_stage);
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        //         GameObject obj = new GameObject("ItemPattern");
        //         obj.AddComponent<Item>();
        //         obj.GetComponent<Item>().m_LuaScript = "ItemRangePattern";
        //         _dic = ObjectManager.getInstance().addObject(obj);
        //
        //
        //         GameObject oobj = new GameObject("ItemPattern2");
        //         oobj.AddComponent<Item>();
        //         oobj.GetComponent<Item>().m_LuaScript = "ItemMeleePattern";
        //         _dic2 = ObjectManager.getInstance().addObject(oobj);

        //Debug.Log(Resources.Load("Meshes/Shell"));

        GameObject _obj = ObjectDictionary.GetItemDic().CreateObject("ItemRangePattern",
                                                                     gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                                     Quaternion.AngleAxis(0, Vector3.up));

        ObjectDictionary.GetItemDic().CreateObject("ItemRangePattern",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));

        ObjectDictionary.GetItemDic().CreateObject("ItemPartsPattern",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));
        ObjectDictionary.GetItemDic().CreateObject("CubeAmmo",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));
        ObjectDictionary.GetItemDic().CreateObject("ItemPartsPattern",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));
        ObjectDictionary.GetItemDic().CreateObject("CubeAmmo",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));
        ObjectDictionary.GetItemDic().CreateObject("ItemPartsPattern",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));
        ObjectDictionary.GetItemDic().CreateObject("CubeAmmo",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));


        //map test
        DCell W = new DCell(0, false, true, false);
        DCell R = new DCell();
        DCell D = new DCell(0, true, false);

        DRoomPreset _room1 = new DRoomPreset();

        _room1.d_Size = new DSizeN(7, 7);
        _room1.d_Data = new DCell[]
        {
            W, W, W, D, W, W, W,
            W, R, R, R, R, R, W,
            W, R, R, R, R, R, W,
            D, R, R, R, R, R, D,
            W, R, R, R, R, R, W,
            W, R, R, R, R, R, W,
            W, W, W, D, W, W, W,
        };

        DRoomPreset _room2 = new DRoomPreset();

        _room2.d_Size = new DSizeN(5, 13);
        _room2.d_Data = new DCell[]
        {
            W, W, W, D, W,
            W, R, R, R, W,
            W, R, R, R, W,
            W, R, R, R, W,
            W, R, R, R, W,
            D, R, R, R, W,
            W, R, R, R, D,
            W, R, R, R, W,
            W, R, R, R, W,
            W, R, R, R, W,
            W, R, R, R, W,
            D, R, R, R, W,
            W, W, D, W, W,
        };

        DRoomPreset _room3 = new DRoomPreset();

        _room3.d_Size = new DSizeN(13, 5);
        _room3.d_Data = new DCell[]
        {
            W, W, D, W, W, W, W, W, D, W, W, W, W,
            W, R, R, R, R, R, R, R, R, R, R, R, W,
            W, R, R, R, R, R, R, R, R, R, R, R, W,
            D, R, R, R, R, R, R, R, R, R, R, R, D,
            W, W, W, W, W, D, W, W, W, W, W, D, W,
        };

        //RoomPresetsManager.GetInstance().AddPreset(_room1);
        //RoomPresetsManager.GetInstance().AddPreset(_room2);
        //RoomPresetsManager.GetInstance().AddPreset(_room3);
        //test
        RoomPresetsManager.GetInstance().AddPreset(mapEditor.Output.GetPresetByMap("C:/Users/FLYPLUSSS/Desktop/ZProject-dev/maps/7x7.txt"));

        Stage _stage = MapGenerator.NewMap(100);

        _stage.CreateStage();


        GameObject go = new GameObject("aaa");

        go.AddComponent(typeof(ttest));
        go.GetComponent <ttest>().tc    = new testClass();
        go.GetComponent <ttest>().tc.aa = 10;
        go.GetComponent <ttest>().tc.bb = 10;
        GameObject go2 = Instantiate(go);

        go.GetComponent <ttest>().tc.aa = 20;
        go.GetComponent <ttest>().tc.bb = 20;
        GameObject go3 = Instantiate(go);

        go.GetComponent <ttest>().tc.aa = 30;
        go.GetComponent <ttest>().tc.bb = 30;

        Debug.Log(go.GetComponent <ttest>().tc.aa);
        Debug.Log(go.GetComponent <ttest>().tc.bb);
        Debug.Log(go2.GetComponent <ttest>().tc.aa);
        Debug.Log(go2.GetComponent <ttest>().tc.bb);
        Debug.Log(go3.GetComponent <ttest>().tc.aa);
        Debug.Log(go3.GetComponent <ttest>().tc.bb);
    }
示例#5
0
    // Use this for initialization
    void Start()
    {
        //         GameObject obj = new GameObject("ItemPattern");
        //         obj.AddComponent<Item>();
        //         obj.GetComponent<Item>().m_LuaScript = "ItemRangePattern";
        //         _dic = ObjectManager.getInstance().addObject(obj);
        //
        //
        //         GameObject oobj = new GameObject("ItemPattern2");
        //         oobj.AddComponent<Item>();
        //         oobj.GetComponent<Item>().m_LuaScript = "ItemMeleePattern";
        //         _dic2 = ObjectManager.getInstance().addObject(oobj);

        //Debug.Log(Resources.Load("Meshes/Shell"));

        ObjectDictionary.GetItemDic().CreateObject("ItemRangePattern",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));

        ObjectDictionary.GetItemDic().CreateObject("ItemPartsPattern",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));
        ObjectDictionary.GetItemDic().CreateObject("CubeAmmo",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));
        ObjectDictionary.GetItemDic().CreateObject("ItemPartsPattern",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));
        ObjectDictionary.GetItemDic().CreateObject("CubeAmmo",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));
        ObjectDictionary.GetItemDic().CreateObject("ItemPartsPattern",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));
        ObjectDictionary.GetItemDic().CreateObject("CubeAmmo",
                                                   gameObject.transform.position + new Vector3(5.0f * Random.value, 0.0f, 5.0f * Random.value),
                                                   Quaternion.AngleAxis(0, Vector3.up));


        //map test
        DCell W = new DCell(0, false, true, false);
        DCell R = new DCell();
        DCell D = new DCell(0, true, false);

        DRoomPreset _room1 = new DRoomPreset();

        _room1.d_Size = new DSizeN(7, 7);
        _room1.d_Data = new DCell[]
        {
            W, W, W, D, W, W, W,
            W, R, R, R, R, R, W,
            W, R, R, R, R, R, W,
            D, R, R, R, R, R, D,
            W, R, R, R, R, R, W,
            W, R, R, R, R, R, W,
            W, W, W, D, W, W, W,
        };

        DRoomPreset _room2 = new DRoomPreset();

        _room2.d_Size = new DSizeN(5, 13);
        _room2.d_Data = new DCell[]
        {
            W, W, W, D, W,
            W, R, R, R, W,
            W, R, R, R, W,
            W, R, R, R, W,
            W, R, R, R, W,
            D, R, R, R, W,
            W, R, R, R, D,
            W, R, R, R, W,
            W, R, R, R, W,
            W, R, R, R, W,
            W, R, R, R, W,
            D, R, R, R, W,
            W, W, D, W, W,
        };

        DRoomPreset _room3 = new DRoomPreset();

        _room3.d_Size = new DSizeN(13, 5);
        _room3.d_Data = new DCell[]
        {
            W, W, D, W, W, W, W, W, D, W, W, W, W,
            W, R, R, R, R, R, R, R, R, R, R, R, W,
            W, R, R, R, R, R, R, R, R, R, R, R, W,
            D, R, R, R, R, R, R, R, R, R, R, R, D,
            W, W, W, W, W, D, W, W, W, W, W, D, W,
        };

        RoomPresetsManager.GetInstance().AddPreset(_room1);
        RoomPresetsManager.GetInstance().AddPreset(_room2);
        RoomPresetsManager.GetInstance().AddPreset(_room3);

        Stage _stage = MapGenerator.NewMap(100);

        _stage.CreateStage();
    }