コード例 #1
0
ファイル: LoadMap.cs プロジェクト: shibigami/SLimSlime
    /*map legend:
     * 0    =   entrance   (this is put at -1*x automatically)
     * 1    =   farm
     * 2    =   forest
     * 3    =   mine
     * 4    =   river
     * 5    =   chest
     * 6    =   monster
     * 7    =   boss
     * 8    =   door   (add locations through doorlocations list for each door)
     * 9    =   wall   (these are put at the beginning and end of a stage automatically)
     * 10   =   SkillUpgradeStation
     * 11   =   AlchemyStation
     * */

    // Start is called before the first frame update
    void Start()
    {
        map           = new List <int>();
        doorLocations = new List <string>();

        switch (SceneManager.GetActiveScene().name)
        {
        //set map creation here
        //if there are doors, set door locations
        case "Home":
        {
            //sets hub list of blocks
            map = new List <int>()
            {
                8, 10, 11
            };
            doorLocations.Clear();
            doorLocations.Add("World");
            break;
        }

        case "World":
        {
            map = CreateWorld(StoryProgressionManager.GetMapSize(), StoryProgressionManager.GetDifficulty());
            break;
        }
        }

        //door counter (used to go through door scene locations)
        int door = 0;

        // Instantiate Walls on the edges of the map
        Instantiate(blocks[9], new Vector3(-2 * 1.5f, 0, 0), blocks[9].transform.rotation);
        Instantiate(blocks[9], new Vector3(map.Count * 1.5f, 0, 0), blocks[9].transform.rotation);
        // Instantiate Entrance
        Instantiate(blocks[0], new Vector3(-1 * 1.5f, 0, 0), blocks[0].transform.rotation);
        //instantiate map
        for (int i = 0; i < map.Count; i++)
        {
            //instantiates objects in blocks list
            var tempObj = Instantiate(blocks[map[i]], new Vector3(i * 1.5f, 0, 0), blocks[map[i]].transform.rotation);

            //if its a door
            if (tempObj.tag == "Door")
            {
                //adds the scene name to the changeScene script
                tempObj.GetComponent <ChangeScene>().sceneName = doorLocations[door];
                door++;
            }
            //if its an enemy
            else if ((tempObj.tag == "Boss") || (tempObj.tag == "Monster"))
            {
                //handles monster spawns
                EnemySpawn(tempObj, StoryProgressionManager.GetDifficulty());
            }
        }

        //if it doesnt find player
        if (!GameObject.FindGameObjectWithTag("Player"))
        {
            //instantiate all objects that should be on every scene
            for (int i = 0; i < dontDestroyOnLoadObjects.Length; i++)
            {
                Instantiate(dontDestroyOnLoadObjects[i]);
            }
        }

        //set player to entrance
        GameObject.FindGameObjectWithTag("Player").transform.position = new Vector3(
            GameObject.FindGameObjectWithTag("Entrance").transform.position.x,
            GameObject.FindGameObjectWithTag("Player").transform.position.y,
            GameObject.FindGameObjectWithTag("Player").transform.position.z);
        GameObject.FindGameObjectWithTag("Canvas").GetComponent <UIControls>().MoveToEntrance();
    }
コード例 #2
0
ファイル: UIOutputs.cs プロジェクト: shibigami/SLimSlime
    // Update is called once per frame
    void Update()
    {
        //ap
        actionPoints.text = "AP:" + GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterStats>().actionPointsCurent.ToString();

        //clock
        clock.text = string.Format("{0}Y {1}M {2}D {3}H", StoryProgressionManager.GetTimeYears(), StoryProgressionManager.GetTimeMonths(), StoryProgressionManager.GetTimeDays(), StoryProgressionManager.GetCurrentTimeHours());

        //escape button
        if ((SceneManager.GetActiveScene().name == "Home") || (GameObject.FindGameObjectWithTag("FightWindow").GetComponent <FightManager>().GetFightState() != FightManager.FightFlow.OutsideFight))
        {
            escapeButton.SetActive(false);
        }
        else
        {
            escapeButton.SetActive(true);
        }

        //door size
        if (GameObject.FindGameObjectWithTag("Canvas").GetComponent <UIControls>().IsNearDoor())
        {
            doorButton.SetActive(true);
            doorSize.text = StoryProgressionManager.GetMapSize().ToString();
        }
        else
        {
            doorButton.SetActive(false);
        }

        //skill Unlock Interface
        if (GameObject.FindGameObjectWithTag("Canvas").GetComponent <UIControls>().IsNearSkillUnlockStation())
        {
            skillUnlockStationButton.SetActive(true);
        }
        else
        {
            skillUnlockStationButton.SetActive(false); skillUnlockStationPanel.SetActive(false); skillUnlockStationButton.GetComponent <ShowHideWindow>().showHide = false;
        }

        //alchemy Interface
        if (GameObject.FindGameObjectWithTag("Canvas").GetComponent <UIControls>().IsNearAlchemyStation())
        {
            alchemyButton.SetActive(true);
        }
        else
        {
            alchemyButton.SetActive(false); alchemyPanel.SetActive(false); alchemyButton.GetComponent <ShowHideWindow>().showHide = false;
        }

        //gold
        gold.text = player.GetComponent <InventorySystem>().itemList[0].GetAmount().ToString();
        //player name
        playerName.text = player.GetComponent <CharacterStats>().playerName;
        //exp
        expPool.text = string.Format("{0}/{1}", player.GetComponent <CharacterStats>().expPoolCurrent, player.GetComponent <CharacterStats>().currentStats.expPool);
        exp.width    = AdjustBarSize(exp.Maxwidth, player.GetComponent <CharacterStats>().expPoolCurrent, player.GetComponent <CharacterStats>().currentStats.expPool);
        expBar.GetComponent <RectTransform>().sizeDelta = new Vector2(exp.width, exp.expbarSize.y);

        //jobs
        lumber.text = string.Format("WoodCutting Lvl.{0}", playerStats.WoodCutting.GetLevel());
        farmer.text = string.Format("Farming Lvl.{0}", playerStats.Farming.GetLevel());
        fisher.text = string.Format("Fishing Lvl.{0}", playerStats.Fishing.GetLevel());
        miner.text  = string.Format("Mining Lvl.{0}", playerStats.Mining.GetLevel());

        //farmer
        farmerExpLabel.text = string.Format("{0}/{1}", player.GetComponent <CharacterStats>().Farming.GetExp(), player.GetComponent <CharacterStats>().Farming.GetExpToLevel());
        farmerExp.width     = AdjustBarSize(farmerExp.Maxwidth, player.GetComponent <CharacterStats>().Farming.GetExp(), player.GetComponent <CharacterStats>().Farming.GetExpToLevel());
        farmerExpBar.GetComponent <RectTransform>().sizeDelta = new Vector2(farmerExp.width, farmerExp.expbarSize.y);
        //lumberman
        lumberjackExpLabel.text = string.Format("{0}/{1}", player.GetComponent <CharacterStats>().WoodCutting.GetExp(), player.GetComponent <CharacterStats>().WoodCutting.GetExpToLevel());
        lumberExp.width         = AdjustBarSize(lumberExp.Maxwidth, player.GetComponent <CharacterStats>().WoodCutting.GetExp(), player.GetComponent <CharacterStats>().WoodCutting.GetExpToLevel());
        lumberjackExpBar.GetComponent <RectTransform>().sizeDelta = new Vector2(lumberExp.width, lumberExp.expbarSize.y);
        //fisher
        fisherExpLabel.text = string.Format("{0}/{1}", player.GetComponent <CharacterStats>().Fishing.GetExp(), player.GetComponent <CharacterStats>().Fishing.GetExpToLevel());
        fisherExp.width     = AdjustBarSize(fisherExp.Maxwidth, player.GetComponent <CharacterStats>().Fishing.GetExp(), player.GetComponent <CharacterStats>().Fishing.GetExpToLevel());
        fisherExpBar.GetComponent <RectTransform>().sizeDelta = new Vector2(fisherExp.width, fisherExp.expbarSize.y);
        //miner
        minerExpLabel.text = string.Format("{0}/{1}", player.GetComponent <CharacterStats>().Mining.GetExp(), player.GetComponent <CharacterStats>().Mining.GetExpToLevel());
        minerExp.width     = AdjustBarSize(minerExp.Maxwidth, player.GetComponent <CharacterStats>().Mining.GetExp(), player.GetComponent <CharacterStats>().Mining.GetExpToLevel());
        minerExpBar.GetComponent <RectTransform>().sizeDelta = new Vector2(minerExp.width, minerExp.expbarSize.y);

        //stats
        stats1.text = string.Format(
            "Health: {0}/{1}\n" +
            "Slime: {2}/{3}\n" +
            "Element Slots: {4}\n" +
            "Action Points: {5}/{6}",
            playerStats.healthCurrent.ToString(), playerStats.currentStats.health.ToString(),
            playerStats.slimeCurrent.ToString(), playerStats.currentStats.slime.ToString(),
            playerStats.currentStats.elementSlots.ToString(),
            playerStats.actionPointsCurent.ToString(), playerStats.currentStats.actionPoints.ToString());
        stats2.text = string.Format(
            "Res:\n" +
            "Fire    - {0}\n" +
            "Water   - {1}\n" +
            "Earth   - {2}\n" +
            "Wind    - {3}\n" +
            "Light   - {4}\n" +
            "Dark    - {5}\n" +
            "Neutral - {6}",
            playerStats.currentStats.fixedDamageStats[DictionaryHolder.element.Fire].ToString(),
            playerStats.currentStats.fixedDamageStats[DictionaryHolder.element.Water].ToString(),
            playerStats.currentStats.fixedDamageStats[DictionaryHolder.element.Earth].ToString(),
            playerStats.currentStats.fixedDamageStats[DictionaryHolder.element.Wind].ToString(),
            playerStats.currentStats.fixedDamageStats[DictionaryHolder.element.Fire].ToString(),
            playerStats.currentStats.fixedDamageStats[DictionaryHolder.element.Dark].ToString(),
            playerStats.currentStats.fixedDamageStats[DictionaryHolder.element.Neutral].ToString());
        stats3.text = string.Format(
            "Damage:\n" +
            "Fire    - {0}\n" +
            "Water   - {1}\n" +
            "Earth   - {2}\n" +
            "Wind    - {3}\n" +
            "Light   - {4}\n" +
            "Dark    - {5}\n" +
            "Neutral - {6}",
            playerStats.currentStats.percentDamageStats[DictionaryHolder.element.Fire].ToString(),
            playerStats.currentStats.percentDamageStats[DictionaryHolder.element.Water].ToString(),
            playerStats.currentStats.percentDamageStats[DictionaryHolder.element.Earth].ToString(),
            playerStats.currentStats.percentDamageStats[DictionaryHolder.element.Wind].ToString(),
            playerStats.currentStats.percentDamageStats[DictionaryHolder.element.Fire].ToString(),
            playerStats.currentStats.percentDamageStats[DictionaryHolder.element.Dark].ToString(),
            playerStats.currentStats.percentDamageStats[DictionaryHolder.element.Neutral].ToString());
        stats4.text = string.Format(
            "Damage(%):\n" +
            "Fire    - {0}%\n" +
            "Water   - {1}%\n" +
            "Earth   - {2}%\n" +
            "Wind    - {3}%\n" +
            "Light   - {4}%\n" +
            "Dark    - {5}%\n" +
            "Neutral - {6}%",
            playerStats.currentStats.fixedResStats[DictionaryHolder.element.Fire].ToString(),
            playerStats.currentStats.fixedResStats[DictionaryHolder.element.Water].ToString(),
            playerStats.currentStats.fixedResStats[DictionaryHolder.element.Earth].ToString(),
            playerStats.currentStats.fixedResStats[DictionaryHolder.element.Wind].ToString(),
            playerStats.currentStats.fixedResStats[DictionaryHolder.element.Fire].ToString(),
            playerStats.currentStats.fixedResStats[DictionaryHolder.element.Dark].ToString(),
            playerStats.currentStats.fixedResStats[DictionaryHolder.element.Neutral].ToString());
    }
コード例 #3
0
 private void UpdateInDeCreaseMapSizeButtons()
 {
     increaseMapButton.GetComponent <Button>().interactable = ((StoryProgressionManager.GetMapSize() + 1 > StoryProgressionManager.GetMapSizeMaxUnlocked()) ? false : true);
     decreaseMapButton.GetComponent <Button>().interactable = ((StoryProgressionManager.GetMapSize() - 1 <= 0) ? false : true);
 }