Inheritance: MyBehaviour
 private void Awake()
 {
     name           = transform.name;
     gameManager    = GameObject.FindGameObjectWithTag("Manager");
     turnManager    = gameManager.GetComponent <TurnManager>();
     floorGenerator = gameManager.GetComponent <FloorGenerator>();
 }
Esempio n. 2
0
    /// <summary>
    /// Generate the floor. This creates and builds the rooms that comprise it.
    /// </summary>
    public void Generate(int floorID)
    {
        FloorID = floorID;

        // Seeds the random generator. Use the base seed for the level + the floor ID to
        // offset the seed by the floor. By doing so, we'll get a different generation
        // pattern for each successive floor in a way that is easily reproducible
        // in a save/load situation.
        Random.InitState((GameController.seed + floorID) % GameController.MaxSeed);

        generator = generators[Random.Range(0, generators.Length)];
        generator.Generate();

        // Ensure the player cannot spawn inside of walls by clearing any nearby walls.
        // TODO: We need to make sure there's no case where the player will get trapped from this.
        ClearAround(new Vec2i(5, 5));

        GameObject.FindWithTag("Player").transform.position = new Vector3(5.0f, 5.0f);
        if (firstTime)
        {
            firstTime = false;//Don't
        }
        else
        {
            GameController.Instance.AddScore(10);
        }

        Pathfinder.Generate();
        GameController.Instance.SaveGame();
    }
Esempio n. 3
0
        /// <summary>
        /// To be called with each new floor, identifies blocked tiles in the pathCounters array with
        /// a value of -1. When hero discovers hidden doors or bashes open locked doors, call this
        /// again to update the map so new routes can be plotted.
        /// </summary>
        internal static void InitializeDistanceMap()
        {
            pathCounters = new int[FloorGenerator.FloorWidth, FloorGenerator.FloorHeight];

            // DEBUG Feature
            if (GameConstants.DEBUG_MODE_DRAW_STEPS_TO_HERO)
            {
                pathCounterText = new GameText[FloorGenerator.FloorWidth, FloorGenerator.FloorHeight];
            }

            for (int x = 0; x < FloorGenerator.FloorWidth; x++)
            {
                for (int y = 0; y < FloorGenerator.FloorHeight; y++)
                {
                    pathCounters[x, y] = unmappedValue;
                    if (!FloorGenerator.TileIsPassible(FloorGenerator.GetTileAt(x, y)))
                    {
                        pathCounters[x, y] = -1;
                    }
                    // DEBUG Feature
                    if (GameConstants.DEBUG_MODE_DRAW_STEPS_TO_HERO)
                    {
                        pathCounterText[x, y] = new GameText(graphicsDevice);
                    }
                }
            }
        }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        gameOver.SetActive(false);
        win.SetActive(false);
        GameObject obj = GameObject.Find("FloorGeneratorObj");

        script = obj.GetComponent <FloorGenerator>();
        save   = GameObject.Find("Save");
        player = GameObject.Find("Blitz");

        enemysTotal = 0;
        foreach (GameObject floor in script.floor)
        {
            enemysTotal += floor.GetComponent <MapConfig>().enemysLeft;
        }

        foreach (GameObject skill in skillList)
        {
            skill.GetComponent <Skill>().purchased = false;
        }

        enemysLeft = enemysTotal;

        skillList = save.GetComponent <Save>().skillList;

        save.GetComponent <Save>().numberOfCapture = 1;
    }
Esempio n. 5
0
        /// <summary>
        /// Reveals any non-blocking tile in a straight line but stops at doors because the light in
        /// a lit room doesn't light up a hallway.
        /// </summary>
        /// <param name="startingPoint"></param>
        /// <param name="direction"></param>
        private void LightTilesInRow(Point startingPoint, GameConstants.Direction8 direction)
        {
            bool  blocked      = false;
            Point currentPoint = startingPoint;

            FloorTile.Surfaces currentSurface;
            while (!blocked)
            {
                currentSurface = FloorGenerator.GetTileAt(currentPoint);
                FloorGenerator.FloorRevealed[currentPoint.X, currentPoint.Y] = true;

                if (!FloorGenerator.TileIsPassible(currentSurface))
                {
                    blocked = true;
                }
                if (currentPoint == startingPoint)
                {
                    blocked = false; // Allows effect if standing in doorway to split both ways
                }
                if (blocked)
                {
                    break;
                }

                // Move to next tile
                currentPoint = FloorGenerator.PointInDirection(currentPoint, direction);
            }
        }
Esempio n. 6
0
	public IEnumerator Start () {
		floorGenerator = GameObject.FindGameObjectWithTag ("GameController").GetComponent<FloorGenerator> ();
		levelText = GameObject.FindGameObjectWithTag ("LevelText").GetComponent<GUIText> ();
		player = GameObject.FindGameObjectWithTag ("Player");

		// Initiate cutscene if player got to fourth level
		if (floorGenerator.level == 4) {
			cutscene = GameObject.FindGameObjectsWithTag ("cutscene");
			audioSources = GameObject.FindGameObjectWithTag("MainCamera").GetComponents<AudioSource>();
			audioSources.ElementAt(0).Stop();

			yield return new WaitForSeconds (0.5f);
			player.SetActive (false);

			showHideCutscene (true);
			yield return new WaitForSeconds (5f);
			showHideCutscene (false);
			player.SetActive (true);

			audioSources.ElementAt (0).Play ();
		}

		// If cutscenes ends, the level is shown
		levelText.enabled = true;
		levelText.text = "Level " + floorGenerator.level;
		yield return new WaitForSeconds (time);
		levelText.GetComponent<GUIText> ().enabled = false;
		yield return null;
	}
 public void Initialize()
 {
     floorGenerator = new FloorGenerator(environmentParameters);
     roomBuilder    = roomPrefab.GetComponent <RoomBuilder>();
     hasInitialized = true;
     keyController  = FindObjectOfType <KeyController>();
 }
Esempio n. 8
0
    void Awake()
    {
        instance = this;

        //gridEmptyFlags.AddRange(Enumerable.Repeat(true, gridNum[0] * gridNum[1]));

        emptyGridNumbers.AddRange(Enumerable.Range(0, gridNum[0] * gridNum[1]));
    }
 private void Awake()
 {
     Instance     = this;
     spritePool   = GetComponent <SpritePool>();
     colliderPool = GetComponent <ColliderPool>();
     generator    = new FloorGenerator(this);
     generator.Generate(RoomCount);
 }
Esempio n. 10
0
    void Awake()
    {
        instance = this;

        //gridEmptyFlags.AddRange(Enumerable.Repeat(true, gridNum[0] * gridNum[1]));

        emptyGridNumbers.AddRange(Enumerable.Range(0, gridNum[0] * gridNum[1]));
    }
Esempio n. 11
0
    private void Start()
    {
        Instance = this;

        FloorGenerator floorGen = GetComponent <FloorGenerator>();

        floorCells = floorGen.GenerateFloor();
    }
Esempio n. 12
0
        public void OnEnemyDied(Enemy enemy)
        {
            floorGenerator = GameObject.FindGameObjectWithTag("GameController").GetComponent <FloorGenerator> ();
            var audioSources = GameObject.FindGameObjectWithTag("MainCamera").GetComponents <AudioSource> ();

            if (floorGenerator.level < floorGenerator.maxLevels || _roomType == RoomType.NormalRoom)
            {
                _enemies.Remove(enemy);

                if (!ContainsEnemies)
                {
                    _doors.ForEach(d => d.IsOpen = true);
                    var doorOpenClip = _doors.First()._doorOpenClip;

                    if (doorOpenClip != null)
                    {
                        doorOpenClip.Play();
                    }

                    if (_roomType != RoomType.NormalRoom)
                    {
                        Destroy(_bossBar);

                        audioSources.ElementAt(1).Stop();
                        audioSources.ElementAt(2).Play();
                        audioSources.ElementAt(0).PlayDelayed(9.629f);

                        var levelDoor = (LevelSwitchDoor)Instantiate(_levelSwitchDoorPrefab);
                        levelDoor.transform.parent        = transform;
                        levelDoor.transform.localPosition = levelDoor.transform.position;
                    }
                    SpawnItem();
                }
            }
            else if ((_roomType == RoomType.AngelRoom) || (_roomType == RoomType.DevilRoom))
            {
                Destroy(_bossBar);
                audioSources.ElementAt(1).Stop();
                audioSources.ElementAt(2).Play();
                audioSources.ElementAt(0).PlayDelayed(9.629f);

                // Disable player
                GameObject player = GameObject.FindGameObjectWithTag("Player");
                player.GetComponent <Player> ().enabled = false;
                player.GetComponent <PlayerShootController> ().enabled = false;
                player.GetComponent <Rigidbody2D> ().isKinematic       = true;
                player.GetComponent <Animator>().Play("Idle");

                // Enemy goes to players direction
                //enemy.GetComponent<Enemy> ().enabled = true;
                enemy.GetComponent <EnemyShootController> ().enabled = false;
                enemy.GetComponent <Animator> ().Play("Dead");
                lastBossDefeated = true;
                StartCoroutine(ghostTowardsPlayer(enemy));
            }
        }
Esempio n. 13
0
    // Use this for initialization
    void Start()
    {
        GameObject obj = GameObject.Find("FloorGeneratorObj");

        scriptGenerator = obj.GetComponent <FloorGenerator>();

        gm  = GameObject.Find("Manager");
        h6  = GameObject.Find("H6");
        knn = GameObject.Find("KnnWatcher");
    }
Esempio n. 14
0
 private void Awake()
 {
     manager          = GameObject.FindGameObjectWithTag("Manager");
     myMaterial       = GetComponent <Renderer>().material;
     turnManager      = manager.GetComponentInParent <TurnManager>();
     floorGenerator   = manager.GetComponentInParent <FloorGenerator>();
     scoreKeeper      = manager.GetComponentInParent <ScoreKeeper>();
     utilityFunctions = new UtilityFunctions();
     floor            = gameObject;
 }
Esempio n. 15
0
 internal static void DrawDiscoveredMonsters(SpriteBatch spriteBatch, Rectangle tileSize, Rectangle localView)
 {
     foreach (var monster in monsters)
     {
         if (monster.Discovered || GameConstants.DEBUG_MODE_REVEAL)
         {
             monster.Draw(spriteBatch, FloorGenerator.TranslateRecToTile(tileSize, localView, monster.Location), localView);
         }
     }
 }
Esempio n. 16
0
    void Awake()
    {
        if (_instance == null)
        {
            //If I am the first instance, make me the Singleton
            _instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            //If a Singleton already exists and you find
            //another reference in scene, destroy it!
            if (this != _instance)
            {
                Destroy(this.gameObject);
            }
        }

        mapTile = new int[, ] {
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
        };

        tileWidth  = tiles[0].transform.GetComponent <Renderer> ().bounds.size.x;
        tileHeight = tiles[0].transform.GetComponent <Renderer> ().bounds.size.y;

        GenerateFloor();
    }
    // Use this for initialization
    void Start()
    {
        fl4Gen            = Maze.GetComponent <FloorGenerator>();
        fl4Gen.size.x     = 5;
        fl4Gen.size.y     = 5;
        fl4Gen.enemyLevel = 1;
        MazePos           = Maze.transform.position;
        PlayerStartPos    = player.transform.position;
        GameObject newMaze = Instantiate(Maze, MazePos, Quaternion.identity);

        newMaze.tag = "Maze";
    }
Esempio n. 18
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
     NewFloor();
 }
Esempio n. 19
0
    void Awake()
    {
        if(_instance == null)
        {
            //If I am the first instance, make me the Singleton
            _instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            //If a Singleton already exists and you find
            //another reference in scene, destroy it!
            if(this != _instance)
                Destroy(this.gameObject);
        }

        mapTile = new int[,]{
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        };

        tileWidth = tiles[0].transform.GetComponent<Renderer> ().bounds.size.x;
        tileHeight = tiles[0].transform.GetComponent<Renderer> ().bounds.size.y;

        GenerateFloor ();
    }
Esempio n. 20
0
        static void Main(string[] args)
        {
            uint[] buildCommands = new uint[8];

            /*buildCommands[0] = 0x28008000;
            *  buildCommands[1] = 0x22008000;
            *  buildCommands[2] = 0x44008000;*/


            //buildCommands[0] = 0xFFFFC400;


            //buildCommands[0] = 0xFF000000;


            buildCommands[0] = 0x48008000;
            buildCommands[1] = 0x2FF04400;
            buildCommands[2] = 0x42008000;
            buildCommands[3] = 0x2FF04400;
            buildCommands[4] = 0x42008000;
            buildCommands[5] = 0x2FF04400;
            buildCommands[6] = 0x41008000;
            buildCommands[7] = 0x2FF06400;

            FloorGenerator generator = new FloorGenerator(buildCommands, 1000000, 1, true);
            bool           noSuccess = true;

            while (noSuccess)
            {
                try
                {
                    generator.GenerateFloor();
                    noSuccess = false;
                }
                catch (NoRoomsToGenerateFromException)
                {
                    Console.WriteLine("Generation stopped because no more rooms were able to be added.");
                    Floor failedFloor = generator.GetFloor();
                    Room[,] roomsOfFailedFloor = SendFloorToArray(failedFloor);
                    PrintRooms(roomsOfFailedFloor, failedFloor.RoomCount, buildCommands, false);
                    generator.Reset();
                }
            }
            Console.WriteLine("Success!");
            Floor floor = generator.GetFloor();

            Room[,] rooms = SendFloorToArray(floor);
            PrintRooms(rooms, floor.RoomCount, buildCommands, true);
        }
Esempio n. 21
0
        static internal bool InLineOfSight(Point startPt, Point endPt, int visibleDistance)
        {
            // for each point along the path from ptA to ptB, check the floor tile
            Vector2 path           = new Vector2(endPt.X - startPt.X, endPt.Y - startPt.Y);
            Point   checkPoint     = Point.Zero;
            double  targetDistance = Math.Floor(Distance(startPt, endPt));

            if (targetDistance > visibleDistance)
            {
                return(false);
            }

            int testDistance = MathHelper.Min((int)targetDistance, visibleDistance);
            var theta        = Math.Atan2(path.Y, path.X);

            for (int d = 1; d <= testDistance; d++)
            {
                var x = d * Math.Cos(theta);
                var y = d * Math.Sin(theta);
                checkPoint.X = (int)(startPt.X + x);
                checkPoint.Y = (int)(startPt.Y + y);
                // If outside boarder, space is not LOS
                if (checkPoint.X < 0 || checkPoint.Y < 0 ||
                    checkPoint.X > FloorGenerator.FloorWidth - 1 ||
                    checkPoint.Y > FloorGenerator.FloorHeight - 1)
                {
                    return(false);
                }

                // If it's right next to you, such as monster on a door or you are on a door
                if (targetDistance <= 1)
                {
                    return(true);
                }

                // If it's a wall, void, or closed door, it's not LOS
                var tile = FloorGenerator.GetTileAt(checkPoint);
                if (!FloorGenerator.TileIsPassible(tile) ||
                    tile == FloorTile.Surfaces.OpenDoor)    // because this is also a light barrier
                {
                    return(false);
                }

                // Keep checking until end of path reached
            }
            // Remaining spaces do not block monsters from being seen
            return(true);
        }
Esempio n. 22
0
        /// <summary>
        /// Divides the algorithms for deciding how to light up an area from the scroll's effect
        /// </summary>
        private void LightSpaces()
        {
            Point startingPoint = DungeonGameEngine.Hero.Location;

            if (FloorGenerator.FloorPlan
                [startingPoint.X, startingPoint.Y] == FloorTile.Surfaces.DarkRoom)
            {
                FloorGenerator.LightRoom(startingPoint);
            }
            else
            if (FloorGenerator.FloorPlan
                [startingPoint.X, startingPoint.Y] == FloorTile.Surfaces.Tunnel)
            {
                LightTunnel();
            }
            else
            if (FloorGenerator.FloorPlan
                [startingPoint.X, startingPoint.Y] == FloorTile.Surfaces.OpenDoor)
            {
                LightTunnel();

                // Check all four sides of door to find the room tile
                if (FloorGenerator.FloorPlan
                    [startingPoint.X, startingPoint.Y + 1] == FloorTile.Surfaces.DarkRoom)
                {
                    startingPoint.Y++;
                }
                else if (FloorGenerator.FloorPlan
                         [startingPoint.X, startingPoint.Y - 1] == FloorTile.Surfaces.DarkRoom)
                {
                    startingPoint.Y--;
                }
                else if (FloorGenerator.FloorPlan
                         [startingPoint.X, startingPoint.X + 1] == FloorTile.Surfaces.DarkRoom)
                {
                    startingPoint.X++;
                }
                else if (FloorGenerator.FloorPlan
                         [startingPoint.X, startingPoint.X - 1] == FloorTile.Surfaces.DarkRoom)
                {
                    startingPoint.X--;
                }

                FloorGenerator.LightRoom(startingPoint);
            }
        }
Esempio n. 23
0
        internal void ChaseTarget()
        {
            // Find lowest path values around monster that is not occupied by another monster
            Point nextPosition = location;

            // To help randomize movements a little when several options exist with the same value
            List <Point> possibleNextSteps = new List <Point>();

            int lowestValue = int.MaxValue;

            for (int x = location.X - 1; x < location.X + 2; x++)
            {
                for (int y = location.Y - 1; y < location.Y + 2; y++)
                {
                    if (pathCounters[x, y] > 0 &&
                        pathCounters[x, y] <= lowestValue &&
                        pathCounters[x, y] < unmappedValue &&
                        FloorGenerator.TileIsPassible(FloorGenerator.GetTileAt(x, y)) &&
                        MonsterFoundAt(new Point(x, y)) == null)
                    {
                        if (pathCounters[x, y] == lowestValue)
                        {
                            possibleNextSteps.Add(new Point(x, y));
                        }
                        else
                        {
                            lowestValue = pathCounters[x, y];
                            possibleNextSteps.Clear();
                            nextPosition.X = x; nextPosition.Y = y;
                            possibleNextSteps.Add(nextPosition);
                        }
                    }
                }
            }
            // Randomly pick one of the possible steps having the same value
            if (possibleNextSteps.Count > 0)
            {
                location = possibleNextSteps[Utility.Rand.Next(possibleNextSteps.Count)];
            }



            // If path mapping disabled due to DEBUG_MODE_WALK_THROUGH_WALLS
            // then location will not change as the mapping will halt before the monster.
            CheckVisibility();
        }
Esempio n. 24
0
    // Use this for initialization
    void Start()
    {
        gameOver.SetActive(false);
        win.SetActive(false);
        GameObject obj = GameObject.Find("FloorGeneratorObj");

        script = obj.GetComponent <FloorGenerator>();

        foreach (GameObject floor in script.floor)
        {
            enemysTotal += floor.GetComponent <MapConfig>().enemysLeft;
        }

        foreach (GameObject skill in skillList)
        {
            skill.GetComponent <Skill>().purchased = false;
        }
    }
Esempio n. 25
0
    void Start()
    {
        GameMasterController.instance.startEvent();
        currentFloor = 0;
        /***/
        floorGenerator = GameObject.Find("FloorGenerator").GetComponent(typeof(FloorGenerator)) as FloorGenerator;
        player         = GameObject.FindGameObjectWithTag("Player");
        gm             = GameObject.FindGameObjectWithTag("GameBattleManager").GetComponent <GameBattleManager>();
        //setPlayerPosition();
        StartCoroutine(generateFloor());
        //prepareNextFloor();
        playerRB      = player.GetComponent <Rigidbody>();
        totalStep     = 0;
        playerLastPos = player.transform.position;

        interaction   = gameObject.GetComponent <EventHandler>();
        hasInteracted = false;
    }
Esempio n. 26
0
        internal static bool MonsterHeroMutualDetection()
        {
            bool monsterSighted = false;

            // Must cycle through each monster to trigger them to notice the hero too.
            foreach (var monster in monsters)
            {
                if (FloorGenerator.WithinSightOf(monster) && !InventoryEffectManager.HeroBlind)
                {
                    monsterSighted     = true;
                    monster.discovered = true;
                }
                if (InventoryEffectManager.HeroDetectsMonsters)
                {
                    monster.discovered = true;
                }
            }
            return(monsterSighted);
        }
Esempio n. 27
0
        internal static void DrawCounters(SpriteBatch spriteBatch, Rectangle tileSize, Rectangle currentView)
        {
            Rectangle currentDrawRectangle;

            if (GameConstants.DEBUG_MODE_DRAW_STEPS_TO_HERO)
            {
                for (int x = 1; x < FloorGenerator.FloorWidth - 1; x++)
                {
                    for (int y = 1; y < FloorGenerator.FloorHeight - 1; y++)
                    {
                        currentDrawRectangle           = FloorGenerator.TranslateRecToTile(tileSize, currentView, new Point(x, y));
                        pathCounterText[x, y].Location = new Point(
                            currentDrawRectangle.Center.X - pathCounterText[x, y].Width / 2,
                            currentDrawRectangle.Center.Y - pathCounterText[x, y].Height / 2);
                        pathCounterText[x, y].Draw(spriteBatch);
                    }
                }
            }
        }
Esempio n. 28
0
 private void DropLoot()
 {
     if (loot.Count > 0)
     {
         foreach (var item in loot)
         {
             // Drop all loot in the same tile the monster died in
             // PLANNING: Maybe later scatter the loot a monster drops ... or maybe not...
             item.Location = Location;
             FloorGenerator.ScatteredLoot.Add(item);
         }
     }
     else
     // Chance to drop gold
     if (rand.NextDouble() < goldDropChance)
     {
         FloorGenerator.RandomlyDropGold(location.X, location.Y, true, goldDropAmt);
     }
 }
Esempio n. 29
0
    public void buildNextLevel(Collider2D other)
    {
        floorGenerator = GameObject.FindGameObjectWithTag("GameController").GetComponent <FloorGenerator> ();
        floorGenerator.numberOfRooms += 2;
        floorGenerator.level         += 1;
        //Debug.Log (floorGenerator.level);

        var r = floorGenerator._roomPrefabs.First();

        r.transform.position = new Vector3(0, 0f, 0);

        floorGenerator._firstRoom = r;
        floorGenerator.ClearFloor();
        floorGenerator.TryGenerateFloor();

        other.transform.position = Vector3.zero;
        floorGenerator.Grid.FirstRoom.OnPlayerEntersRoom(other.GetComponent <Player> ());

        GameObject.FindGameObjectWithTag("MainCamera").transform.position = new Vector3(0, 0, -10);
    }
Esempio n. 30
0
 void Start()
 {
     bfs        = bf.GetComponent <BlockFactoryScript>();
     blockList  = bfs.blockList;
     fg         = GetComponent <FloorGenerator>();
     ps         = player.GetComponent <Player>();
     whatFloor += 1;
     if (whatFloor == 1)
     {
                         /*ダンジョンの切り替えができるか実験 */
             type = false;
     }
     else
     {
         type = true;
     }
     pmsc = map.GetComponent <PlatersMapCreatScript>();
     pmsc.setting();
     generate();
 }
Esempio n. 31
0
        }                              // Monsters won't gain XP in this game

        internal void Roam()
        {
            // TODO: Make another Move method with path finding to get a monster moving toward a given point
            // For when an effect triggers all monsters to detect the hero or behavior should be less eratic.
            // This method should actually be used in the HeroStrikable method to move towards the hero.
            bool  monsterMoved = false;
            Point checkPoint;

            while (!monsterMoved)
            {
                GameConstants.Direction8 moveDirection = (GameConstants.Direction8)rand.Next(8);
                checkPoint = FloorGenerator.PointInDirection(location, moveDirection);
                if (FloorGenerator.TileIsPassible(FloorGenerator.GetTileAt(checkPoint)))
                {
                    location     = checkPoint;
                    monsterMoved = true;
                }
            }
            CheckVisibility();
        }
        private void SplashProgressThread()
        {
            int UserID = 1;

            Logger.Debug("Initializing Clientsided Server");
            Logger.Info("Please enter SSOTicket:  ");
            string ssoTicket = "";

            RetroEnvironment.Initialize();
            RetroEnvironment.GetConnectionManager().CreateClient();

            Thread.Sleep(500);
            RetroEnvironment.GetGame().GetClientManager().SendPacket(new GetClientVersionEvent());

            RetroEnvironment.GetGame().GetClientManager().SendPacket(new InitCryptoEvent());
            RetroEnvironment.GetGame().GetClientManager().SendPacket(new GenerateSecretKeyEvent("59f6aa4d465979f7c9226744d3117cd2d7a9ffa3d6b275efe5c3fcf8d18d343c9c543d63bd5c9370bad738abc672a9f43cad956a24e0d30fb0dbaabf44f3f71b1c2160e4eb9fb594d844f10867a90269c952d0111cd124894926fa3bcada300340ef5a385020014f44dde37377c235953d4a9e936b3696cd91da5991ef3bafbc"));

            RetroEnvironment.GetGame().GetClientManager().SendPacket(new ClientVariablesEvent());
            RetroEnvironment.GetGame().GetClientManager().SendPacket(new UniqueIDEvent());

            RetroEnvironment.GetGame().GetClientManager().SendPacket(new SSOTicketEvent(ssoTicket));
            RetroEnvironment.GetGame().GetClientManager().SendPacket(new EventTrackerEvent());
            RetroEnvironment.GetGame().GetClientManager().SendPacket(new InfoRetrieveEvent());
            RetroEnvironment.GetGame().GetClientManager().SendPacket(new EventTrackerEvent());

            splashScreenManager.setPercentage(58);
            Thread.Sleep(500);

            FloorGenerator.Initialize();

            splashScreenManager.setPercentage(76);
            Logger.DebugWarn("Waiting on Connection Confirmation");
            while (!RetroEnvironment.ConnectionIsSucces && !RetroEnvironment.ShutdownStarted)
            {
            }

            Logger.Debug("Completed SplashScreen");

            //if(RetroEnvironment.ConnectionIsSucces)
            SplashscreenFinish();
        }
Esempio n. 33
0
    // START AND UPDATE:
    void Start()
    {
        floorGenerator = GetComponent<FloorGenerator> ();
        sceneryGenerator = GetComponent<SceneryGenerator> ();

        floorGenerator.Start ();
        sceneryGenerator.Start ();

        cellTypeGrid = new CellType[numCellsX, numFloors, numCellsZ];
        floors = new Floor[numFloors];

        FillDungeon();

        floorGenerator.CreateFloor();
    }
Esempio n. 34
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    public void Start()
    {
        // Get the dungeon generator component
        dungeonGenerator = GetComponent<DungeonGenerator> ();

        // Get the floor generator component
        floorGenerator = GetComponent<FloorGenerator> ();

        // Get the entrance generator component
        entranceGenerator = GetComponent<EntranceGenerator> ();
    }
Esempio n. 35
0
 void Awake()
 {
     Instance = this;
 }