示例#1
0
    void discoverMaze()
    {
        clearRewards();
        PlayerSurroundings player = this.player.getSurroundings();

        foreach (Direction direction in player.walls)
        {
            switch (direction)
            {
            case Direction.UP: placeWallInFactors(Direction.UP); break;

            case Direction.RIGHT: placeWallInFactors(Direction.RIGHT); break;

            case Direction.DOWN: placeWallInFactors(Direction.DOWN); break;

            case Direction.LEFT: placeWallInFactors(Direction.LEFT); break;
            }
        }


        switch (player.finish)
        {
        case Direction.UP: placeFinishInRewards(Direction.UP); break;

        case Direction.RIGHT: placeFinishInRewards(Direction.RIGHT); break;

        case Direction.DOWN: placeFinishInRewards(Direction.DOWN); break;

        case Direction.LEFT: placeFinishInRewards(Direction.LEFT); break;
        }
    }
示例#2
0
文件: Player.cs 项目: Feridum/RL_Maze
    public PlayerSurroundings getSurroundings()
    {
        PlayerSurroundings playerSurroundings = new PlayerSurroundings();

        foreach (Direction direction in System.Enum.GetValues(typeof(Direction)))
        {
            Collider2D finish = Physics2D.OverlapCircle((Vector2)transform.position + getTranslation(direction), (float)0.1, 1 << LayerMask.NameToLayer("Finish"));
            if (finish)
            {
                playerSurroundings.finish = direction;
            }
            else if (!canMove(getTranslation(direction)))
            {
                playerSurroundings.walls.Add(direction);
            }
            else
            {
                playerSurroundings.empty.Add(direction);
            }
        }

        return(playerSurroundings);
    }
示例#3
0
        public void UpdateMusicState()
        {
            //Debug.Log ("Updating music state");
            MusicType   shouldBePlaying   = MusicType.Regional;
            MusicVolume musicTargetVolume = MusicVolume.Quiet;

            PlayList.Regional    = GameWorld.Get.CurrentRegion.DayMusic;
            PlayList.Night       = GameWorld.Get.CurrentRegion.NightMusic;
            PlayList.Underground = GameWorld.Get.CurrentRegion.UndergroundMusic;
            bool               isDaytime    = WorldClock.IsDay;
            PlayerStatus       status       = Player.Local.Status;
            PlayerSurroundings surroundings = Player.Local.Surroundings;

            if (surroundings.IsInDanger)
            {
                //same day or night
                //Debug.Log ("We're in danger - should be playing combat");
                shouldBePlaying = MusicType.Combat;
            }
            else if (surroundings.IsInSafeLocation)
            {
                //same day or night
                shouldBePlaying = MusicType.SafeLocation;
            }
            else if (surroundings.IsUnderground)
            {
                //same day or night
                shouldBePlaying = MusicType.Underground;
            }
            else
            {
                if (isDaytime)
                {
                    shouldBePlaying = MusicType.Regional;
                    if (surroundings.IsInsideStructure)
                    {
                        musicTargetVolume = MusicVolume.Quiet;
                    }
                    else
                    {
                        musicTargetVolume = MusicVolume.Default;
                    }
                }
                else
                {
                    //night
                    shouldBePlaying = MusicType.Night;
                    if (surroundings.IsInsideStructure)
                    {
                        musicTargetVolume = MusicVolume.Quiet;
                    }
                    else
                    {
                        musicTargetVolume = MusicVolume.Default;
                    }
                }
            }

            bool updateMusic = false;

            if (shouldBePlaying == MusicType.Regional && mPreviousRegionalTrack != PlayList.Regional)
            {
                //Debug.Log ("Switching regional music to " + PlayList.Regional);
                mPreviousRegionalTrack = PlayList.Regional;
                updateMusic            = true;
            }
            else if (shouldBePlaying == MusicType.Night && mPreviousNightTrack != PlayList.Night)
            {
                //Debug.Log ("Switching night music to " + PlayList.Night);
                mPreviousNightTrack = PlayList.Night;
                updateMusic         = true;
            }
            else if (shouldBePlaying != CurrentMusic)
            {
                updateMusic = true;
            }

            if (updateMusic)
            {
                //Debug.Log("AUDIO MANAGER: Trying to switch music to " + shouldBePlaying.ToString());
                StartCoroutine(PlayMusic(shouldBePlaying, musicTargetVolume));
            }
        }