Beispiel #1
0
    public BattleStageData GetBattleStageData(string id)
    {
        BattleStageData data = null;

        _worldBattleStageData.TryGetValue(id, out data);
        return(data);
    }
Beispiel #2
0
    public void StartGame(List <WeaponTileData> tileData, BattleStageData stageData)
    {
        _gameTileData = tileData;
        gameStageData = stageData;

        SceneManager.LoadScene("Game");
    }
Beispiel #3
0
    public void InitializeAsBattleStage(string id, Vector3 position, BattleStageData stageData, MapNodeTappedCallback callback)
    {
        BaseInitialize(id, position);

        Data.BattleStageDataId = stageData.name;
        _battleStageData       = stageData;
        _callback = callback;
    }
Beispiel #4
0
 public Session(BattleStageData stageData)
 {
     TurnsRemaining       = UnityEngine.Random.Range(stageData.TurnsMin, stageData.TurnsMax + 1);
     HPMax                = UnityEngine.Random.Range(stageData.HPMin, stageData.HPMax + 1);
     HPRemaining          = HPMax;
     EnemyCooldown        = UnityEngine.Random.Range(stageData.CooldownMin, stageData.CooldownMax + 1);
     CurrentEnemyCooldown = EnemyCooldown;
     AttackSets           = stageData.AttackSets;
     AttackPattern        = stageData.Pattern;
     LootTableId          = stageData.LootTableId;
 }
Beispiel #5
0
    public void Initialize(BattleStageData data, GameHud gameHud, GameBoard gameBoard)
    {
        _session   = new Session(data);
        _gameHud   = gameHud;
        _gameBoard = gameBoard;

        _gameBoard.OnTilesMatched += HandleOnTilesMatched;
        _gameBoard.OnTurnEnded    += HandleOnTurnEnded;

        _enemyGameObject.GetComponent <SpriteRenderer>().sprite = data.EnemySprite;

        UpdateHUD();
    }
Beispiel #6
0
    public void InitializeFromData(MapNodeData data, MapNodeTappedCallback callback)
    {
        Data = data;

        if (data.BattleStageDataId != null)
        {
            _battleStageData = Database.Instance.GetBattleStageData(data.BattleStageDataId);
        }
        else if (data.ShopStageDataId != null)
        {
            _shopStageData = Database.Instance.GetShopStageData(data.ShopStageDataId);
        }

        transform.position = Data.Coordinates;
        _callback          = callback;
    }
Beispiel #7
0
 public BattleStageData GetRandomTestBattleStageData()
 {
     if (_testStageData.Count == 0)
     {
         Object[] allTestStages = Resources.LoadAll(STAGES_TEST_PATH);
         for (int i = 0, count = allTestStages.Length; i < count; i++)
         {
             BattleStageData data = allTestStages[i] as BattleStageData;
             _testStageData.Add(data.name, data);
         }
         return((BattleStageData)allTestStages[UnityEngine.Random.Range(0, allTestStages.Length)]);
     }
     else
     {
         int      index = UnityEngine.Random.Range(0, _testStageData.Count);
         string[] keys  = new string[_testStageData.Keys.Count];
         _testStageData.Keys.CopyTo(keys, 0);
         return(_testStageData[keys[index]]);
     }
 }
Beispiel #8
0
    public WorldData LoadWorldStageData(int worldId)
    {
        //temp
        string worldName = "World" + worldId.ToString();

        if (_worldData != null && _worldData.name == worldName)
        {
            return(_worldData);
        }

        string worldPath = WORLD_PATH;

        worldPath  = worldPath.Replace("{worldNum}", worldId.ToString());
        _worldData = Resources.Load(worldPath) as WorldData;

        string stagesPath = WORLD_STAGES_PATH;

        stagesPath = stagesPath.Replace("{worldNum}", worldId.ToString());
        Object[] stages = Resources.LoadAll(stagesPath);
        for (int i = 0, count = stages.Length; i < count; i++)
        {
            // Test if the stage data is a battle stage
            BattleStageData battleStage = stages[i] as BattleStageData;
            if (battleStage != null)
            {
                _worldBattleStageData.Add(battleStage.name, battleStage);
            }

            ShopStageData shopData = stages[i] as ShopStageData;
            if (shopData != null)
            {
                _worldShopStageData.Add(shopData.name, shopData);
            }
        }

        return(_worldData);
    }
Beispiel #9
0
    private MapNode GenerateGraph(WorldData worldData)
    {
        List <Vector2> points       = new List <Vector2>();
        MapNode        startingNode = null;


        // world data says... maybe 8 battle stages, 2 shops, 1 quest
        int numBattleStages = UnityEngine.Random.Range(worldData.MinNumBattleStages, worldData.MaxNumBattleStages + 1);
        int numShopStages   = UnityEngine.Random.Range(worldData.MinNumShopStages, worldData.MaxNumShopStages + 1);

        // Create battle stage nodes
        for (int i = 0; i < numBattleStages; i++)
        {
            Vector3 position;
            if (i == 0)
            {
                position = FindStartingPosition();
            }
            else if (i == numBattleStages)
            {
                position = FindEndingPosition();
            }
            else
            {
                position = FindOpenPosition();
            }

            BattleStageData stageData = Database.Instance.GetRandomBattleStageData();

            string  nodeId  = GetNodeIdFromVector3(position);
            MapNode mapNode = CreateMapNode(nodeId);
            mapNode.InitializeAsBattleStage(nodeId, position, stageData, MapNodeTappedCallback);

            points.Add(new Vector2(position.x, position.y));

            if (i == 0)
            {
                // save current node
                startingNode = mapNode;
            }
        }

        // Create shop nodes
        for (int i = 0; i < numShopStages; i++)
        {
            Vector3 position = FindOpenPosition();

            // depending on the world data, we need to pick from a random set

            ShopStageData stageData = Database.Instance.GetRandomShopStageData();

            string  nodeId  = GetNodeIdFromVector3(position);
            MapNode mapNode = CreateMapNode(nodeId);
            mapNode.InitializeAsShopStage(nodeId, position, stageData, MapNodeTappedCallback);

            points.Add(new Vector2(position.x, position.y));
        }

        GenerateEdges(points);

        return(startingNode);
    }