예제 #1
0
    private string receiveTreasure()
    {
        GameInfo player = BaseSaver.getGame();
        int      pick   = Random.Range(0, 20);

        if (pick == 0)
        {
            Debug.Log("Gained Attribute!");
            CharacterInfo.attributeType newAttrib = GameInfo.getAvailableAttribute(player);
            if (newAttrib != CharacterInfo.attributeType.None)
            {
                List <CharacterInfo.attributeType> attribs = new List <CharacterInfo.attributeType> (player.attributes);
                attribs.Add(newAttrib);
                player.attributes = attribs.ToArray();
            }
            return("Gained Attribute!");
        }
        else if (pick < 8)
        {
            Debug.Log("Gained Gold!");
            player.gold += Random.Range(80, 220);
            return("Gained Gold!");
        }
        else
        {
            Debug.Log("Gained Rations!");
            player.rations += Random.Range(200, 450);
            return("Gained Rations!");
        }
    }
예제 #2
0
파일: QuestPanel.cs 프로젝트: BradZzz/Hex
    public void ButtonClick(int sel)
    {
        int clicked = sel - 1;

        Debug.Log("Sel: " + sel.ToString());

        GameInfo game = BaseSaver.getGame();


        if (clicked < mainButtons.Length && thisLoc == QLocType.Main)
        {
            thisLoc = (QLocType)System.Enum.Parse(typeof(QLocType), mainButtons[clicked]);
        }
        else if (thisLoc == QLocType.Quests && thisSel == -1 && clicked < game.quests.Length)
        {
            thisSel = clicked;
        }
        else
        {
            if (thisSel > -1)
            {
                thisSel = -1;
            }
            else if (thisLoc != QLocType.Main)
            {
                thisLoc = QLocType.Main;
            }
            else
            {
                SceneManager.LoadScene("AdventureScene");
            }
        }
        PopulateInfo(thisLoc, thisSel);
    }
예제 #3
0
    protected override void Awake()
    {
        game = BaseSaver.getGame();

        GameObject.Find("HeaderTxt").GetComponent <Text> ().text = game.name;

        gridCanvas = GetComponentInChildren <Canvas>();
        hexMesh    = GetComponentInChildren <HexMesh>();

        BattleInfo thisBattle = BaseSaver.getBattle();

        if (thisBattle != null)
        {
            boardHeight = thisBattle.height > 0 ? thisBattle.height : 10;
            boardWidth  = thisBattle.width > 0 ? thisBattle.width : 10;
        }
        else
        {
            boardHeight = 6;
            boardWidth  = 8;
        }

        cells = new HexCell[boardHeight * boardWidth];

        for (int z = 0, i = 0; z < boardHeight; z++)
        {
            for (int x = 0; x < boardWidth; x++)
            {
                CreateCell(x, z, i++);
            }
        }
    }
예제 #4
0
파일: QuestPanel.cs 프로젝트: BradZzz/Hex
    void PopulateInfo(QLocType screen, int selection)
    {
        Debug.Log("thisLoc");
        Debug.Log(thisLoc);
        GameInfo game = BaseSaver.getGame();

        switch (screen)
        {
        case QLocType.Main:
            Debug.Log("Main");
            populateInfo("Player Menu", "Click on the buttons on the side to see the current information about your character.");
            PopulateButtons(mainButtons);
            break;

        case QLocType.Quests:
            Debug.Log("Quests");
            if (selection > -1)
            {
                string msg = game.quests [selection].startMsg + "\n\n";
                msg += "Proximity: " + game.quests [selection].distance.ToString() + "\n";
                msg += "Status: " + (game.quests [selection].completed ? "Completed" : "Active") + "\n";
                msg += "Quest Type: " + game.quests [selection].type.ToString() + "\n";
                msg += "Rewards:\n";
                foreach (ResInfo res in game.quests[selection].rewards)
                {
                    msg += "\t" + res.type.ToString() + "\n";
                }

                populateInfo(game.quests[selection].title, msg);
                PopulateButtons(new string[] {});
            }
            else
            {
                populateInfo("Quests", "Here are your character's active quests. Click on one to see more information and make it active.");
                string[] qsts = new string[game.quests.Length];
                for (int i = 0; i < game.quests.Length; i++)
                {
                    qsts [i] = game.quests [i].title;
                }
                PopulateButtons(qsts);
            }
            break;

        case QLocType.Stats:
            populateInfo("Stats", BaseSaver.getGame().RetInfo());
            PopulateButtons(new string[0]);
            Debug.Log("Stats");
            break;

        case QLocType.Squad:
            Debug.Log("Squad");
            break;

        case QLocType.Enemies:
            Debug.Log("Enemies");
            break;
        }
    }
예제 #5
0
    protected override void attackCell(HexCell attacker, HexCell defender)
    {
        GameInfo game = BaseSaver.getGame();

        BattleInfo thisBattle = new BattleInfo();

        thisBattle.playerRoster = game.playerRoster;
        thisBattle.enemyRoster  = game.enemyRoster;
        thisBattle.redirect     = "AdventureScene";
        BaseSaver.putBattle(thisBattle);

        SceneManager.LoadScene("BattleScene");
    }
예제 #6
0
    //Traverse all the nodes of the location and calculate events
    void TraverseMeta(LocationInfo node, bool calcAppearChance)
    {
        node.visible = true;

        if (calcAppearChance && node.appearChance < 1)
        {
            float pick   = UnityEngine.Random.Range(0, 100);
            float chance = node.appearChance * 100;

            Debug.Log("Name: " + node.name);
            Debug.Log("Pick: " + pick.ToString());
            Debug.Log("Chance: " + chance.ToString());

            if (pick > chance)
            {
                node.visible = false;
                Debug.Log("Making invisible");
            }
        }

        /*
         * We need to disable the parent to the quest if the quest has already been accepted
         */

        foreach (LocationInfo child in node.children)
        {
            if (child.nxtRes.Length > 0)
            {
                foreach (ResInfo res in child.nxtRes)
                {
                    if (res.type == ResInfo.ResType.Quest)
                    {
                        if (returnValidQ(res, BaseSaver.getGame()).Length < 1)
                        {
                            node.visible = false;
                        }
                    }
                }
            }
        }

        foreach (LocationInfo child in node.children)
        {
            TraverseMeta(child, calcAppearChance);
        }
    }
예제 #7
0
    void Awake()
    {
        Debug.Log("Awake");

        gameState       = new Stack <GameInfo> ();
        availableQuests = new List <QuestInfo> ();
        foreach (GameObject quest in quests)
        {
            availableQuests.Add(quest.GetComponent <QuestMain>().quest);
        }

        gameState.Push(BaseSaver.getGame());

        getLocation();
//
//    locMeta = locations[0].GetComponent<LocationMain> ();
//    locSprite = locations[0].GetComponent<SpriteRenderer> ().sprite;
    }
예제 #8
0
    protected virtual void Awake()
    {
        game = BaseSaver.getGame();

        GameObject.Find("HeaderTxt").GetComponent <Text> ().text = game.name;

        gridCanvas = GetComponentInChildren <Canvas>();
        hexMesh    = GetComponentInChildren <HexMesh>();

        cells = new HexCell[boardHeight * boardWidth];

        for (int z = 0, i = 0; z < boardHeight; z++)
        {
            for (int x = 0; x < boardWidth; x++)
            {
                CreateCell(x, z, i++);
            }
        }
    }
예제 #9
0
파일: EndGamePanel.cs 프로젝트: BradZzz/Hex
    // Use this for initialization
    void Start()
    {
        Debug.Log("Start");

        // Win / Lose
        GameObject status = GameObject.Find("Status");
        // A,B,C,etc
        GameObject scoreGrade = GameObject.Find("ScoreGrade");
        // Siberian Guru, etc
        GameObject scoreRankText = GameObject.Find("ScoreRankText");
        // 1,2,3,4
        GameObject placeRankText = GameObject.Find("PlaceRankText");

        GameObject rationScore    = GameObject.Find("RationScore");
        GameObject goldScore      = GameObject.Find("GoldScore");
        GameObject repScore       = GameObject.Find("RepScore");
        GameObject enemyScore     = GameObject.Find("EnemyScore");
        GameObject squadScore     = GameObject.Find("SquadScore");
        GameObject attributeScore = GameObject.Find("AttributeScore");
        GameObject totalScore     = GameObject.Find("TotalScore");

        GameInfo game = BaseSaver.getGame();

        HighScoreInfo.EndInfo end = HighScoreInfo.makeEndInfo(game);

        status.GetComponent <Text> ().text        = "Victory!";
        scoreGrade.GetComponent <Text> ().text    = HighScoreInfo.returnGrade(end.score);
        scoreRankText.GetComponent <Text> ().text = "Title: \n\n" + HighScoreInfo.returnRank(end.score);
        placeRankText.GetComponent <Text> ().text = "Map Rank: 1st";

        rationScore.GetComponent <Text> ().text    = "Rations: " + end.getRationsScore() + " (" + end.rations.ToString() + ")";
        goldScore.GetComponent <Text> ().text      = "Gold: " + end.getGoldScore() + " (" + end.gold.ToString() + ")";
        repScore.GetComponent <Text> ().text       = "Reputation: " + end.getRepScore() + " (" + end.rep.ToString() + ")";
        enemyScore.GetComponent <Text> ().text     = "Enemies Killed: " + end.enemies.ToString();
        squadScore.GetComponent <Text> ().text     = "Squad Score: " + end.squad.ToString();
        attributeScore.GetComponent <Text> ().text = "Attributes: " + end.attributes.ToString();
        totalScore.GetComponent <Text> ().text     = "Total: " + end.score.ToString();
    }
예제 #10
0
    void Start()
    {
        checkEndGame();

        TileInfo[] bTiles = BaseSaver.getTiles();
        UnitInfo[] bUnits = BaseSaver.getUnits();

        HexCell hPos = cells [0];

        if (bTiles != null && bUnits != null)
        {
            game = BaseSaver.getGame();
            for (int i = 0; i < cells.Length; i++)
            {
                cells [i].SetInfo(bUnits[i]);
                cells [i].SetTile(bTiles[i]);

                if (bUnits[i].human)
                {
                    int mv = game.movement - game.fatigue;
                    cells [i].GetInfo().actions = mv < 0 ? 0 : mv;
                    hPos = cells [i];
                    focusOnCell(cells [i]);
                }
            }

            GameObject.Find("TurnImg").GetComponent <Image>().color = playerColors [0];
            setPTurn(0);

            /*
             * Here is where the new quests need to be calculated if there are any
             */
            foreach (QuestInfo quest in game.quests)
            {
                if (!quest.placed)
                {
                    quest.startIdx = hPos.coordinates;
                    List <HexCell> dests = new List <HexCell> ();
                    for (int i = 0; i < cells.Length; i++)
                    {
                        if (cells[i].GetTile().type == quest.locType && !cells[i].GetTile().interaction)
                        {
                            HexCell[] path = HexAI.aStar(cells, hPos, cells[i]);
                            if (path != null && path.Length < 10)
                            {
                                dests.Add(cells[i]);
                            }
                        }
                    }
                    if (dests.Count > 0)
                    {
                        HexCell[] theseDests = dests.ToArray();
                        HexUtilities.ShuffleArray(theseDests);
                        theseDests [0].GetTile().interaction = true;
                        quest.endIdx = theseDests [0].coordinates;
                        quest.placed = true;
                        Debug.Log("Destination Set: " + quest.endIdx.ToString());
                        Debug.Log("Tiles saved");
                        BaseSaver.putBoard(cells, BaseSaver.getBoardInfo().name,
                                           BaseSaver.getBoardInfo().height, BaseSaver.getBoardInfo().width);
                        BaseSaver.putGame(game);
                    }
                    else
                    {
                        Debug.Log("No destinations! Quest invalid...");
                    }
                }
            }

            ResetCells();
            hexMesh.Triangulate(cells);
//			BaseSaver.resetBoard ();
        }
        else
        {
            Debug.Log("Maps: ");
            foreach (MapInfo mp in BaseSaver.getMaps())
            {
                Debug.Log(mp.name);
            }


//			foreach(HexCell cell in cells) {
//				cell.GetTile ().fog = true;
//			}

//			MapInfo map = BaseSaver.getMap("Basic Level");
//      MapInfo map = BaseSaver.getMap(MAP_NAME);

            Debug.Log("Next Map: " + BaseSaver.getNextMap());

            MapInfo map = BaseSaver.getMap(BaseSaver.getNextMap());

            List <int> playerPos = new List <int> ();
            List <int> enemyPos  = new List <int> ();

            for (int i = 0; i < cells.Length; i++)
            {
                if (map.tiles[i].type == TileInfo.tileType.pSpawn)
                {
                    cells[i].setType(TileInfo.tileType.Road);
                    playerPos.Add(i);
                }
                else if (map.tiles[i].type == TileInfo.tileType.eSpawn)
                {
                    cells[i].setType(TileInfo.tileType.Road);
                    enemyPos.Add(i);
                }
                else
                {
                    cells[i].setType(map.tiles[i].type);
                    if (cells[i].GetTile().type == TileInfo.tileType.Castle || cells[i].GetTile().type == TileInfo.tileType.City)
                    {
                        cells [i].GetTile().meta = StaticNames.getTownName();
                        Debug.Log("Town Name: " + cells [i].GetTile().meta);
                    }
                }
            }

            int[] pArr = playerPos.ToArray();
            int[] eArr = enemyPos.ToArray();

            HexUtilities.ShuffleArray(pArr);
            HexUtilities.ShuffleArray(eArr);


            placePlayer(cells[pArr[0]], 0, false, UnitInfo.unitType.Adventure, true);
            cells [pArr[0]].removeFog();

            placePlayer(cells[eArr[0]], 1, false, UnitInfo.unitType.Adventure, false);

//			if (players > 2) {
//				placePlayer(cells[cells.Length - width], 2, false, UnitInfo.unitType.Adventure, false);
//			}
//
//			if (players > 3) {
//				placePlayer (cells [width - 1], 3, false, UnitInfo.unitType.Adventure, false);
//			}

//			foreach (HexCell cell in cells) {
//				//			cell.setType((TileInfo.tileType) Random.Range(0, 7));
//				cell.setType(TileInfo.tileType.Grass);
//			}

//			HexCell[] road = HexAI.aStar (cells, cells[0], cells[cells.Length - 1]);
//			foreach (HexCell cell in road) {
//				cell.setType(TileInfo.tileType.Road);
//			}
//
//      HexAdventureGenerator.generateMap (cells, height, width);
//
//			int mountain = Random.Range (3, cells.Length - 3);
//			cells [mountain].setType (TileInfo.tileType.Mountain);
//			foreach(HexDirection dir in cells [mountain].dirs) {
//				if (cells [mountain].GetNeighbor(dir) && TileInfo.tileType.Grass == cells [mountain].GetNeighbor(dir).GetTile().type) {
//					cells [mountain].GetNeighbor (dir).setType (TileInfo.tileType.Forest);
//				}
//			}

//			foreach (HexCell cell in cells){
//				if (cell.GetPlayer() == -1) {
//					int chp = Random.Range(0, 4);
//					if (chp == 0) {
//						cell.GetTile ().interaction = true;
////						cell.setLabel ("I");
//					}
//				}
//			}

            hexMesh.Triangulate(cells);
            setPTurn(players - 1);
            EndTurn();
            ResetCells();
        }
    }
예제 #11
0
    public void selectChoice(int btn, int idx, bool callback)
    {
//    ChoiceInfo choice = glossy.options[idx].GetComponent<ChoiceMain>().choice;
        OptionInfo option = lstOptions [btn - 1];

        if (callback)
        {
            GameObject.Find("InfoDescription").GetComponent <Text> ().text = BaseSaver.getBattle().won ? choice.winningGreeting : choice.losingGreeting;

            OptionInfo final = new OptionInfo();
            final.TextOptions = new string[] { "Continue" };
            final.result      = OptionInfo.resultType.None;
            final.reaction    = "<confirm/>";

            populateInfoButtons(new OptionInfo[] { final });

            BaseSaver.resetBattle();
            BaseSaver.resetChoice();
        }
        else
        {
            if (!option.reaction.Equals("<confirm/>"))
            {
                GameObject.Find("InfoDescription").GetComponent <Text> ().text = option.reaction;

                OptionInfo final = new OptionInfo();
                final.TextOptions = new string[] { "Continue" };
                final.result      = (option.result == OptionInfo.resultType.MiniGame || option.result == OptionInfo.resultType.Battle)
                                        ? option.result : OptionInfo.resultType.None;
                final.reaction = "<confirm/>";

                populateInfoButtons(new OptionInfo[] { final });
            }
            else
            {
                if (option.result == OptionInfo.resultType.MiniGame)
                {
                    BaseSaver.putChoice(choice, idx, btn);
                    SceneManager.LoadScene("MiniGameScene");
                }
                else
                {
                    if (option.result == OptionInfo.resultType.Battle)
                    {
                        BaseSaver.putChoice(choice, idx, btn);

                        GameInfo game = BaseSaver.getGame();

                        BattleInfo battle = new BattleInfo();
                        battle.redirect     = "ChoiceScene";
                        battle.playerRoster = game.playerRoster;

                        int enemies = 2;
                        battle.height = 5;
                        battle.width  = 7;

                        switch (choice.difficulty)
                        {
                        case ChoiceInfo.DifficultyType.Medium:
                            enemies       = 4;
                            battle.height = 6;
                            battle.width  = 8;
                            break;

                        case ChoiceInfo.DifficultyType.Hard:
                            enemies       = 6;
                            battle.height = 7;
                            battle.width  = 9;
                            break;

                        case ChoiceInfo.DifficultyType.Insane:
                            enemies       = 10;
                            battle.height = 10;
                            battle.width  = 12;
                            break;
                        }

                        battle.enemyRoster = new UnitInfo[enemies];
                        for (int i = 0; i < enemies; i++)
                        {
                            UnitInfo info = new UnitInfo();
                            info.playerNo = 0;
                            info.type     = choiceArr[Random.Range(0, 3)];
                            Debug.Log("Choice: " + info.type);
                            info.human             = true;
                            battle.enemyRoster [i] = info;
                        }
                        BaseSaver.putBattle(battle);

                        SceneManager.LoadScene("BattleScene");
                    }
                    else
                    {
                        SceneManager.LoadScene("AdventureScene");
                    }
                }
            }
        }
    }