Example #1
0
    public override WorldObject CreateWorldObject(Transform transform = null)
    {
        GenerationRandom genRan = new GenerationRandom(WorldPosition.GetHashCode() * 13);
        int count = genRan.RandomInt(2, 5);

        WorldObject r1 = null;

        for (int i = 0; i < count; i++)
        {
            Vector3 pos   = genRan.RandomVector3(-MaxSize, MaxSize, (i) * 0.1f, (i) * 0.2f + 0.1f, -MaxSize, MaxSize) / 100f;
            float   rSize = genRan.Random(0.5f, 1.5f);
            Rock    r     = new Rock(WorldPosition, pos, rSize);

            if (i == 0)
            {
                r1 = r.CreateWorldObject(transform);
            }
            else
            {
                WorldObject rn = r.CreateWorldObject(r1.transform);
                rn.transform.localPosition = pos;
            }
        }
        return(r1);
    }
Example #2
0
    public override WorldObject CreateWorldObject(Transform transform = null)
    {
        WorldObject baseObj = new EmptyObjectBase(WorldPosition, meta: MetaData).CreateWorldObject(transform);
        Vec2i       dir     = new Vec2i(0, 1);

        if (HasMetaData() && GetMetaData().Direction != null)
        {
            dir = GetMetaData().Direction;
        }
        WorldObjectMetaData door1Dir = new WorldObjectMetaData(direction: Vec2i.Rotate(new Vec2i(0, 1), dir));
        WorldObjectMetaData door2Dir = new WorldObjectMetaData(direction: Vec2i.Rotate(new Vec2i(0, -1), dir));

        WorldObject baseDoor   = new WoodDoor(new Vec2i(1, 0), door1Dir, onDoorOpen: OnEntityEnter).CreateWorldObject(baseObj.transform);
        WorldObject secondDoor = new WoodDoor(new Vec2i(3, 0), door2Dir, onDoorOpen: OnEntityEnter).CreateWorldObject(baseObj.transform);

        Vec2i[] rockPos = new Vec2i[] { new Vec2i(0, 0), new Vec2i(0, 1), new Vec2i(0, 2), new Vec2i(0, 3),
                                        new Vec2i(1, 3), new Vec2i(2, 3), new Vec2i(3, 3), new Vec2i(3, 3), new Vec2i(3, 2), new Vec2i(3, 1), new Vec2i(3, 0) };
        GenerationRandom genRan = new GenerationRandom(WorldPosition.x << 16 + WorldPosition.z);

        foreach (Vec2i v in rockPos)
        {
            for (int y = 0; y < 3; y++)
            {
                Rock r = new Rock(v, Vector3.up * y + new Vector3(1, 0, 1) * 0.5f, rockSize: 1.5f);
                r.SetRandom(genRan);
                r.CreateWorldObject(baseObj.transform);
            }
        }
        for (int x = 1; x < 4; x++)
        {
            for (int z = 1; z < 4; z++)
            {
                new Rock(new Vec2i(x, z), new Vector3(0, 2, 0), rockSize: 2).CreateWorldObject(baseObj.transform);
            }
        }

        return(baseObj);
    }