コード例 #1
0
 private bool MatchesRecipe(List <WeaponTileData> chosenWeapons, TileRecipe recipe)
 {
     if (recipe.Tile1 == chosenWeapons[0].Type &&
         recipe.Tile2 == chosenWeapons[1].Type &&
         recipe.Tile3 == chosenWeapons[2].Type &&
         recipe.Tile4 == chosenWeapons[3].Type)
     {
         return(true);
     }
     return(false);
 }
コード例 #2
0
    public TileRecipe GetRecipe(List <WeaponTileData> weaponData)
    {
        TileRecipe recipe = null;

        // IF we are going with the assumption that order matters for the recipe,
        // then we just need to simply iterate the list
        for (int i = 0, count = _recipes.Count; i < count; i++)
        {
            if (MatchesRecipe(weaponData, _recipes[i]))
            {
                recipe = _recipes[i];
            }
        }

        return(recipe);
    }
コード例 #3
0
    private void StartGame()
    {
        // Initialize Game HUD
        _gameHud = UIManager.Instance.OpenDialog(GameHud.DIALOG_ID) as GameHud;

        TileRecipe recipe = _recipeManager.GetRecipe(_gameTileData);

        // Create the gameboard and battle
        GameObject gameBoard = GameObject.Instantiate(_gameBoardPrefab);

        _gameBoard = gameBoard.GetComponent <GameBoard>();

        GameObject battle = GameObject.Instantiate(_battlePrefab);

        _battle = battle.GetComponent <Battle>();

        // Initialize battle manager
        _battle.Initialize(gameStageData, _gameHud, _gameBoard);

        // Initialize game board
        _gameBoard.Initialize(_gameTileData, _battle, _gameHud, recipe);
    }
コード例 #4
0
ファイル: GameHud.cs プロジェクト: gunnermanx/rogue3
    public void SetupRecipeChargeHud(GameBoard board, TileRecipe recipe, Action callback)
    {
        if (recipe == null)
        {
            _recipeSkillButton.gameObject.SetActive(false);
            _recipeSkillChargeSlider.gameObject.SetActive(false);
        }
        else
        {
            _recipeMatches   = 0;
            _requiredMatches = recipe.RequiredMatches;
            _recipeSkillChargeSlider.value  = 0f;
            _recipeSkillButton.interactable = false;
            _recipeChargeButtonCallback     = callback;

            board.OnTilesMatched += delegate(List <Tile> matches) {
                _recipeMatches = Mathf.Min(_recipeMatches + 1, _requiredMatches);
                _recipeSkillChargeSlider.value  = (float)_recipeMatches / (float)_requiredMatches;
                _recipeSkillButton.interactable = (_recipeMatches == _requiredMatches);
            };
        }
    }
コード例 #5
0
ファイル: GameBoard.cs プロジェクト: gunnermanx/rogue3
    public void Initialize(List <WeaponTileData> tileData, Battle battle, GameHud gameHud, TileRecipe recipe)
    {
        _equippedTileData = tileData;
        _battle           = battle;
        _gameHud          = gameHud;
        _recipe           = recipe;

        _gameHud.SetupRecipeChargeHud(this, _recipe, RecipeSkillButtonTapped);

        // 0, 0 is the bottom left corner tile
        for (int w = 0; w < BOARD_WIDTH; w++)
        {
            for (int h = 0; h < BOARD_HEIGHT; h++)
            {
                BaseTileData data = PickRandomTileData();
                // This can be done in a less dumb way later
                while (CheckForMatchAtCoordsOnInitializing(data, w, h))
                {
                    data = PickRandomTileData();
                }
                CreateTileAtCoords(data, w, h);
            }
        }
    }