Coder Social home page Coder Social logo

mapgen's Introduction

MapGen

2d Map generator for tile based games built in Unity3d. Alt text

How it works

Creates 2d objects in a constricted space then uses Unity's physics engine to seperate. Once seperated, the larger 'hub' rooms are found and connected to one another. The connections are culled down to a minimum spanning tree, then a few of the culled connections are added back. Alt text

Next, create right angle hallways between connected hub rooms. The remaining rooms are checked for collision along the hallway paths. If collision is found then those rooms are added as 'hallway' rooms. Check the hallway lines for empty space along their path. If a space is found to be empty, note the point. Create 'filler' rooms from the noted empty spaces along the hallway line paths.

Legend:
  Hub rooms:      Green
  Hallway rooms:  Yellow
  Filler rooms:   Blue
  Filler points:  Red
  Hallways:       Grey

Alt text

Prerequisites

Unity 3d (MapGen was created with version 2017.1.0f3)

https://unity3d.com/

Zenject

https://github.com/modesttree/Zenject
or
https://www.assetstore.unity3d.com/en/#!/content/17758

Point Triangulation

https://github.com/adamgit/Unity-delaunay
This is outdated but works fine in this instance. Replace as required.

Installing

Install Zenject and Unity-Delaunay from prerequisites section.

Import MapGen into Unity3D project window.

Drag MapGen/mapGen (folder) into Unity project window under Scripts

Create new SceneContext object in scene

Right click on Hierarchy > Zenject > Scene Context
Add GameInstaller to SceneContext
Drag added GameInstaller to "Installers" collection on Scene Context

Create Physical helper room prefab

Create empty game object in scene.

Add Rigidbody 2D
  Freeze Rotation Z
  
Add Box Collider 2D
Add MapRoomHolder (script)

Drag newly created object to Prefab folder in Project window.
Delete from scene.

Create MapGen

Create empty game object in scene.

Add MapGen(Script)
  Drag Physical helper room prefab (Created above) onto "Physical Room" property.
  Drag a MapSettings SO (Located @ MapGen>Scriptable Objects>MapSettings) onto "Map Settings" property.

Add MapGenVisualDebugger(Script)

Add ZenjectBinding(script)
  Drag MapGen(script) on same game object to Components.

Built With

mapgen's People

Contributors

templarit avatar apac- avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.