Beispiel #1
0
 void Awake()
 {
     if (instance != null)
     {
         return;
     }
     instance = this;
 }
Beispiel #2
0
 public override void Initialize()
 {
     base.Initialize();
     _buffSpawner          = new BuffSpawner();
     _specialAbilityButton = GetComponentInChildren <Button>();
     _specialAbilityButton.gameObject.SetActive(false);
     _specialAbilityButton.onClick.AddListener(TriggerSpecialAbility);
 }
Beispiel #3
0
 public override void Initialize()
 {
     base.Initialize();
     _buffSpawner = new BuffSpawner();
     _specialAbilityButton = GetComponentInChildren<Button>();
     _specialAbilityButton.gameObject.SetActive(false);
     _specialAbilityButton.onClick.AddListener(TriggerSpecialAbility);
 }
Beispiel #4
0
 private void Start()
 {
     buffSpawner = GameObject.Find("GameManager").GetComponent <BuffSpawner>();
 }
Beispiel #5
0
 void Start()
 {
     buffSpawner = BuffSpawner.instance;
     animator    = this.GetComponent <Animator>();
 }
Beispiel #6
0
 void Start()
 {
     buffSpawner   = BuffSpawner.instance;
     animator      = this.GetComponent <Animator>();
     playerAbility = gameObject.GetComponent <Abilities>();
 }
Beispiel #7
0
    /*
     * Type A : Raising, thwomp, pyramid, movingCube
     *
     * Type B : Ramp = (add trampoline ?)
     *
     * 3 configurations :
     * - 50% of 1 A, others A + B are equally distributed
     * - 30% of two A, then same as first configuration
     * - All A + B equally distributed
     */

    // density should be between like 0 and 1ish (but hey, you do you, fry your computer as much as you like)
    public override Map GenerateMap(int x, int y, float density)
    {
        Map map = new Map();

        PartsA.Shuffle();
        PartsB.Shuffle();

        List <string> TotalParts = new List <string>(PartsA);

        TotalParts.AddRange(PartsB);

        List <int> Configuration = new List <int>();

        switch (Random.Range(0, 3))
        {
        case 0:

            Configuration.Add(50);

            for (int i = 1; i < TotalParts.Count; i++)
            {
                Configuration.Add(50 / (TotalParts.Count - 1));
            }

            break;

        case 1:

            Configuration.Add(30);
            Configuration.Add(30);

            for (int i = 2; i < TotalParts.Count; i++)
            {
                Configuration.Add(40 / (TotalParts.Count - 2));
            }

            break;

        case 2:

            for (int i = 0; i < TotalParts.Count; i++)
            {
                Configuration.Add(100 / TotalParts.Count);
            }

            break;

        default:
            break;
        }

        for (int i = 0; i < Mathf.Min(TotalParts.Count, Configuration.Count); i++) // Trust nobody, not even yourself
        {
            //Debug.Log(TotalParts[i] + " : " + (((float)Configuration[i] / 100.0f) * x * y * ((float)density / 100.0f)));
            for (int nbr = 0; nbr < (((float)Configuration[i] / 100.0f) * x * y * ((float)density / 100.0f)); nbr++)
            {
                AddPartAtRandomPlace(map, TotalParts[i], x, y);
            }
        }

        for (int i = 0; i < (x * y) / 300; i++)
        {
            BuffSpawner.AddRandomBuff(map, new Vector3(Random.Range(0, x), 0.5f, Random.Range(0, y)));
        }

        return(map);
    }
Beispiel #8
0
    void Start()
    {
        Physics2D.IgnoreLayerCollision(10, 11);
        nextLevelData = new AssetProxy(typeof(NextLevelData)).LoadAsset("Objects/NextData.asset");
        gamData       = new AssetProxy(typeof(GameData)).LoadAsset("Objects/Data.asset");
        Debug.Log(nextLevelData);
        nextLevelData.GenerateNextLevelData();
        Vector2Int ms       = nextLevelData.GetMapSize();
        int        MapSizeX = ms.x;
        int        MapSizeY = ms.y;

        System.DateTime start = System.DateTime.Now;

        edgeCollider        = GetComponent <EdgeCollider2D>();
        edgeCollider.points = new Vector2[] { new Vector2(-MapSizeX / 2, -MapSizeY / 2), new Vector2(-MapSizeX / 2, MapSizeY / 2), new Vector2(MapSizeX / 2, MapSizeY / 2), new Vector2(MapSizeX / 2, -MapSizeY / 2), new Vector2(-MapSizeX / 2, -MapSizeY / 2) };
        GameMap map = new GameMap(MapSizeX, MapSizeY);

        map.ground      = GetComponentsInChildren <Tilemap>()[0];
        map.decorations = GetComponentsInChildren <Tilemap>()[1];
        map.structures  = GetComponentsInChildren <Tilemap>()[2];

        TilesetCreator tilesetCreator;

        Locations location = nextLevelData.GetLocation();

        switch (location)
        {
        case Locations.Forest:
            tilesetCreator = new ForestTilesetCreator();
            break;

        case Locations.Desert:
            tilesetCreator = new DesertTilesetCreator();
            break;

        case Locations.Village:
            tilesetCreator = new VillageTilesetCreator();
            break;

        default:
            tilesetCreator = new ForestTilesetCreator();
            break;
        }

        Tileset ts = tilesetCreator.CreateTileset();

        MapBuilder builder;

        MapType type = nextLevelData.GetMapType();

        switch (type)
        {
        case MapType.Dungeon:
            builder = new DungeonMapBuilder(new Rect(-MapSizeX / 2, -MapSizeY / 2, MapSizeX, MapSizeY), map, ts);
            break;

        case MapType.Ruins:
            builder = new RuinsMapBuilder(new Rect(-MapSizeX / 2, -MapSizeY / 2, MapSizeX, MapSizeY), map, ts);
            break;

        case MapType.Village:
            tilesetCreator = new VillageTilesetCreator();
            ts             = tilesetCreator.CreateTileset();
            builder        = new VillageMapBuilder(new Rect(-MapSizeX / 2, -MapSizeY / 2, MapSizeX, MapSizeY), map, ts);
            break;

        default:
            builder = new DungeonMapBuilder(new Rect(-MapSizeX / 2, -MapSizeY / 2, MapSizeX, MapSizeY), map, ts);
            break;
        }
        //MapBuilder builder = new VillageMapBuilder(new Rect(-MapSizeX / 2, -MapSizeY / 2, MapSizeX, MapSizeY), map);


        MapGenerator mapGen = new MapGenerator(builder);

        mapGen.Generate();
        builder.GetMap();
        Spawner spawner = new Spawner();

        spawner.Spawn(map, ts);
        BuffSpawner buffSpawner = new BuffSpawner();

        buffSpawner.Spawn(map, ts);
        System.TimeSpan timeItTook = System.DateTime.Now - start;
        Debug.Log(string.Format("Map generated, {0}", timeItTook));
    }