Ejemplo n.º 1
0
    void Start()
    {
        _audioManager     = AudioManager.Instance();
        _terrainDatabase  = TerrainDatabase.Instance();
        _characterManager = CharacterManager.Instance();
        _itemDatabase     = ItemDatabase.Instance();
        _key        = _terrainDatabase.GetRegionKey();
        _monsterObj = Resources.Load <GameObject>("Prefabs/Monster");
        var starter = GameObject.FindObjectOfType <SceneStarter>();

        if (starter != null)
        {
            _mapPosition      = starter.MapPosition;
            _previousPosition = starter.PreviousPosition;
        }
        _floor = FloorTiles[RandomHelper.Range(new Vector2(_mapPosition.x + 0.01f, _mapPosition.y + 0.01f), _key, FloorTiles.Length)];
        //print("Building Interior _floor: "  +"  " + _floor.name);
        _story = _terrainDatabase.GetStoryBasedOnRarity(_mapPosition, _key);
        GenerateInterior();
        if (_audioManager != null)
        {
            _audioManager.UpdateSoundVolume(_characterManager.UserPlayer.SoundVolume);
            _audioManager.PlayInsideMusic(_previousPosition, _key);
        }
    }
Ejemplo n.º 2
0
 void Start()
 {
     _userDatabase     = Instance();
     _terrainDatabase  = TerrainDatabase.Instance();
     _apiGatewayConfig = ApiGatewayConfig.Instance();
     _xmlHelper        = XmlHelper.Instance();
     Debug.Log("***UDB*** Start!");
 }
Ejemplo n.º 3
0
    internal Vector2 GetMapLocation(int key)
    {
        //Latitudes range from 0 to 90. Longitudes range from 0 to 180
        var     terrainDatabase = TerrainDatabase.Instance();
        Vector2 regionLocation  = terrainDatabase.GetRegionLocation(key);
        int     x           = (int)(UserPlayer.Latitude * 1000 - regionLocation.x);
        int     y           = (int)(UserPlayer.Longitude * 1000 - regionLocation.y);
        var     mapLocation = new Vector2(x, y);

        return(mapLocation);
    }
Ejemplo n.º 4
0
        private static IEnumerable <Division> InitialDivisions()
        {
            var divisions = new List <Division>();

            for (var i = 0; i < 10; i++)
            {
                divisions.Add(new Division(TerrainDatabase.Find(TerrainName.Plain.ToString())));
            }

            return(divisions);
        }
Ejemplo n.º 5
0
 public static TerrainDatabase Instance()
 {
     if (!_terrainDatabase)
     {
         _terrainDatabase = FindObjectOfType(typeof(TerrainDatabase)) as TerrainDatabase;
         if (!_terrainDatabase)
         {
             Debug.LogError("There needs to be one active TerrainDatabase script on a GameObject in your scene.");
         }
     }
     return(_terrainDatabase);
 }
Ejemplo n.º 6
0
    void Awake()
    {
        terrainsDB = new TerrainDatabase();
        string path = Path.Combine(Application.streamingAssetsPath, "Databases/Grids/" + mapName + ".json");
        string data = File.ReadAllText(path);

        gridData = JsonUtility.FromJson <GridData>(data);
        gridData.Initialise();
        width  = gridData.width;
        height = gridData.height;
        InitialiseGrid();
    }
Ejemplo n.º 7
0
 // Start is called before the first frame update
 void Start()
 {
     Debug.Log("***API*** Start!");
     _xmlHelper         = XmlHelper.Instance();
     _itemDatabase      = ItemDatabase.Instance();
     _userDatabase      = UserDatabase.Instance();
     _characterDatabase = CharacterDatabase.Instance();
     _terrainDatabase   = TerrainDatabase.Instance();
     _gameLoadHelper    = GameObject.Find("GameStarter").GetComponent <GameLoadHelper>();
     //Call UserPlayer
     //_apiGate = "GetUserPlayer";
     //_uri = String.Format(ApiPath + ApiStage + _apiGate + "?id={0}", DeviceHandler.FetchMacId());
     //StartCoroutine(GetRequest(_uri, ReadUserPlayerJson));
     ReadUserPlayerXml(DeviceHandler.FetchMacId());
 }
Ejemplo n.º 8
0
    void Start()
    {
        _terrainDatabase = TerrainDatabase.Instance();
        _audioManager    = AudioManager.Instance();
        var starter = GameObject.FindObjectOfType <SceneStarter>();

        if (starter != null)
        {
            _mapPosition      = starter.MapPosition;
            _key              = starter.Key;
            _monsterInfo      = starter.Content;
            starter.LastScene = "Combat";
        }
        SetMonster(_monsterInfo);
        DrawMap();
        if (_audioManager != null)
        {
            _audioManager.PlayFightMusic(_mapPosition, _key);
        }
    }
Ejemplo n.º 9
0
    void Start()
    {
        _terrainDatabase  = TerrainDatabase.Instance();
        _characterManager = CharacterManager.Instance();
        var starter = GameObject.FindObjectOfType <SceneStarter>();

        if (starter != null)
        {
            _mapPosition      = starter.MapPosition;
            _key              = starter.Key;
            _previousPosition = starter.PreviousPosition;
        }
        _availableTerrainTypes = _terrainDatabase.GetTerrains();
        Debug.Log("Mini Map-Available TerrainTypes.Count = " + _availableTerrainTypes.Count);
        _markers = GetAllMarkers(_mapPosition.x, _mapPosition.y, _key);
        Debug.Log("Mini Map-Map Markers.Count = " + _markers.Count);
        Debug.Log("Mini Map-" + "currentPos =" + _previousPosition + "mapPos =" + _mapPosition + "Key =" + _key);
        _mapPanel = GameObject.Find("MapPanel");
        for (int i = 0; i < 13; i++)  //25/49/81
        {
            for (int j = 0; j < 9; j++)
            {
                GameObject pixelMap = new GameObject(_markers[i * 9 + j].MarkerIndex + "-" + i + "x" + j + " " + _markers[i * 9 + j].Terrain.Name + _markers[i * 9 + j].Location);
                pixelMap.transform.SetParent(_mapPanel.transform);
                pixelMap.transform.localScale          = new Vector3(1.70f, 1.70f, 0);
                pixelMap.AddComponent <Image>().sprite = _markers[i * 9 + j].Terrain.GetSprite();
                if (i == 6 && j == 4) //"Center"
                {
                    GameObject characterPin = new GameObject("Character Pin " + _characterManager.MyCharacter.Name);
                    characterPin.transform.SetParent(pixelMap.transform);
                    characterPin.transform.localScale          = new Vector3(0.3f, 0.3f, 0);
                    characterPin.transform.localPosition       = new Vector3(5, 5, 0);
                    characterPin.AddComponent <Image>().sprite = _characterManager.MyCharacter.GetSprite();
                }
            }
        }
    }
Ejemplo n.º 10
0
 void Start()
 {
     _terrainDatabase   = TerrainDatabase.Instance();
     _characterDatabase = CharacterDatabase.Instance();
     Debug.Log("***TDB*** Start!");
 }
Ejemplo n.º 11
0
 private int _verticalTiles = 25;
    private SpriteRenderer[,] _renderers;
    private IEnumerable<Marker> _markers;
    private List<GameObject> _digs = new List<GameObject>();


    private GameObject _monsterObj;

    void Start()
    {
        Debug.Log("***TM*** Start!");
        _terrainManager = TerrainManager.Instance();
        _audioManager = AudioManager.Instance();
        _itemDatabase = ItemDatabase.Instance();
        _inv = InventoryHandler.Instance();
        _terrainDatabase = TerrainDatabase.Instance();
        _characterManager = CharacterManager.Instance();
        _cache = Cache.Instance();
        _monsterObj = Resources.Load<GameObject>("Prefabs/Monster");
        _player = GameObject.FindGameObjectWithTag("PlayerCamera").transform;

        _terrainTypes = _terrainDatabase.GetTerrains();
        _allElements = _terrainDatabase.GetElements();
        _allMonster = _terrainDatabase.GetMonsters();
        Region = _terrainDatabase.GetRegion();
     Key = Region.Key;
        _player.position = _characterManager.GetMapLocation(Key);
        print("Region= " + Region.MyInfo() + " Player.position = " + _player.position);
        var offset = new Vector3(0 - _horizontalTiles / 2, 0 - _verticalTiles / 2, 0);
        _renderers = new SpriteRenderer[_horizontalTiles, _verticalTiles];
        for (int x = 0; x < _horizontalTiles; x++)
        {
            for (int y = 0; y < _verticalTiles; y++)
            {
                var tile = new GameObject();
                tile.transform.position = new Vector3(x, y, 0) + offset;
                var spriteRenderer = _renderers[x, y] = tile.AddComponent<SpriteRenderer>();
                spriteRenderer.sortingOrder = _baseSortIndex;
                tile.name = "Terrain " + tile.transform.position;
                tile.transform.parent = transform;
            }
        }
        print("Terrain Manager Health Check #1");
        var starter = GameObject.FindObjectOfType<SceneStarter>();
        if (starter != null)
        {
            _player.position = starter.PreviousPosition;
            print(" Player.position = " + _player.position);
        }
     //else SetPlayerLocation();
        _inv.SetInventoryPanel(false);
        print("Terrain Manager Health Check #2");
        RedrawMap(true);
        if (starter == null)
            SetPlayerLocation();
        else
        {
            if (starter.ShowInventory)
                _inv.SetInventoryPanel(true);
            if (starter.LastScene == "Combat")
                if (starter.Content != "FightRunAway")
                {
                    foreach (var monster in GetMonster(starter.MapPosition, 0.3f))
                        if (monster.Alive)
                            if (DestroyMonster(monster, true))
                                break;
                            else
                                throw new Exception("TM-Wasn't able to kill the monster!!!");
                }
            Destroy(starter.gameObject);
        }
        print("Terrain Manager Health Check #3");

        if (_audioManager != null)
        {
            _audioManager.UpdateSoundVolume(_characterManager.UserPlayer.SoundVolume);
            _audioManager.PlayBgMusic(_player.position, Key);
        }
    }
    void Update()
    {
        if (_maxDistanceFromCenter < Vector3.Distance(_player.position, transform.position))
            RedrawMap(false);
    }