// Update is called once per frame
    void Update()
    {
        if (player == null)
        {
            player = GameObject.Find("PlayerState").GetComponent <Playerstats> ();
        }
        else
        {
            if (Application.loadedLevelName == "Main")
            {
                if (curLevel != "Main")
                {
                    curLevel = "Main";
                }
                reportLapScore();
            }
            if (Application.loadedLevelName == "Blitz")
            {
                if (curLevel != "Blitz")
                {
                    blitzButton = GameObject.Find("GraphicManager/LapButton").GetComponent <LapButtonBlitz> ();
                    Debug.Log("Found Button");
                    curLevel = "Blitz";
                }
                reportBlitz();
            }

            if (lapCoin == null)
            {
                lapCoin = GameObject.Find("GraphicManager/LapCoins/AchievementText");
            }
        }
    }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     player = GameObject.FindGameObjectWithTag ("Player");
     anim = GetComponentInChildren<Animator> ();
     sound = GetComponent<AudioSource> ();
     stats = player.GetComponent<Playerstats> ();
 }
 // Use this for initialization
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     anim   = GetComponentInChildren <Animator> ();
     sound  = GetComponent <AudioSource> ();
     stats  = player.GetComponent <Playerstats> ();
 }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     setBG = PlayerPrefs.GetString ("cBG", "City");
     player = GameObject.Find ("PlayerState").GetComponent<Playerstats> ();
     countLap = player.score;
     player.curBG = setBG;
 }
 // Use this for initialization
 void Start()
 {
     DontDestroyOnLoad(gameObject);
     player      = GameObject.Find("PlayerState").GetComponent <Playerstats> ();
     blitzButton = GameObject.Find("GraphicManager/LapButton").GetComponent <LapButtonBlitz> ();
     lapCoin     = GameObject.Find("GraphicManager/LapCoins/AchievementText");
 }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     setBG        = PlayerPrefs.GetString("cBG", "City");
     player       = GameObject.Find("PlayerState").GetComponent <Playerstats> ();
     countLap     = player.score;
     player.curBG = setBG;
 }
Ejemplo n.º 7
0
 // Update is called once per frame
 void Update()
 {
     if (hasReset) {
         //do something when the player tapped reset
         stats.score = 0;
         player = GameObject.FindGameObjectWithTag ("Player");
         stats = player.GetComponent<Playerstats> ();
         hasReset = false;
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (hasLapped)
     {
         //do something when the player tapped lap
         Playerstats stats = player.GetComponent <Playerstats> ();
         stats.score++;
         hasLapped = false;
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (hasReset)
     {
         //do something when the player tapped reset
         stats.score = 0;
         player      = GameObject.FindGameObjectWithTag("Player");
         stats       = player.GetComponent <Playerstats> ();
         hasReset    = false;
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (hasLapped)
     {
         //do something when the player tapped lap
         Playerstats stats = player.GetComponent <Playerstats> ();
         stats.startedPlay = true;
         stats.score++;
         stats.curLaps1++;
         stats.curLaps2++;
         stats.curLaps3++;
         stats.curLaps4++;
         hasLapped = false;
     }
 }
Ejemplo n.º 11
0
 // Update is called once per frame
 void Update()
 {
     Pstats = GetComponent <Playerstats>();
     Estats = GetComponent <Enemystats>();
     if (Input.GetKeyDown(KeyCode.Space))
     {
         //Checker for successful interaction based on chances for different enemies.
         int EH    = Random.Range(Estats.health, Estats.health + 101);
         int Hdiff = EH - Pstats.Health;
         if (Hdiff < Pstats.Health)
         {
             if (Random.Range(1, 11) > 2)
             {
                 Attack(EH, Pstats.Dmg);
             }
             else
             {
                 Debug.Log("Attack missed");
             }
         }
         if (Hdiff > Pstats.Health)
         {
             if (Random.Range(1, 11) > 6)
             {
                 Attack(EH, Pstats.Dmg);
             }
             else
             {
                 Debug.Log("Attack missed");
             }
         }
         if (Hdiff == Pstats.Health)
         {
             if (Random.Range(1, 11) > 4)
             {
                 Attack(EH, Pstats.Dmg);
             }
             else
             {
                 Debug.Log("Attack missed");
             }
         }
     }
 }
Ejemplo n.º 12
0
    public void calculateResults()
    {
        currentQuestResult = 0;
        int questnum = 0;

        //Sorted player list
        Playerstats[] playerlist = new Playerstats[Mathf.Max(3, GetComponent <PlayersTracker>().players.Count)];
        foreach (Playerstats player in GetComponent <PlayersTracker>().players)
        {
            //places players in list based on order of tasks
            playerlist [selectedPlayers [player.name] - 1] = player;
        }

        for (int i = 0; i < 3; i++)
        {
            resultsUI [i] = new QuestResults();
        }
        int tasknum = 0;

        //assigns each player to their task
        for (int i = 0; i < activeQuests.Count; i++)
        {
            //if quest doen't have players sullected cause less then 3 people skip
            if (playerlist[tasknum] == null)
            {
                tasknum++;
                continue;
            }
            resultsUI [i] = new QuestResults();
            resultsUI[i].addQuest(activeQuests [i]);
            int i2 = 0;
            //adding to task per quest
            foreach (Task task in activeQuests[i].tasks)
            {
                resultsUI [i].addPlayer(i2, playerlist [tasknum]);
                i2++;
                tasknum++;
            }
        }
        GetComponent <CanvasManager>().displayNextquest();
    }
Ejemplo n.º 13
0
    // Rolls stats for any amount of players, clears the old stats and stores the new ones.
    public void GenerateStats(int numPlayers, string[] names)
    {
        players.Clear();

        //Generate stats for each player
        for (int x = 0; x < numPlayers; x++)
        {
            int[] Passion = { -5, -5, -5, -5, -5 };
            int[] Skill = { 0, 0, 0, 0, 0 };
            float Greed, Need;

            List <int> pList = new List <int> {
                -5, -2, 0, 2, 5
            };
            List <int> sList = new List <int> {
                1, 3, 5, 7, 9
            };

            // Randomly assign which stat gets which number
            for (int i = 5; i > 1; i--)
            {
                int index = Random.Range(0, i);
                Passion[i - 1] = pList[index];
                pList.RemoveAt(index);
                index        = Random.Range(0, i);
                Skill[i - 1] = sList[index];
                sList.RemoveAt(index);
            }
            Passion[0] = pList[0];
            Skill[0]   = sList[0];

            // Goes through 5 rounds of "Mutations" which add to 1 stat and subtract from another.
            for (int i = 0; i < 5; i++)
            {
                int indexA = Random.Range(0, 5);
                while (Passion[indexA] <= -5)
                {
                    indexA = Random.Range(0, 5);
                }
                int indexB = indexA;
                while (indexB == indexA || Passion[indexB] >= 5)
                {
                    indexB = Random.Range(0, 5);
                }
                Passion[indexA] -= 1;
                Passion[indexB] += 1;

                indexA = Random.Range(0, 5);
                while (Skill[indexA] <= 0)
                {
                    indexA = Random.Range(0, 5);
                }
                indexB = indexA;
                while (indexB == indexA || Skill[indexB] >= 10)
                {
                    indexB = Random.Range(0, 5);
                }
                Skill[indexA] -= 1;
                Skill[indexB] += 1;
            }

            // Greed and need are from 0-1
            Greed = Random.Range(0, 11) / 10f;
            Need  = Random.Range(0, 11) / 10f;

            // set the values and then generates a display
            Playerstats playerstats = new Playerstats();
            playerstats.Passion = Passion;
            playerstats.Skill   = Skill;
            playerstats.Greed   = Greed;
            playerstats.Need    = Need;
            playerstats.name    = names[x];
            players.Add(playerstats);
        }
    }
Ejemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     player = GameObject.FindGameObjectWithTag ("Player");
     stats = player.GetComponent<Playerstats> ();
 }
Ejemplo n.º 15
0
 // Use this for initialization
 void Start()
 {
     avatarAni = gameObject.GetComponent<Animator> ();
     player = GameObject.Find("PlayerState").GetComponent<Playerstats>();
 }
Ejemplo n.º 16
0
 void Start()
 {
     player = GameObject.Find("PlayerState").GetComponent <Playerstats> ();
 }
Ejemplo n.º 17
0
 private void Start()
 {
     money = rfpc.GetComponent <Playerstats>();
     FindObjectOfType <AudioManager>().Play("MainTheme");
 }
Ejemplo n.º 18
0
    // Update is called once per frame
    void Update()
    {
        if (player == null) {
                        player = GameObject.Find ("PlayerState").GetComponent<Playerstats> ();
                } else {
            if (Application.loadedLevelName == "Main") {
                if (curLevel != "Main") {
                    curLevel = "Main";
                }
                                reportLapScore ();
                        }
            if (Application.loadedLevelName == "Blitz") {
                if (curLevel != "Blitz") {
                    blitzButton = GameObject.Find ("GraphicManager/LapButton").GetComponent<LapButtonBlitz> ();
                    Debug.Log("Found Button");
                    curLevel = "Blitz";
                }
                                reportBlitz ();
                        }

                        if (lapCoin == null) {
                lapCoin = GameObject.Find ("GraphicManager/LapCoins/AchievementText");
                        }
                }
    }
Ejemplo n.º 19
0
 // Use this for initialization
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     stats  = player.GetComponent <Playerstats> ();
 }
Ejemplo n.º 20
0
    public void displayNextquest()
    {
        //if end of quests turn off an "reset" results
        if (GetComponent <GameLoopManager> ().currentQuestResult >= GetComponent <GameLoopManager> ().getActiveQuestNumber())
        {
            ToggleResults();
            GetComponent <GameLoopManager> ().RollJobs();
            GetComponent <GameLoopManager> ().currentQuestResult = 0;
            return;
        }
        QuestResults result = GetComponent <GameLoopManager> ().resultsUI [GetComponent <GameLoopManager> ().currentQuestResult];

        //if quest was not given a player move on to next quest
        while (!result.unselected)
        {
            GetComponent <GameLoopManager> ().currentQuestResult++;
            if (GetComponent <GameLoopManager> ().currentQuestResult >= GetComponent <GameLoopManager> ().getActiveQuestNumber())
            {
                ToggleResults();
                GetComponent <GameLoopManager> ().RollJobs();
                GetComponent <GameLoopManager> ().currentQuestResult = 0;
                return;
            }
            result = GetComponent <GameLoopManager> ().resultsUI [GetComponent <GameLoopManager> ().currentQuestResult];
        }
        Quest quest = result.quest;

        //set quest name, i think this needs a fix sorry
        resultsCanvas.transform.GetChild(2).GetComponent <Text> ().text = result.quest.title;

        int  taskWins     = 0;
        bool questSuccess = true;

        //figuring out task results for sake of quest success/failure and also setting task success + name
        for (int taskNum = 0; taskNum < 4; taskNum++)
        {
            GameObject taskUI = taskUIs[taskNum];
            Text[]     texts  = taskUI.GetComponentsInChildren <Text> ();
            //if task doesn't exist skipp and set blank
            if (taskNum >= quest.tasks.Length)
            {
                texts [0].text = "";
                texts [2].text = "";
                //set image to blank
                continue;
            }
            Playerstats player = result.playerlist [taskNum];
            Task        task   = quest.tasks[taskNum];
            texts [0].text = player.name;
            int stat = 0;
            if (task.stat == Task.Stat.Fight)
            {
                stat = 0;
                //also set image
            }
            else if (task.stat == Task.Stat.Charm)
            {
                stat = 1;
                //also set image
            }
            else if (task.stat == Task.Stat.Agility)
            {
                stat = 2;
                //also set image
            }
            else if (task.stat == Task.Stat.Smarts)
            {
                stat = 3;
                //also set image
            }
            else if (task.stat == Task.Stat.Magic)
            {
                stat = 4;
                //also set image
            }
            //sucesses at task text
            if (task.difficulty <= player.Skill [stat])
            {
                //Successful task
                texts [2].text = player.name + " has succeeded at their " + statTypes[stat] + " task.\n";
                taskWins++;
            }
            else
            {
                texts [2].text = player.name + " has failed their " + statTypes[stat] + " task.\n";
            }
        }
        //sets if the quest failed or succeded
        if (taskWins == 0 || taskWins * 2 < quest.tasks.Length)
        {
            questSuccess = false;
            GameObject.Find("Fail/Success").GetComponent <Text> ().text = "Failed Quest";
        }
        else
        {
            GameObject.Find("Fail/Success").GetComponent <Text> ().text = "Successful Quest";
        }

        // Set the quest result text
        if (questSuccess)
        {
            resultsCanvas.transform.GetChild(4).GetComponent <Text>().text = quest.succeed;
        }
        else
        {
            resultsCanvas.transform.GetChild(4).GetComponent <Text>().text = quest.fail;
        }

        // set image for money based on success/failure/ammount of money
        string output = "";

        if (!questSuccess)
        {
            output += "You got no money,";
            GameObject.Find("MoneyAmount").GetComponent <Image>().sprite = moneySprites[0];
        }
        else
        {
            if (quest.money == -5)
            {
                output += "You got no money,";
                GameObject.Find("MoneyAmount").GetComponent <Image>().sprite = moneySprites[0];
            }
            else if (quest.money == 5)
            {
                output += "You got a lot of money,";
                GameObject.Find("MoneyAmount").GetComponent <Image>().sprite = moneySprites[4];
            }
            else if (quest.money <= -2)
            {
                output += "You got very little money,";
                GameObject.Find("MoneyAmount").GetComponent <Image>().sprite = moneySprites[1];
            }
            else if (quest.money <= 1)
            {
                output += "You got an average amount of money,";
                GameObject.Find("MoneyAmount").GetComponent <Image>().sprite = moneySprites[2];
            }
            else
            {
                output += "You got a good amount of money,";
                GameObject.Find("MoneyAmount").GetComponent <Image>().sprite = moneySprites[3];
            }
        }

        if (questSuccess)
        {
            if (Mathf.Abs(quest.money - quest.need) >= 7)
            {
                output += " but\n";
            }
            else
            {
                output += " and\n";
            }
        }
        else
        {
            if (quest.need <= -2)
            {
                output += " but\n";
            }
            else
            {
                output += " and\n";
            }
        }

        //set world stat text based on success/failure/ammount of world change
        if (questSuccess)
        {
            if (quest.need == -5)
            {
                output += "the world is worse now.";
            }
            else if (quest.need == 5)
            {
                output += "you did a great deed!";
            }
            else if (quest.need <= -2)
            {
                output += "you did a pretty bad thing.";
            }
            else if (quest.need <= 1)
            {
                output += "life goes on as usual.";
            }
            else
            {
                output += "you helped some people today!";
            }
        }
        else
        {
            if (quest.need == -5)
            {
                output += "the world is glad you failed.";
            }
            else if (quest.need == 5)
            {
                output += "you failed, when the world desperately needed you.";
            }
            else if (quest.need <= -2)
            {
                output += "it's probably a good thing you failed...";
            }
            else if (quest.need <= 1)
            {
                output += "life goes on as usual anyway.";
            }
            else
            {
                output += "you missed an opportunity to help others.";
            }
        }

        GameObject.Find("Money&Need").GetComponent <Text>().text = output;

        //going through tasks to set ikigai
        for (int taskNum = 0; taskNum < 4; taskNum++)
        {
            GameObject taskUI = taskUIs[taskNum];
            Text[]     texts  = taskUI.GetComponentsInChildren <Text> ();
            if (taskNum >= quest.tasks.Length)
            {
                texts [1].text = "";
                //set image to blank
                taskUI.SetActive(false);
                continue;
            }
            taskUI.SetActive(true);

            Playerstats player = result.playerlist [taskNum];
            Task        task   = quest.tasks[taskNum];
            int         stat   = 0;
            if (task.stat == Task.Stat.Fight)
            {
                stat = 0;
            }
            else if (task.stat == Task.Stat.Charm)
            {
                stat = 1;
            }
            else if (task.stat == Task.Stat.Agility)
            {
                stat = 2;
            }
            else if (task.stat == Task.Stat.Smarts)
            {
                stat = 3;
            }
            else if (task.stat == Task.Stat.Magic)
            {
                stat = 4;
            }

            // set stat picture
            taskUI.GetComponentInChildren <Image>().sprite = statSprites[stat];

            //setting ikigai number
            int ikigai = 0;
            if (questSuccess)
            {
                //Successful quest
                ikigai = GetComponent <GameLoopManager> ().calculateIkigai(player.Passion[stat], quest.money, player.Greed, quest.need, player.Need);
            }
            else
            {
                //Failed quest
                ikigai = GetComponent <GameLoopManager> ().calculateIkigai(player.Passion[stat], -5, player.Greed, quest.need * -1, player.Need);
            }
            texts[1].text = ikigai.ToString();
            if (ikigai > 0)
            {
                texts[1].color = Color.green;
            }
            else if (ikigai < 0)
            {
                texts[1].color = Color.red;
            }
            else
            {
                texts[1].color = Color.white;
            }
        }
        GetComponent <GameLoopManager> ().currentQuestResult++;
    }
Ejemplo n.º 21
0
 // Use this for initialization
 void Start()
 {
     avatarAni = gameObject.GetComponent <Animator> ();
     player    = GameObject.Find("PlayerState").GetComponent <Playerstats>();
 }
Ejemplo n.º 22
0
 void Start()
 {
     player = GameObject.Find ("PlayerState").GetComponent<Playerstats> ();
 }
Ejemplo n.º 23
0
 // Use this for initialization
 void Start()
 {
     playerStats = GameObject.Find("PlayerState").GetComponent<Playerstats>();
     sound = GetComponent<AudioSource> ();
     anim = GetComponent<Animator> ();
 }
Ejemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     playerStats = GameObject.Find("PlayerState").GetComponent <Playerstats>();
     sound       = GetComponent <AudioSource> ();
     anim        = GetComponent <Animator> ();
 }
Ejemplo n.º 25
0
 public void addPlayer(int task, Playerstats player)
 {
     playerlist [task] = player;
     unselected        = true;
 }
Ejemplo n.º 26
0
 // Use this for initialization
 void Start()
 {
     DontDestroyOnLoad (gameObject);
     player = GameObject.Find("PlayerState").GetComponent<Playerstats> ();
     blitzButton = GameObject.Find ("GraphicManager/LapButton").GetComponent<LapButtonBlitz> ();
     lapCoin = GameObject.Find ("GraphicManager/LapCoins/AchievementText");
 }