Inheritance: MonoBehaviour
Exemple #1
0
 public GameMode(MapGenerator Generator, String label, Vector2D minspeed, Vector2D stepspeed)
 {
     this.Generator = Generator;
     this.Label = label;
     this.MinSpeed = minspeed;
     this.StepSpeed = stepspeed;
 }
 internal AntiFlickerCapability(MapGenerator node)
     : base(node)
 {
     this.frequencyChangedEvent = new StateChangedEvent(node,
         SafeNativeMethods.xnRegisterToPowerLineFrequencyChange,
         SafeNativeMethods.xnUnregisterFromPowerLineFrequencyChange);
 }
Exemple #3
0
 public World()
 {
     Realm = new Realm();
     Renderer = new RealmRenderer(Realm);
     MapGenerator = new MapGenerator(Realm);
     Requester = new RealmRequester(Realm);
 }
 private void getManagerComponents()
 {
     mapper = GameObject.Find("ChunkManager").GetComponent<MapGenerator>();
     player = GameObject.Find("Player").GetComponent<Player>();
     trapper = GameObject.Find("TrapSpawner").GetComponent<TrapSpawner>();
     scoreText = GameObject.Find("Canvas").GetComponentInChildren<Text>();
 }
 void Start()
 {
     mapGenScript = GameObject.Find ("Map Generator").GetComponent<MapGenerator>();
     CreateBats();
     audioSource = this.GetComponent<AudioSource>();
     audioSource.Play();
 }
Exemple #6
0
 void Start()
 {
     mapgenerator = GameObject.FindGameObjectWithTag("Map").GetComponent<MapGenerator>();
     Camera.transform.position = new Vector3(0, (mapgenerator.width * 1.5f), 0);
     SpawnPlayer();
     StartCoroutine(LightsOut());
     SetIsRespawnToFalse();
 }
Exemple #7
0
 public void InitializeDecorator()
 {
     mG = transform.GetComponent<MapGenerator>();
     wallDecorationsDB = Resources.LoadAll("mapgen/walldecorations");
     floorMaterial = (Material)Resources.Load("mapgen/roomParts/MaterialsPack/Materials/floorTex");
     wallMaterial = (Material)Resources.Load("mapgen/roomParts/MaterialsPack/Materials/wallTex");
     CeilingMaterial = (Material)Resources.Load("mapgen/roomParts/MaterialsPack/Materials/ceilingTex");
 }
Exemple #8
0
 // Use this for initialization
 void Start()
 {
     mapGen = new MapGenerator(mapWidth, mapHeight, simSteps, birthLimit, deathLimit);
     if (mapGen._map != null)
     {
         DisplayMap();
     }
 }
 // Use this for initialization
 void Start()
 {
     if(this.markers == null) {
         this.markers = GameObject.Find("Markers");
     }
     mapGenScript = GameObject.Find ("Map Generator").GetComponent<MapGenerator>();
     playerController = GetComponent<PlayerController>();
 }
Exemple #10
0
    public override void Start()
    {
        base.Start();

        mapper = GameObject.Find("ChunkManager").GetComponent<MapGenerator>();
        firstChunk = mapper.getFirstChunk;
        this.gameObject.transform.position = new Vector3(firstChunk.transform.position.x, firstChunk.transform.position.y + 0.8f, -3);
    }
	void Start() {
		mapGenerator = FindObjectOfType<MapGenerator> ();

		maxViewDst = detailLevels [detailLevels.Length - 1].visibleDstThreshold;
		chunkSize = MapGenerator.mapChunkSize - 1;
		chunksVisibleInViewDst = Mathf.RoundToInt(maxViewDst / chunkSize);

		UpdateVisibleChunks ();
	}
 void Start()
 {
     playerSelectManager = GetComponent<PlayerSelectManager>();
     gameManager = GetComponent<GameManager>();
     undoManager = GetComponent<UndoManager>();
     mapGenerator = GetComponent<MapGenerator>();
     currentActionSelected = -1;
     tileColorManager = GetComponent<TileColorManager>();
 }
    public void StartMovement(MapGenerator mapGen, Direction dir)
    {
        this.mapGen = mapGen;

        GameObject spawnTile = mapGen.Tiles[mapGen.SpawnPoint.x, mapGen.SpawnPoint.y].tileGO;
        this.transform.position = spawnTile.transform.position;
        currentTile = new IntVector2(mapGen.SpawnPoint.x, mapGen.SpawnPoint.y);
        MoveInDirection(dir);
        running = true;
    }
    void Start()
    {
        counter = 0;
        counterPause = true;
        PurpleVersion pv = new PurpleVersion ();
        Debug.Log (pv.GetCurrent(0, 0, 5660));

        mg = new MapGenerator ();
        GenerateMap ();
    }
 private void AddFirstLevel()
 {
     // Load all level information from XML: map and enemies.
     MapInformation mapInformation = new MapInformation(Game);
     mapInformation.LoadMapFromXML("test map");
     MapGenerator mapGen = new MapGenerator(Game);
     TileMap map = mapGen.Generate(mapInformation, camera);
     // Create a level from that xml level information
     Level firstLevel = new Level(Game, "First Island", map, mapGen.Enemies, player);
     AddLevel(firstLevel);
 }
 public static List<AStarBitch.AStarNode> Astarfct(MapGenerator.FieldInfo[] map, int hauteur_map, int largeur_map, int start, int end)
 {
     AStarBitch asb = new AStarBitch();
     asb.haut = hauteur_map;
     asb.larg = largeur_map;
     List<AStarBitch.AStarNode> _ret = null;
     List<AStarBitch.AStarNode> _map = null;
     _map = asb.buildAStarMap(map, hauteur_map, largeur_map);
     _ret = asb.aStar(_map, hauteur_map, largeur_map, start, end);
     return _ret;
 }
    // Use this for initialization
    void Start()
    {
        player = GameObjectsList.GetPlayer();
        map = GameObjectsList.GetMapGenerator();
        map.OnPathComplete += OnPathComplete;
        MonsterVariable = GameObject.Find("MonsterVariable");
        MonsterComponent = MonsterVariable.GetComponent<Text>();

        WaveVariable = GameObject.Find("WaveVariable");
        WaveComponent = WaveVariable.GetComponent<Text>();
    }
	void Start() {
		playerEntity = FindObjectOfType<Player> ();
		playerT = playerEntity.transform;

		nextCampCheckTime = timeBetweenCampingChecks + Time.time;
		campPositionOld = playerT.position;
		playerEntity.OnDeath += OnPlayerDeath;

		map = FindObjectOfType<MapGenerator> ();
		NextWave ();
	}
Exemple #19
0
	// Use this for initialization
	void Start ()
    {
        if (PowerUpRepo.Count == 0)
        {
            Debug.Log("OI! YOU NEED TO PUT SOME POWERUPS IN THE SPAWNER!");
        }
        MG = this.GetComponent<MapGenerator>();
        if (MG == null)
        {
            Debug.Log("OMG MAP GENERATOR NOT FOUND!");
        }
	}
Exemple #20
0
 public Area(Vector3 center, Vector3 areaSize, Vector3 halfSize, ref CubeState[,,] mapState, MapGenerator map)
 {
     this.map = map;
     this.mapState = mapState;
     this.center = center;
     min = center - areaSize;
     max = center + areaSize;
     halfMin = map.PositionToIndex(center - halfSize);
     halfMin.y = 0;
     halfMax = map.PositionToIndex(center + halfSize);
     halfMax.y = mapState.GetLength(1);
 }
Exemple #21
0
    // Use this for initialization
    void Start()
    {
        mapgenerator = GameObject.FindGameObjectWithTag("Map").GetComponent<MapGenerator>();

        if (!IsRespawn)
        {
            StartCoroutine(FreezeUntilStart());
        }
        else
        {
            CanMove = true;
        }
    }
Exemple #22
0
    public static void OnWindowStartUp()
    {
        //If we are do not have right GameObject, inform user
        MapGeneratorGO = GameObject.Find("MapGenerator");
        if (MapGeneratorGO == null)
            disableTool = true;
        else
        {
            MapScript = MapGeneratorGO.GetComponent<MapGenerator>();

            if (EditorPrefs.HasKey("FolderSaveLocation"))
            {
                fileLocation = EditorPrefs.GetString("FolderSaveLocation");
                validFolder = true;
            }
        }
    }
    /*
    ////////////////////
    Initilization
    ////////////////////
    */

    void Start () {
        mainMap = GetComponentInParent<MapGenerator>();
        sol = FindObjectOfType<SunControls>();
        if (isWater == true){
            currentType = Type.Liquid;
            abundanceLevel = Abundance.Barron;
            InstanceType();
        }
        else {
            currentType = Type.Solid;
            abundanceLevel = Abundance.Empty;
            if (sol != null) { sol.Photosynthesis += UpdateAbundance; }
            InstanceType();
            setSurfaceTexture();
        }
        
    }
    void OnGUI()
    {
        GUILayout.Label ("Map Generator Variables", EditorStyles.boldLabel);

        mapGenerator = EditorGUILayout.ObjectField("Map Script Algorithm: ", mapGenerator, typeof(MapGenerator), true) as MapGenerator;
        trapsGenerator = EditorGUILayout.ObjectField("Traps Script Algorithm: ", trapsGenerator, typeof(TrapsGeneration), true) as TrapsGeneration;
        startingSets = EditorGUILayout.ObjectField("Starting Sets: ", startingSets, typeof(StartingSets), true) as StartingSets;
        seed = EditorGUILayout.IntField ("Seed: ", seed);
        maxSize = EditorGUILayout.IntField("Maximum Map Size: ", maxSize);
        minSteps = EditorGUILayout.IntField("Minimum Steps to Exit: ", minSteps);
        maxSteps = EditorGUILayout.IntField("Maximum Steps to Exit: ", maxSteps);

        if (GUILayout.Button ("Create new map!")) {
            Dictionary<Point, Chunk> map = mapGenerator.NewMap(maxSize, minSteps, maxSteps, seed);
            trapsGenerator.generateTraps(map);
            startingSets.startingGame(map);
        }
    }
    void Start()
    {
        if (player == null) {
            player = GameObject.Find ("Player").transform;
        }

        float vertExtent = Camera.main.orthographicSize;
        float horzExtent = vertExtent * Screen.width / Screen.height;

        mapGenScript = GameObject.Find ("Map Generator").GetComponent<MapGenerator>();
        maxPosition = mapGenScript.GetTilePositionInScene(new Coord(mapGenScript.width-1,mapGenScript.height-1));
        float mapX = maxPosition.x;
        float mapY = maxPosition.y;

        xMax = mapX - horzExtent;
        xMin = horzExtent - mapX;
        yMax = mapY - vertExtent;
        yMin = vertExtent - mapY;
    }
Exemple #26
0
    private void DrawEntrance(Directional entrance, ref Texture2D2 texture)
    {
        BuildingModule module = GameObject.FindObjectOfType <BuildingModule>();

        if (entrance.direction == Direction.North)
        {
            MapGenerator.AddToTexture(ref texture, entrance.Position(Depth.World), module.entrance_north);
        }
        else if (entrance.direction == Direction.East)
        {
            MapGenerator.AddToTexture(ref texture, entrance.Position(Depth.World), module.entrance_east);
        }
        else if (entrance.direction == Direction.South)
        {
            MapGenerator.AddToTexture(ref texture, entrance.Position(Depth.World), module.entrance_south);
        }
        else
        {
            MapGenerator.AddToTexture(ref texture, entrance.Position(Depth.World), module.entrance_west);
        }
    }
Exemple #27
0
    private void DrawWindow(Directional window, ref Texture2D2 texture)
    {
        BuildingModule module = GameObject.FindObjectOfType <BuildingModule>();

        if (window.direction == Direction.North)
        {
            MapGenerator.AddToTexture(ref texture, window.Position(Depth.World), module.window_north);
        }
        else if (window.direction == Direction.East)
        {
            MapGenerator.AddToTexture(ref texture, window.Position(Depth.World), module.window_east);
        }
        else if (window.direction == Direction.South)
        {
            MapGenerator.AddToTexture(ref texture, window.Position(Depth.World), module.window_south);
        }
        else
        {
            MapGenerator.AddToTexture(ref texture, window.Position(Depth.World), module.window_west);
        }
    }
    public override void OnInspectorGUI()
    {
        MapGenerator mapGen = (MapGenerator)target;

        if (DrawDefaultInspector())
        {
            if (mapGen.autoUpdate)
            {
                mapGen.drawMapInEditor();
            }
        }

        if (GUILayout.Button("Generate"))
        {
            mapGen.drawMapInEditor();
        }
        if (GUILayout.Button("Save noise"))
        {
            mapGen.saveNoise();
        }
    }
    // Places stairs connecting adjacent levels of the map.
    public void GenerateStairs(List <char[, ]> ms, List <bool> hasPlacedStairs, MapGenerator mg,
                               bool validateOnly)
    {
        SetMapGenerationVariables(mg);
        maps = ms;

        for (int currentLevel = 0; currentLevel < maps.Count; currentLevel++)
        {
            if (currentLevel > 0)
            {
                if (hasPlacedStairs[currentLevel])
                {
                    GenerateLevelStairs(GetValidatedStairs(currentLevel), currentLevel);
                }
                else if (!validateOnly)
                {
                    GenerateLevelStairs(GetPossibleStairs(currentLevel), currentLevel);
                }
            }
        }
    }
    private void GenerateMaxTaxAndGoodsToSoldCount()
    {
        List <StarObject> stars = starByName.Values.ToList();
        HashSet <MapGenerator.CellStar> cells = new HashSet <MapGenerator.CellStar>(stars.Select((s) => s.cell));
        int _maxTax;
        int _goodsToBeSoldCount;

        MapGenerator.GenerateMaxTaxAndGoodsToSoldCount(cells, this, out _maxTax, out _goodsToBeSoldCount);
        Debug.LogFormat("[Space Traders #{0}] New max tax per vessel: {1}", _moduleId, _maxTax);
        Debug.LogFormat("[Space Traders #{0}] New products count to be sold: {1}", _moduleId, _goodsToBeSoldCount);
        Debug.LogFormat("[Space Traders #{0}] Possible solutions for even minute: {1}", _moduleId, stars.Where((s) => (
                                                                                                                   s.cell.edge
                                                                                                                   )).Select((s) => (
                                                                                                                                 new {
            tax = s.cell.path.Where((p) => StarData.HasTaxOnGenerationAt(p, this)).Select((p) => p.tax).Sum(),
            name = s.cell.name
        }
                                                                                                                                 )).Where((d) => d.tax <= _maxTax).Select((d) => d.name).Join(","));
        maxTax = _maxTax;
        productsCountToBeSold = _goodsToBeSoldCount;
    }
Exemple #31
0
        private static void Init()
        {
            // Build the room's walls then carve out some floors
            //MapGenerator.CreateWalls(HUD.MapWidth, HUD.MapHeight);
            //MapGenerator.CreateFloors(1, 1, HUD.MapWidth-1, HUD.MapHeight-1);
            // Initialize an empty map
            MapGenerator.GameMap = new Map(HUD.MapWidth, HUD.MapHeight);
            // Instantiate a new map generator and
            // populate the map with rooms and tunnels
            MapGenerator mapGen = new MapGenerator();

            MapGenerator.GameMap = mapGen.GenerateMap(MapGenerator.GameMap.Width, MapGenerator.GameMap.Height, MapGenerator.MaxRooms, MapGenerator.MinRoomSize, MapGenerator.MaxRoomSize);

            HUD.InitHUD(MapGenerator.GameMap.Tiles);
            MapGenerator.LoadMap(MapGenerator.GameMap);
            //create an instance of the player
            MapGenerator.CreatePlayer();
            MapGenerator.CreateMonsters();
            // spawn some loot
            MapGenerator.CreateLoot();
        }
Exemple #32
0
    public override void OnInspectorGUI()
    {
        MapGenerator mapGen = (MapGenerator)target;

        if (DrawDefaultInspector())
        {
            if (mapGen.autoUpdate)
            {
                mapGen.DrawMapInEditor();
            }
        }
        if (GUILayout.Button("Generate"))
        {
            mapGen.DrawMapInEditor();
        }
        if (GUILayout.Button("Clear"))
        {
            mapGen.display.ClearMap();
            mapGen.display.UpdateData();
        }
    }
    public override void OnInspectorGUI()           //We override the Inspector (custom)
    {
        MapGenerator mapGen = (MapGenerator)target; //cast target to map generation

        //DrawDefaultInspector();

        if (DrawDefaultInspector())       //if any value change in the inspector
        {
            if (mapGen.autoUpdate)        // if we auto update
            {
                mapGen.DrawMapInEditor(); //we generate the map
            }
        }

        //Create the button
        if (GUILayout.Button("Generate"))
        {
            //if pressed then generate the map
            mapGen.DrawMapInEditor();
        }
    }
Exemple #34
0
    // Update is called once per frame
    void Update()
    {
        if (AllDead())
        {
            GenInfo info = GetGenInfo();
            previousScore = info.score;
            if (bestScore < info.score)
            {
                bestScore = info.score;
            }

            MapGenerator mapGenerator = GameObject.Find("Map").GetComponent <MapGenerator>();
            mapGenerator.Clear();
            mapGenerator.Create();
            NewGeneration();
            StartGameLoop();
            Camera.main.transform.position = new Vector3(7.44f, 6, 0);
        }

        UpdateUI();
    }
Exemple #35
0
        public static void Main()
        {
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight);

            DungeonMap = mapGenerator.CreateMap();

            string fontFileName = "terminal8x8.png";
            string consoleTitle = "RougeLikeGame - Level 1";


            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 8, 8, 1f, consoleTitle);

            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;
            _rootConsole.Run();
        }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        MapGenerator mapGenerator = target as MapGenerator;

        if (GUILayout.Button("Generate"))
        {
            if (mapGenerator)
            {
                mapGenerator.Generate();
            }
        }

        if (GUILayout.Button("Clear"))
        {
            if (mapGenerator)
            {
                mapGenerator.TileListClear();
            }
        }
    }
Exemple #37
0
    void Start()
    {
        foreach (SpawnRect rect in spawnRects)
        {
            rect.SetOwner(transform);
        }

        PoolManager.instance.CreatePool(enemy.gameObject, 30);
        playerEntity = FindObjectOfType <Player>();
        playerT      = playerEntity.GetComponent <Transform>();

        playerEntity.OnDeath += OnPlayerDeath;
        //
        NextWave();

        mapGen = FindObjectOfType <MapGenerator>();

        SpawnPatrolEnemes();
        //
        gameUI = FindObjectOfType <GameUI>();
    }
    void Start()
    {

        /*if (useRandomSeed)
            seed = Time.time.ToString();
        map.MapGenerator.GenerateMap(seed);
        mapGenerator = Instantiate(mapGenerator, transform.position, transform.rotation) as GameObject;
        mapGenerator = mapGenerator.GetComponent<MapGenerator>();*/

        mapGen = map.GetComponent<MapGenerator>();
        if (useRandomSeed)
            seed = Time.time.ToString();
        mapGen.GenerateMap(seed);

        playerSpawn = mapGen.FindStartArea();
        Instantiate(player, playerSpawn, Quaternion.identity);

        //exitSpawn = mapGen.FindEndArea();
        //Instantiate(exit, exitSpawn, Quaternion.identity)

    }
Exemple #39
0
    private IEnumerator InstantiateFromNSecond(float seconds)
    {
        while (true)
        {
            yield return(new WaitForSeconds(seconds));

            GameObject   Scripts      = GameObject.Find("Scripts");
            MapGenerator mapGenerator = Scripts.GetComponent <MapGenerator>();
            grid = mapGenerator.grid;

            RoadTemplates road = GetComponentInParent <RoadTemplates>();
            J = Mathf.Abs((int)road.transform.position.x) / mapGenerator.GetRoadSize;
            I = Mathf.Abs((int)road.transform.position.z) / mapGenerator.GetRoadSize;

            Vehicule tmpCar = cars[Random.Range(0, cars.Length)].GetComponent <Vehicule>();
            tmpCar.PathNode = new List <Node>();
            getNodesFromMap(tmpCar, I, J);
            var SpawnPoint = gameObject.transform.Find("SpawnPoint");
            Instantiate(tmpCar, SpawnPoint.position, Quaternion.identity);
        }
    }
Exemple #40
0
        public void StartGame(IGameConfiguration game)
        {
            GameConfig = game;

            while (!MapGenerator.Generate(GameConfig, _map, _gem, out _squads))
            {
                _gem.KillAll();
                _map.ClearMap();

                (GameConfig as GameConfiguration).RandomSeed += 1;
            }

            _squads.ForEach(s => s.Deck.MaximumHandSize = cardsHandMaximumSize);

            TurnNumber    = 0;
            TurnEnded     = true;
            _nextTurnData = null;

            Debug.Log($"[GameManager] Starting game! id: {GameConfig.ServerId}");
            _bus.Publish(new GameStartedMessage(this));
        }
    // Use this for initialization
    void Start()
    {
        mapGenerator = GameObject.Find("MapGenerator").GetComponent <MapGenerator>();
        if (mapGenerator == null)
        {
            throw new NullReferenceException("No MapGenerator found! - DepthArrowHandler");
        }

        playerControl = GameObject.Find("Player").GetComponent <PlayerControl>();
        if (playerControl == null)
        {
            throw new NullReferenceException("No PlayerControl found! - DepthArrowHandler");
        }

        worldHeight = mapGenerator.GetWorldHeight;
        depthArrow  = GameObject.Find("DepthArrow");
        if (depthArrow == null)
        {
            throw new NullReferenceException("No DepthArrow found! - DepthArrowHandler");
        }
    }
    // Use this for initialization
    void Start()
    {
        job_queue        = new SimplePriorityQueue <Job>();
        in_progress_jobs = new List <Job>();
        item_yield_stats = GetComponent <ItemYieldStats>();

        var pauser = GameObject.Find("GamePauser");

        pause_game_control = pauser.GetComponent <PauseGame>();

        var info_panel = GameObject.Find("InfoPanel");

        info_panel_manager = info_panel.GetComponent <InfoPanelManager>();

        GameObject map_gen_game_object = GameObject.Find("MapGenerator");

        if (map_gen_game_object != null)
        {
            map_generator = map_gen_game_object.GetComponent <MapGenerator>();
        }
    }
Exemple #43
0
    private void Awake()
    {
        if (_singleton == null)
        {
            _singleton = this;

            _spawnedMapChunks    = new List <GameObject>();
            _spawnedWorldMarkers = new List <Transform>();
            _spawnedWaypoints    = new List <Transform>();
            _renderedMapChunks   = new Dictionary <Vector2, TextureSave>();
            _worldMarkers        = new Dictionary <Vector3, WorldMarker>();

            _centerMapScaleVector = new Vector3(_centerMapScale, _centerMapScale, _centerMapScale);

            _centerTwiceTimer = new Timer(_timePressTwiceToLockCenter);
        }
        else
        {
            Destroy(_parentCanvas.gameObject);
        }
    }
Exemple #44
0
        public static void Main()
        {
            MessageLog       = new MessageLog();
            CommandSystem    = new CommandSystem();
            SchedulingSystem = new SchedulingSystem();

            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);
            MessageLog.Add($"Level created with seed {seed}");

            //this must be the exact name of the bitmap font file we are using
            var fontFileName = "terminal8x8.png";
            //this title will appear at the top of the console window
            var consoleTitle = "Roguesharp Tutorial - Level 1 - Seed {seed}";

            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 8, 8, 1f, consoleTitle);


            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.updatePlayerFieldOfView();
            MessageLog.Add($"Map generated and player added");


            // Initialize the sub consoles that we will Blit to the root console
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);
            //set up a handler for the update event
            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;

            _currentState  = _gameStates.MainMenu;
            renderRequired = true;

            _rootConsole.Run();
        }
Exemple #45
0
    private void Start()
    {
        SaveManager.Load(this);

        TotalArea = (areaInfos.Count + bonusAreaInfos.Count) - 1;

        BonusAreaCheck();
        for (int i = 0; i < bonusAreaInfos.Count; i++)
        {
            for (int j = 0; j < bonusAreaInfos[i].StageInfos.Count; j++)
            {
                bonusAreaInfos[i].StageInfos[j].IsBonus = true;
            }
        }
        for (int i = 0; i < bonusAreaInfos.Count; i++)
        {
            RandomBonusStagesInfos[i].IsBonus = true;
        }

        if (ClearedTotalAreaCount < TotalArea)
        {
            if (!Isbonus)
            {
                CurrentArea = areaInfos[ClearedStandCount];
            }
            else
            {
                CurrentArea = bonusAreaInfos[ClearedBonusCount];
            }
        }
        else
        {
            LoadRandomStage();
        }

        mapGenerator = gameObject.AddComponent <MapGenerator>();
        stageManager.mapGenerator = mapGenerator;
        StartArea();
        BindEvent();
    }
Exemple #46
0
        public static void Main()
        {
            int seed = (int)DateTime.UtcNow.Ticks;

            random = new DotNetRandom(seed);

            string fontFileName = "Cheepicus_12x12.png";
            string consoleTitle = $"RougeSharp V3 Tutorial - Level 1 - Seed {seed}";

            // Tell RLNet to use the bitmap font that we specified and that each tile is 8 x 8 pixels
            _root_console = new RLRootConsole(fontFileName, Constants.screen_width, Constants.screen_height,
                                              12, 12, 1f, consoleTitle);

            _map_console       = new RLConsole(Constants.map_width, Constants.map_height);
            _message_console   = new RLConsole(Constants.message_width, Constants.message_height);
            _stat_console      = new RLConsole(Constants.stat_width, Constants.stat_height);
            _inventory_console = new RLConsole(Constants.inventory_width, Constants.inventory_height);

            MapGenerator map_generator = new MapGenerator(Constants.map_width, Constants.map_height, 20, 7, 13);

            dungeon_map = map_generator.CreateMap();

            dungeon_map.UpdatePlayerFOV();

            command_system = new CommandSystem();

            // Set up a handler for RLNET's Update event
            _root_console.Update += OnRootConsoleUpdate;
            // Set up a handler for RLNET's Render event
            _root_console.Render += OnRootConsoleRender;

            message_log = new MessageLog();
            message_log.Add("The rogue arrive on level 1.");

            _inventory_console.SetBackColor(0, 0, Constants.inventory_width, Constants.inventory_height, Swatch.DbWood);
            _inventory_console.Print(1, 1, "Inventory", Colours.TextHeading);

            // Begin RLNET's game loop
            _root_console.Run();
        }
Exemple #47
0
    public override void OnInspectorGUI()
    {
        MapGenerator mapGen = (MapGenerator)target;

        if (DrawDefaultInspector())
        {
            if ((mapGen.autoUpdate) && (mapGen.multithreading))
            {
                mapGen.GenerateMap();
            }
        }
        #endregion

        #region Error Control
        //error control to keep height positive and non zero
        if (mapGen.mapWidth < 1)
        {
            mapGen.mapWidth = 1;
        }
        if (mapGen.mapHeight < 1)
        {
            mapGen.mapHeight = 1;
        }
        #endregion

        #region Image Save Functionality

        if (GUILayout.Button("Save Image"))
        {
            fileName = EditorUtility.SaveFilePanel("Save a Copy of Texture", Application.dataPath, "mapimage", "png");
            mapGen.SaveImage(fileName);
        }
        #endregion
        TerrainFoldout(ref mapGen);
        NoiseFunctionFoldout(ref mapGen);
        if (GUILayout.Button("Generate"))
        {
            mapGen.GenerateMap();
        }
    }
Exemple #48
0
    private void UpdateVisableChunks()
    {
        HashSet <Vector2> alreadyUpdatedChunkCoords = new HashSet <Vector2>();

        for (int i = _visibleTerrainChunks.Count - 1; i >= 0; i--)
        {
            alreadyUpdatedChunkCoords.Add(_visibleTerrainChunks[i].Coord);
            _visibleTerrainChunks[i].UpdateTerrainChunk();
        }

        int currentChunkCoordX = Mathf.RoundToInt(_viewerPosition.x / _meshWorldSize);
        int currentChunkCoordY = Mathf.RoundToInt(_viewerPosition.y / _meshWorldSize);

        for (int yOffset = -_chunksVisableInViewDist; yOffset <= _chunksVisableInViewDist; yOffset++)
        {
            for (int xOffset = -_chunksVisableInViewDist; xOffset <= _chunksVisableInViewDist; xOffset++)
            {
                Vector2 viewedChunkCoord = new Vector2(currentChunkCoordX + xOffset, currentChunkCoordY + yOffset);

                if (!alreadyUpdatedChunkCoords.Contains(viewedChunkCoord))
                {
                    if (_terrainChunkDictionary.ContainsKey(viewedChunkCoord))
                    {
                        _terrainChunkDictionary[viewedChunkCoord].UpdateTerrainChunk();
                    }
                    else
                    {
                        TerrainChunk newChunk = new TerrainChunk(viewedChunkCoord, _heightMapSettings, _meshSettings, _detailLevelsHolder[_detailLevelIndex]._levelOfDetail, _colliderLODIndex, transform, _viewer, _mapMaterial, _biome, _textureSettings, _groundLayer);

                        //Make mapchunk
                        MapGenerator.AddChunkToMap(viewedChunkCoord);

                        _terrainChunkDictionary.Add(viewedChunkCoord, newChunk);
                        newChunk.onVisibilityChanged += OnTerrainChunkVisibilityChanged;
                        newChunk.Load();
                    }
                }
            }
        }
    }
        /// <summary>
        /// 选择了一种工具后的响应方法
        /// </summary>
        /// <param name="tool">Tool.</param>
        /// <param name="mapItem">Map item.</param>
        private void OnToolChoiceButtonClick(Consumables tool, MapItem mapItem)
        {
            QuitToolChoicePlane();

            // 背包中的工具数量-1
            player.RemoveItem(tool, 1);

            // 播放对应的音效
            SoundManager.Instance.PlayAudioClip("MapEffects/" + mapItem.audioClipName);

            Vector3      mapItemPos   = mapItem.transform.position;
            MapGenerator mapGenerator = TransformManager.FindTransform("ExploreManager").GetComponent <MapGenerator> ();

            int[,] mapWalkableInfoArray = mapGenerator.mapWalkableInfoArray;

            switch (mapItem.mapItemType)
            {
            case MapItemType.Stone:
            case MapItemType.Tree:
                (mapItem as Obstacle).DestroyObstacle(null);
                mapWalkableInfoArray [(int)mapItemPos.x, (int)mapItemPos.y] = 1;
                break;

            case MapItemType.TreasureBox:
                TreasureBox tb = mapItem as TreasureBox;
                tb.UnlockTreasureBox(null);
                mapWalkableInfoArray [(int)mapItemPos.x, (int)mapItemPos.y] = 1;
                mapGenerator.SetUpAwardInMap(tb.awardItem, mapItemPos);
                break;

            case MapItemType.Plant:
                Plant plant = mapItem as Plant;
                mapGenerator.AddMapItemInPool(mapItem.transform);
                mapWalkableInfoArray [(int)mapItemPos.x, (int)mapItemPos.y] = 1;
                mapGenerator.SetUpAwardInMap(plant.attachedItem, mapItemPos);
                break;
            }

            SetUpBottomConsumablesButtons();
        }
Exemple #50
0
    /**********************************************************************************/
    //  дропаем рандомный бонус
    //
    /**********************************************************************************/
    protected void DeployRandomBonus()
    {
        if (m_dropDescriptor.Count == 0)
        {
            Debug.LogError("m_dropDescriptor is empty!");
            return;
        }

        Base.GO_TYPE bonusType = ChoseDropType();

        // определяем место дропа
        // выбираем рандомную позицию и проверяем её на доступность
        int xMapSize = MapGenerator.GetInstance().MapSizeX;
        int yMapSize = MapGenerator.GetInstance().MapSizeY;

        Point positionToDrope = new Point(-1, -1);

        while (!PathFinder.GetInstance().ValidatePathCell(positionToDrope))
        {
            positionToDrope.x = Random.Range(0, xMapSize);
            positionToDrope.y = Random.Range(0, yMapSize);
        }

        // создаём дроп под
        Vector2    positionOutsideTheMap = new Vector2(-100, -100);
        GameObject dropPod = ObjectFactory.GetInstance().CreateGObject(positionOutsideTheMap, Base.DIREC.DOWN, Base.GO_TYPE.DROP_POD, false);
        DropPodCtr podeCtr = dropPod.GetComponent <DropPodCtr>();

        if (podeCtr == null)
        {
            Debug.LogError("podeCtr is null!");
            return;
        }

        // загружаем под полезной нагрузкой и отправляем
        podeCtr.SetDropType(bonusType);
        podeCtr.DropInPosition(positionToDrope);

        m_currentNumberOfDroppedBonus++;
    }
Exemple #51
0
    void Start()
    {
        map = new GameObject
        {
            name = "Map"
        };
        map.transform.parent = transform;

        tiles = MapGenerator.GenerateMap(width, height);
        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                Tile tile = tiles[i, j];
                if (tile.type == TileType.Wall)
                {
                    var g = Instantiate(wallTile, new Vector3(i, 0, j), Quaternion.identity);
                    g.transform.parent = map.transform;
                }
                else if (tile.type == TileType.Floor)
                {
                    var g = Instantiate(floorTile, new Vector3(i, 0, j), Quaternion.identity);
                    g.transform.parent = map.transform;
                }
            }
        }

        // Let there be light
        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                if (i % 10 == 0 && j % 10 == 0)
                {
                    var g = Instantiate(pointLight, new Vector3(i, 3, j), Quaternion.identity);
                    g.transform.parent = map.transform;
                }
            }
        }
    }
    //Perlin Noise Mesh Generation
    public static MeshData GenerateMesh(float[,] heightMap, float heightMultiplier, AnimationCurve heightCurve)
    {
        int   width    = heightMap.GetLength(0);
        int   height   = heightMap.GetLength(1);
        float topLeftX = (width - 1) / -2f;
        float topLeftZ = (height - 1) / 2f;

        GameObject   mapGen         = GameObject.Find("MapGenerator");
        MapGenerator mapGenerator   = mapGen.GetComponent <MapGenerator>();
        bool         useFlatShading = mapGenerator.useFlatShading;

        MeshData meshData    = new MeshData(width, height, useFlatShading);
        int      vertexIndex = 0;

        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                meshData.vertices[vertexIndex] = new Vector3(topLeftX + x, heightCurve.Evaluate(heightMap[x, y]) * heightMultiplier, topLeftZ - y);
                meshData.uvs[vertexIndex]      = new Vector2(x / (float)width, y / (float)height);

                if (x < width - 1 && y < height - 1)
                {
                    //triangles added in a formulaic way, imagine numbers 0 1 2 3 with 2 3 under 0 1
                    //they would be joined as 0 3 2, 3 0 1 with 0 being the index or i
                    // we know that 1 would be i + 1 and 2 would be i + width and therefore 3 would be i + width + 1
                    //So we can add these two triangles from a square using this formulae
                    meshData.AddTriangle(vertexIndex, vertexIndex + width + 1, vertexIndex + width);
                    meshData.AddTriangle(vertexIndex + width + 1, vertexIndex, vertexIndex + 1);
                }

                vertexIndex++;
            }
        }
        if (useFlatShading)
        {
            meshData.FlatShading();
        }
        return(meshData);
    }
Exemple #53
0
    private void ApplyData(SaveData data)
    {
        if (data == null)
        {
            return;
        }

        Scrap      = data.Scrap;
        Metal      = data.Metal;
        Experience = data.Experience;
        Level      = data.Level;
        Map        = data.Map;

        transform.position = new Vector3(data.PositionX, data.PositionY);

        Lasers  = data.Lasers;
        Rockets = data.Rockets;

        if (data.Ships != null)
        {
            for (int i = 0; i < data.Ships.Count; i++)
            {
                Ships[(PlayerShips)i].UpgradeHitpoints = data.Ships[i].UpgradeHitpoints;
                Ships[(PlayerShips)i].UpgradeSpeed     = data.Ships[i].UpgradeSpeed;
                Ships[(PlayerShips)i].Bought           = data.Ships[i].Bought;
                Ships[(PlayerShips)i].Used             = data.Ships[i].Used;
            }
            ChangeShip(Ships.First(o => o.Value.Used).Key, true);
        }

        SelectedAmmo = data.SelectedAmmo;

        Items = data.PlayerItems;



        MapGenerator.ChangeMap((Maps)Map);

        //Save.CheckSave(this);
    }
Exemple #54
0
        // Token: 0x06000064 RID: 100 RVA: 0x00004278 File Offset: 0x00002478
        public override void Generate(Map map, GenStepParams parms)
        {
            CellRect rectToDefend;

            if (!MapGenerator.TryGetVar <CellRect>("RectOfInterest", out rectToDefend))
            {
                rectToDefend = CellRect.SingleCell(map.Center);
            }
            Faction faction;

            if (map.ParentFaction == null || map.ParentFaction == Faction.OfPlayer)
            {
                faction = Find.FactionManager.RandomEnemyFaction(false, false, true, TechLevel.Industrial);
            }
            else
            {
                faction = map.ParentFaction;
            }
            ResolveParams resolveParams = default(ResolveParams);

            resolveParams.rect                    = this.GetOutpostRect(rectToDefend, map);
            resolveParams.faction                 = faction;
            resolveParams.edgeDefenseWidth        = new int?(0);
            resolveParams.edgeDefenseTurretsCount = new int?(Rand.RangeInclusive(0, 0));
            resolveParams.edgeDefenseMortarsCount = new int?(0);
            if (parms.siteCoreOrPart != null)
            {
                resolveParams.settlementPawnGroupPoints = new float?(parms.siteCoreOrPart.parms.threatPoints);
                resolveParams.settlementPawnGroupSeed   = new int?(OutpostSitePartUtility.GetPawnGroupMakerSeed(parms.siteCoreOrPart.parms));
            }
            else
            {
                resolveParams.settlementPawnGroupPoints = new float?(this.defaultPawnGroupPointsRange.RandomInRange);
            }
            BaseGen.globalSettings.map          = map;
            BaseGen.globalSettings.minBuildings = 28;
            BaseGen.globalSettings.minBarracks  = 4;
            BaseGen.symbolStack.Push("advancedGeneration", resolveParams);
            BaseGen.Generate();
        }
Exemple #55
0
        public Map makeMoonMap()
        {
            //Log.Message("Look at that moon!");
            WorldObjectChild_Satellite target = this.satellites.Find((WorldObjectChild_Satellite x) => !x.hasMap);

            this.satellites.Remove(target);
            Map map2 = MapGenerator.GenerateMap(new IntVec3(300, 1, 300), target, target.MapGeneratorDef, target.ExtraGenStepDefs, null);

            target.hasMap = true;
            this.satellites.Add(target);
            try
            {
                bool flag = false;
                List <WeatherDef> wdefs = DefDatabase <WeatherDef> .AllDefs.ToList();

                foreach (WeatherDef defer in wdefs)
                {
                    if (defer.defName.Equals("OuterSpaceWeather"))
                    {
                        flag = true;
                    }
                }
                if (flag)
                {
                    //Log.Message("set weather");
                    map2.weatherManager.curWeather = WeatherDef.Named("OuterSpaceWeather");
                }
                else
                {
                    //Log.Message("no weather");
                }
            }
            catch { if (Prefs.DevMode)
                    {
                        Log.Message("No space weather catch");
                    }
            }
            Find.World.WorldUpdate();
            return(map2);
        }
Exemple #56
0
        protected override void LoadContent()
        {
            new Registry();
            this.SpriteBatch = new SpriteBatch(this.GraphicsDevice);

            var data = SaveManager.Load("save");

            this.MapSeed = data?.Seed ?? new Random().Next();

            var town = this.AddMap(MapGenerator.GenerateTown(this.MapSeed, data == null));

            var villager = new Villager("Player", town, new Vector2(35.5F, 32.5F));

            town.AddObject(villager);

            var houseMap = this.AddMap(MapGenerator.GenerateHouse("House1", new Point(20, 20)));
            var house    = new VillagerHouse(0, town, new Vector2(20, 20), houseMap.Name);

            town.AddObject(house);

            if (data != null)
            {
                foreach (var map in data.Maps)
                {
                    map.Load(this.Maps);
                }
                this.Player = data.Player.Load(this.Maps);

                this.lastRealTimeUpdate = data.LastRealTimeUpdate;
                this.ForceRealTimeUpdate();
            }
            else
            {
                this.Player = new Player(town, new Vector2(22.5F, 22.5F));
                town.AddObject(this.Player);
            }

            this.Camera = new Camera(this.Player);
            this.Camera.FixPosition(this.CurrentMap);
        }
 private void Start()
 {
     mapGScript = mapGenerator.GetComponent<MapGenerator>();
     zPosition = transform.position.z * -1 - transform.localScale.z*2;
 }
Exemple #58
0
 static void Main(string[] args)
 {
     var mapGenerator = new MapGenerator();
     mapGenerator.CreateMap();
     Console.ReadKey();
 }
Exemple #59
0
        private ProductionNode CreateProductionNodeObject(IntPtr nodeHandle, NodeType? type)
        {
            lock (this)
            {
                if (!this.allNodes.ContainsKey(nodeHandle))
                {
                    if (type == null)
                    {
                        IntPtr pNodeInfo = SafeNativeMethods.xnGetNodeInfo(nodeHandle);
                        type = NodeInfo.FromNative(pNodeInfo).Description.Type;
                    }

                    ProductionNode node;

                    switch (type)
                    {
                        case NodeType.Device:
                            node = new Device(this, nodeHandle, true);
                            break;
                        case NodeType.Depth:
                            node = new DepthGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Image:
                            node = new ImageGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Audio:
                            node = new AudioGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.IR:
                            node = new IRGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.User:
                            node = new UserGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Recorder:
                            node = new Recorder(this, nodeHandle, true);
                            break;
                        case NodeType.Player:
                            node = new Player(this, nodeHandle, true);
                            break;
                        case NodeType.Gesture:
                            node = new GestureGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Scene:
                            node = new SceneAnalyzer(this, nodeHandle, true);
                            break;
                        case NodeType.Hands:
                            node = new HandsGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Codec:
                            node = new Codec(this, nodeHandle, true);
                            break;
                        case NodeType.ProductionNode:
                            node = new ProductionNode(this, nodeHandle, true);
                            break;
                        case NodeType.Generator:
                            node = new Generator(this, nodeHandle, true);
                            break;
                        case NodeType.MapGenerator:
                            node = new MapGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.ScriptNode:
                            node = new ScriptNode(this, nodeHandle, true);
                            break;
                        default:
                            throw new NotImplementedException("C# wrapper: Unknown generator type!");
                    }
                    this.allNodes[nodeHandle] = node;
                }

                return this.allNodes[nodeHandle];
            } // lock
        }
Exemple #60
0
        void AsyncGen( object sender, DoWorkEventArgs e ) {
            stopwatch = Stopwatch.StartNew();
            GC.Collect( GC.MaxGeneration, GCCollectionMode.Forced );
            Map generatedMap;
            if( tab == Tabs.Generator ) {
                MapGenerator gen = new MapGenerator( generatorArgs );
                gen.ProgressChanged +=
                    ( progressSender, progressArgs ) =>
                    bwGenerator.ReportProgress( progressArgs.ProgressPercentage, progressArgs.UserState );
                generatedMap = gen.Generate();
            } else {
                generatedMap = MapGenerator.GenerateFlatgrass( Convert.ToInt32( nFlatgrassDimX.Value ),
                                                               Convert.ToInt32( nFlatgrassDimY.Value ),
                                                               Convert.ToInt32( nFlatgrassDimZ.Value ) );
            }

            if( floodBarrier ) generatedMap.MakeFloodBarrier();
            generatedMap.CalculateShadows();
            Map = generatedMap;
            GC.Collect( GC.MaxGeneration, GCCollectionMode.Forced );
        }