Ejemplo n.º 1
0
    public List <Objective> GetCompletedExpectations(Athlete manager)
    {
        for (int i = 0; i < expectationsList.Count; i++)
        {
            Objective      expectation = expectationsList [i];
            TeamController team        = manager.GetTeam();

            switch (expectation.objectiveID)
            {
            case "gold":
                if (team.gold >= expectation.objectiveValue)
                {
                    Debug.Log("ENOUGH GOLD HAS BEEN COLLECTED");
                    expectation.completed = true;
                }
                break;

            case "win":
                if (team.winsThisSeason >= expectation.objectiveValue)
                {
                    Debug.Log("WINS HAVE BEEN COLLECTED ENOUGHLY");
                    expectation.completed = true;
                }
                break;

            case "prestige":
                if (team.prestige >= expectation.objectiveValue)
                {
                    Debug.Log("GOT ALL THEM PRESTIGES");
                    expectation.completed = true;
                }
                break;

            case "levelUp":
                Debug.Log("Not sure how to calculate");

                break;
            }
        }

        List <Objective> completedExpectations = new List <Objective> ();

        for (int i = 0; i < expectationsList.Count; i++)
        {
            if (expectationsList [i].completed)
            {
                completedExpectations.Add(expectationsList [i]);
            }
        }

        return(completedExpectations);
    }
    public GameObject GetNewTickBox(Athlete athlete, int cooldownEndTime)
    {
        GameObject tickBoxHolder = transform.GetChild(cooldownEndTime).GetChild(0).gameObject;

        GameObject newTickBox = Instantiate(tickBoxPrefab, tickBoxHolder.transform.localPosition, Quaternion.identity, tickBoxHolder.transform);
        Vector3    newPos     = tickBoxHolder.transform.localPosition;

        newPos.y -= (GetComponent <RectTransform>().rect.height *(tickBoxHolder.transform.childCount - 1));         //Subtract the height of the timeline times the number of children
        newPos.x  = 0;
        newTickBox.transform.localPosition = newPos;

        newTickBox.GetComponent <Image>().color = athlete.GetTeam().teamColor;

        return(newTickBox);
    }
    public void DisplayTickBoxHighlight(Athlete athlete, int cooldownEndTime)
    {
        if (matchManager.currentMatch.timeUnitsLeft > transform.childCount - 1)
        {
            tickBoxHighlight.GetComponent <Image>().enabled = true;
            tickBoxHighlight.GetComponent <Image>().color   = athlete.GetTeam().teamColor;

            GameObject tickBoxHolder = transform.GetChild(cooldownEndTime).GetChild(0).gameObject;

            Vector3 newPos = tickBoxHolder.transform.position;
            tickBoxHighlight.transform.position = newPos;

            newPos    = tickBoxHighlight.transform.localPosition;
            newPos.y -= (GetComponent <RectTransform>().rect.height *(tickBoxHolder.transform.childCount));             //Subtract the height of the timeline times the number of children
            tickBoxHighlight.transform.localPosition = newPos;
        }
    }
    public void SetAthletePanel(Athlete a)
    {
        athlete = a;

        button.onClick.RemoveAllListeners();

        if (athlete != null)
        {
            nameText.text     = a.name;
            positionText.text = a.positionName;

            bodyImg.enabled   = true;
            bodyImg.sprite    = a.bodySprite;
            bodyImg.color     = Color.white;
            jerseyImg.enabled = true;
            jerseyImg.sprite  = a.jerseySprite;
            jerseyImg.color   = a.GetTeam().teamColor;

            overallStatText.text = a.overallRating.ToString();

            descriptorPanel.SetActive(false);

            button.onClick.AddListener(() => gameController.DisplayAthletePanel(gameObject, a));
        }
        else
        {
            for (int i = 0; i < transform.childCount; i++)
            {
                transform.GetChild(i).gameObject.SetActive(false);
            }
            button.interactable = false;

            /*
             * nameText.text = "";
             * bodyImg.enabled = false;
             * jerseyImg.enabled = false;
             * positionText.text = "";
             * overallStatText.text = "";
             * descriptorPanel.SetActive (false);
             */
        }
    }
    public void SetAthleteMatchPanel(Athlete a)
    {
        athlete = a;

        if (athlete != null)
        {
            athlete.athleteMatchPanel = this;

            Color teamColor = athlete.GetTeam().teamColor;

            nameText.text     = athlete.name;
            bodyImg.sprite    = athlete.bodySprite;
            jerseyImg.sprite  = athlete.jerseySprite;
            jerseyImg.color   = teamColor;
            positionText.text = athlete.positionName;

            if (athlete.heldBall == null)
            {
                ballImg.enabled = false;
            }
            else
            {
                ballImg.enabled = true;
            }

            overallText.text = athlete.overallRating.ToString();

            /*
             * speedText.text = athlete.GetAttributeValue("speed").ToString();
             * strengthText.text = athlete.GetAttributeValue("strength").ToString();
             * ballControlText.text = athlete.GetAttributeValue("ball control").ToString();
             * defenseText.text = athlete.GetAttributeValue("defense").ToString();
             */

            selectionBorderImg.color = teamColor;
            //selectionBorderImg.enabled = false;

            button.enabled = true;
            button.onClick.RemoveAllListeners();

            if (athlete.currentFieldTile == null)
            {
                //actionSlider.value = actionSlider.maxValue;
                //actionSlider.GetComponentInChildren<Text>().text = "On the Bench";

                if (a.GetTeam() == GameController.playerManager.GetTeam())
                {
                    button.onClick.AddListener(() => matchManager.SelectAthlete(this));
                    selectionBorderImg.enabled = false;
                }
                else
                {
                    button.enabled = false;
                }
            }
            else
            {
                //actionSlider.GetComponentInChildren<Text>().text = "Waiting to Start the Match";

                if (a.GetTeam() == GameController.playerManager.GetTeam() && !matchManager.currentMatch.matchStarted)
                {
                    button.onClick.AddListener(() => matchManager.RemoveAthleteFromField(this));
                }
                else
                {
                    button.enabled = false;
                }

                selectionBorderImg.enabled = true;
            }
        }
        else
        {
            gameObject.SetActive(false);
        }
    }
Ejemplo n.º 6
0
    public void AssignExpectations(Athlete athlete)
    {
        expectationsList    = new List <Objective> ();
        bonusObjectivesList = new List <Objective> ();

        List <Objective> potentialExpectationsList    = new List <Objective> ();
        List <Objective> potentialBonusObjectivesList = new List <Objective> ();

        int careGold = GetOwnerValueValue("Gold");

        if (careGold > 0)
        {
            int goldNeeded = athlete.GetTeam().gold;     //The amount of gold the team currently has
            int extraGold  = Random.Range(10, 51) * 5;   //Between 50 and 250 additional gold, multiples of 5
            goldNeeded += extraGold;
            int       rewardGold    = extraGold / 10;    //A tenth of the extra gold will be rewarded to the manager
            Objective goldObjective = new Objective(athlete, "gold", goldNeeded, "gold", rewardGold);


            int highGoldNeeded = athlete.GetTeam().gold;         //The amount of gold the team currently has
            int highExtraGold  = Random.Range(50, 101) * 5;      //Between 250 and 500 additional gold, multiples of 5
            highGoldNeeded += highExtraGold;
            int       highRewardGold    = highExtraGold / 10;    //A tenth of the extra gold will be rewarded to the manager
            Objective highGoldObjective = new Objective(athlete, "gold", highGoldNeeded, "gold", highRewardGold);

            if (careGold >= 2)
            {
                potentialExpectationsList.Add(goldObjective);
                potentialBonusObjectivesList.Add(highGoldObjective);
            }
            else if (careGold == 1)
            {
                potentialBonusObjectivesList.Add(goldObjective);
            }
        }

        int careWins = GetOwnerValueValue("Wins");

        if (careWins > 0)
        {
            int       winsNeeded   = Random.Range(4, 7);
            int       rewardGold   = winsNeeded * 5;
            Objective winObjective = new Objective(athlete, "win", winsNeeded, "gold", rewardGold);

            int       highWinsNeeded   = Random.Range(7, 9);
            int       highRewardGold   = highWinsNeeded * 5;
            Objective highWinObjective = new Objective(athlete, "win", highWinsNeeded, "gold", highRewardGold);

            if (careWins >= 2)
            {
                potentialExpectationsList.Add(winObjective);
                potentialBonusObjectivesList.Add(highWinObjective);
            }
            else if (careWins == 1)
            {
                potentialBonusObjectivesList.Add(winObjective);
            }
        }

        int carePrestige = GetOwnerValueValue("Prestige");

        if (carePrestige > 0)
        {
            int       prestigeNeeded    = Random.Range(10, 21) * 10;     //Between 100 and 200, multiples of 10
            int       rewardGold        = prestigeNeeded / 5;
            Objective prestigeObjective = new Objective(athlete, "prestige", prestigeNeeded, "gold", rewardGold);

            int       highPrestigeNeeded    = Random.Range(20, 40) * 10;     //Between 200 and 400, multiples of 10
            int       highRewardGold        = highPrestigeNeeded / 5;
            Objective highPrestigeObjective = new Objective(athlete, "prestige", highPrestigeNeeded, "gold", highRewardGold);

            if (carePrestige >= 2)
            {
                potentialExpectationsList.Add(prestigeObjective);
                potentialBonusObjectivesList.Add(highPrestigeObjective);
            }
            else if (carePrestige == 1)
            {
                potentialBonusObjectivesList.Add(prestigeObjective);
            }
        }

        int careDevelop = GetOwnerValueValue("Development");

        if (careDevelop > 0)
        {
            int       levelUpsNeeded   = Random.Range(2, 5);      //Between 2 and 4
            int       rewardGold       = levelUpsNeeded * 20;
            Objective levelUpObjective = new Objective(athlete, "levelUp", levelUpsNeeded, "gold", rewardGold);

            int       highLevelUpsNeeded   = Random.Range(5, 8);     //Between 5 and 7
            int       highRewardGold       = highLevelUpsNeeded * 20;
            Objective highLevelUpObjective = new Objective(athlete, "levelUp", highLevelUpsNeeded, "gold", highRewardGold);

            /*
             * Athlete specificAthlete = athlete.GetTeam ().rosterList [Random.Range (0, athlete.GetTeam ().rosterList.Count)];
             * Objective levelUpSpecificAthleteObjective = new Objective (athlete, "levelUpSpecific", specificAthlete, "gold", rewardGold);
             */

            if (careDevelop >= 2)
            {
                potentialExpectationsList.Add(levelUpObjective);
                potentialBonusObjectivesList.Add(highLevelUpObjective);
            }
            else if (careDevelop == 1)
            {
                potentialBonusObjectivesList.Add(levelUpObjective);
            }

            /*
             * List<int> levelIntList = new List<int> ();
             * for (int i = 0; i < athlete.GetTeam ().rosterList.Count; i++) {
             *      levelIntList.Add (athlete.GetTeam ().rosterList [i].level);
             * }
             *
             * for (int i = 0; i < levelIntList.Count; i++) {
             *
             * }
             */
        }



        for (int i = 0; i < 3; i++)
        {
            if (potentialExpectationsList.Count > 0)
            {
                Objective newExpectation = potentialExpectationsList [Random.Range(0, potentialExpectationsList.Count)];
                potentialExpectationsList.Remove(newExpectation);

                expectationsList.Add(newExpectation);
            }

            if (potentialBonusObjectivesList.Count > 0)
            {
                Objective newBonusObjective = potentialBonusObjectivesList [Random.Range(0, potentialBonusObjectivesList.Count)];
                potentialBonusObjectivesList.Remove(newBonusObjective);

                bonusObjectivesList.Add(newBonusObjective);
            }
        }
    }