Пример #1
0
    public void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/playerData.nut"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/playerData.nut", FileMode.Open);
            playerData      data = (playerData)bf.Deserialize(file);

            //<<<-------------LOADING DATA--------------->>>
            Food          = data.food; Water = data.water; Honey = data.honey;
            storyProgress = data.storyProgress;
            for (int i = 0; i <= storyProgress; i++)
            {
                if (i == 0)
                {
                    highlightStory(i);
                }
                else
                {
                    highlightStory(i, i - 1);
                }
            }

            ChangeResourceText.UpdateUIResources(Food, Water, Honey);

            Hex a = Map.map.GetHexAt(data.q, data.r);           //store q and r of hex so it can be retreived
            SetHex(a);
            //<<<-------------END OF LOADING DATA--------------->>>

            file.Close();
        }
    }
Пример #2
0
    public void UpdateResources(int food, int water, int honey = 0)
    {
        if (Food + food < 0)
        {
            Food = 0;
        }
        else
        {
            Food += food;
        }

        if (Water + water < 0)
        {
            Water = 0;
        }
        else
        {
            Water += water;
        }

        if (Honey + honey < 0)
        {
            Honey = 0;
        }
        else
        {
            Honey += honey;
        }
        ChangeResourceText.UpdateUIResources(Food, Water, Honey);      //auto updates whenever there is a change
    }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        GenerateMap();
        //after generate map can generate more ocean tiles around the whole world that are in
        //a new array and are never interacted with

        //TODO: make place boy spawn on a random tile of specific elevation
        //easy to do: just loop through all tiles after map has been spawned and choose one close
        //to land
        PlaceBoy(Boy, 12, 11);
        FocusCameraOnBoy();
        highlightSelectableTiles(player.currentHex);
        ChangeResourceText.UpdateUIResources(player.Food, player.Water, player.Honey);
        Random.InitState(1);
        placeFlowers();         //CAN: place this after reinit of random for more fun generation if we want

        //rerandomises the seed so debugging isnt no fun
        Random.InitState(System.Environment.TickCount);
        if (player != null)
        {
            player.highlightCurrentObjective(0);
        }
    }
Пример #4
0
    //store the move for the character and then do the things in here
    public void doTurn(int turnNum)
    {
        UpdateDayResources();

        if (nextHex == currentHex || nextHex == null)
        {
            ChangeResourceText.UpdateUIResources(Food, Water, Honey);
            return;
        }
        if (backpack == null)
        {
            backpack      = UniquesBackpack.backpack;
            storyProgress = 0;
        }
        //set all the variables and stuff when the click happens, then call all the actual moving and updating of stuff here!
        //TODO: make it more clear when the player has selected a tile
        //have to pass as negative as we are taking these away as movement cost
        UpdateResources(-nextHex.foodCost, -nextHex.waterCost);

        //updates and resets event costs
        UpdateResources(ScenarioManager.foodResult, ScenarioManager.waterResult, ScenarioManager.honeyResult);
        ScenarioManager.honeyResult = 0; ScenarioManager.waterResult = 0; ScenarioManager.foodResult = 0;

        float rand = Random.Range(0f, 10f);

        highlightStory(storyProgress);

        if ((turnNum % 7 != 4))
        {
            //HERE: hard code a check for if the nextHex is a story location
            if (currentHex.hexMap.storyLocations.Contains(nextHex))                     //roundabout way of doing it but we get what we want
            {
                if (currentHex.hexMap.storyLocations.IndexOf(nextHex) == storyProgress) //checks if the next is the one we have progressed up to
                //THIS WORKS: AS IN - the recognition triggers
                //ONCOMPLETION: add 1 to story progress from within scenario manager and unset storyTrigger
                {
                    if (storyProgress == 0)
                    {
                        ScenarioManager.ChooseEvent(nextHex, 1000);                         //TRIGGERS AGAIN
                        storyTriggered = true;
                    }
                    else if (storyProgress == 1)
                    {
                        ScenarioManager.ChooseEvent(nextHex, 2000);
                        storyTriggered = true;
                    }
                    else if (storyProgress == 2)
                    {
                        ScenarioManager.ChooseEvent(nextHex, 3000);
                        storyTriggered = true;
                    }
                    else if (storyProgress == 3)
                    {
                        ScenarioManager.ChooseEvent(nextHex, 4000);
                        storyTriggered = true;
                    }
                    else if (storyProgress == 4)
                    {
                        ScenarioManager.ChooseEvent(nextHex, 5000);
                        storyTriggered = true;
                    }                    //else game should be over
                }
                else
                {
                    int currentLoc = currentHex.hexMap.storyLocations.IndexOf(nextHex);
                    if (currentLoc == 0)                                  //can only be after
                    {
                        ScenarioManager.ChooseEvent(nextHex, 1002, true); //___1 is before, ___2 is after
                    }
                    else if (currentLoc == 1)
                    {
                        if (currentLoc > storyProgress)
                        {
                            ScenarioManager.ChooseEvent(nextHex, 2001, true);                           //have no completed the event before this one
                        }
                        else if (currentLoc < storyProgress)
                        {
                            ScenarioManager.ChooseEvent(nextHex, 2002, true);                           //have completed this story event
                        }
                    }
                    else if (currentLoc == 2)
                    {
                        if (currentLoc > storyProgress)
                        {
                            ScenarioManager.ChooseEvent(nextHex, 3001, true);
                        }
                        else if (currentLoc < storyProgress)
                        {
                            ScenarioManager.ChooseEvent(nextHex, 3002, true);
                        }
                    }
                    else if (currentLoc == 3)
                    {
                        if (currentLoc > storyProgress)
                        {
                            ScenarioManager.ChooseEvent(nextHex, 4001, true);
                        }
                        else if (currentLoc < storyProgress)
                        {
                            ScenarioManager.ChooseEvent(nextHex, 4002, true);
                        }
                    }
                    else if (currentLoc == 4)
                    {
                        if (currentLoc > storyProgress)
                        {
                            ScenarioManager.ChooseEvent(nextHex, 5001, true);
                        }
                        else if (currentLoc < storyProgress)
                        {
                            ScenarioManager.ChooseEvent(nextHex, 5002, true);
                        }
                    }
                    //TODO: add events here so it doesnt trigger agin if already visited
                }
            }
            else if (rand < 4.1f)
            {
                //happens a turn late but at least it happens
                ScenarioManager.ChooseEvent(nextHex);
            }
        }

        AudioManager.audioManager.playSound("footsteps");
        ChangeResourceText.UpdateUIResources(Food, Water, Honey);
        //TODO: play walking animation
        SetHex(nextHex);
        unHighlightTile(nextHex.hexMap.hexToGameObjectMap[nextHex]);
    }