コード例 #1
0
ファイル: BarsMenu.cs プロジェクト: johannbjarka/TheGrind
    public void getSkills(Text _ID)
    {
        // Open the canvas
        SkillsCanvas.enabled = true;

        // Parse the ID into int
        int ID = Int32.Parse(_ID.text);

        // Search for the employee character and fill in the skills.
        foreach (var emp in myCompany.characters)
        {
            if (emp.ID == ID)
            {
                fillSkillBars(emp);
            }
        }
        foreach (var appl in myCompany.applicants)
        {
            if (appl.ID == ID)
            {
                fillSkillBars(appl);
            }
        }
        // Play click sound
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #2
0
ファイル: ComputerMenu.cs プロジェクト: johannbjarka/TheGrind
    public void closeComputerPanel()
    {
        ComputerMenuCanvas.enabled = false;
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #3
0
ファイル: FireConfirm.cs プロジェクト: johannbjarka/TheGrind
    public void openFireConfirm(Text _id)
    {
        Company myCompany = GameObject.Find("Company").GetComponent <Company>();
        int     ID        = Int32.Parse(_id.text);

        isOpen = !isOpen;
        fireConfirmView.SetActive(!fireConfirmView.activeSelf);
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
        foreach (Character emp in myCompany.characters)
        {
            if (emp.ID == ID)
            {
                if (emp.gender == 'M')
                {
                    fireText.text = "If you fire " + emp.characterName +
                                    " you will have to pay him a severance package of $" + emp.salary.ToString();
                }
                else
                {
                    fireText.text = "If you fire " + emp.characterName +
                                    " you will have to pay her a severance package of $" + emp.salary.ToString();
                }
            }
        }
    }
コード例 #4
0
ファイル: BarsMenu.cs プロジェクト: johannbjarka/TheGrind
    public void closeSkills()
    {
        SkillsCanvas.enabled = false;
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #5
0
    public void openMonthlyReview()
    {
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
        isOpen = !isOpen;
        monthlyReview.enabled = !monthlyReview.enabled;
    }
コード例 #6
0
    public void openCalendar()
    {
        isOpen = !isOpen;
        calendarClickView.enabled = !calendarClickView.enabled;
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #7
0
ファイル: OpenBudget.cs プロジェクト: johannbjarka/TheGrind
    public void openBudget()
    {
        isOpen             = !isOpen;
        budgetView.enabled = !budgetView.enabled;
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #8
0
ファイル: ComputerMenu.cs プロジェクト: johannbjarka/TheGrind
    public void openComputerMenuPanel()
    {
        myContinueClass.closeEverything();
        ComputerMenuCanvas.enabled = true;
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #9
0
    public void openTooMany()
    {
        isOpen = !isOpen;
        tooManyView.enabled = !tooManyView.enabled;
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #10
0
ファイル: ComputerMenu.cs プロジェクト: johannbjarka/TheGrind
    public void openApplicantsMenu()
    {
        closeComputerPanel();
        applicantsMenuIsOpen     = !applicantsMenuIsOpen;
        ApplicantsCanvas.enabled = !ApplicantsCanvas.enabled;
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #11
0
ファイル: ComputerMenu.cs プロジェクト: johannbjarka/TheGrind
    public void openAvailableProjects()
    {
        closeComputerPanel();
        availableProjectsIsOpen         = !availableProjectsIsOpen;
        AvailableProjectsCanvas.enabled = !AvailableProjectsCanvas.enabled;
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #12
0
ファイル: ComputerMenu.cs プロジェクト: johannbjarka/TheGrind
    public void openEmployeeRecords()
    {
        closeComputerPanel();
        employeeRecordsIsOpen         = !employeeRecordsIsOpen;
        EmployeeRecordsCanvas.enabled = !EmployeeRecordsCanvas.enabled;
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #13
0
ファイル: ComputerMenu.cs プロジェクト: johannbjarka/TheGrind
    public void closeCurrentProjects()
    {
        closeComputerPanel();
        currentProjectsIsOpen         = false;
        CurrentProjectsCanvas.enabled = false;
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
    }
コード例 #14
0
    public void removeFromProject(Text _id)
    {
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();
        int id = Int32.Parse(_id.text);
        CreateScrollList list = GameObject.Find("Main Camera").GetComponent <CreateScrollList>();

        list.populateProjectEmployeeList(id);
    }
コード例 #15
0
    public void selectProject(Text _id)
    {
        ClickSound click = GameObject.FindWithTag("ClickSound").GetComponent <ClickSound>();

        click.playSound();

        myCompany = GameObject.Find("Company").GetComponent <Company>();
        int id = Int32.Parse(_id.text);

        myCompany.selectedProject = id;
        // Takes player to menu to select employees for project
        CreateScrollList list = GameObject.Find("Main Camera").GetComponent <CreateScrollList>();

        list.PopulateAvailableInitialEmployeeList(id);
    }
コード例 #16
0
    public void addEmployee(IDPair ids)
    {
        click.playSound();

        Company myCompany  = GameObject.Find("Company").GetComponent <Company>();
        int     projectID  = Int32.Parse(ids.projectID.text);
        int     employeeID = Int32.Parse(ids.employeeID.text);
        float   ratio      = 0.0f;

        foreach (Project proj in myCompany.projects)
        {
            if (proj.ID == projectID)
            {
                foreach (Character emp in myCompany.characters)
                {
                    if (emp.ID == employeeID)
                    {
                        emp.onProject = true;
                        emp.project   = proj.projName;
                        proj.employees.Add(emp);
                        proj.workEstimate += emp.speed * proj.deadline;
                        Destroy(availableEmployeePanel);

                        GameObject    newPanel = Instantiate(projectEmployeePanel) as GameObject;
                        EmployeePanel panel    = newPanel.GetComponent <EmployeePanel> ();
                        panel.nameLabel.text = emp.characterName;
                        if (emp.gender == 'M')
                        {
                            panel.genderLabel.text = emp.gender.ToString() + "ale";
                        }
                        else
                        {
                            panel.genderLabel.text = emp.gender.ToString() + "emale";
                        }
                        panel.moraleLabel.text           = emp.morale.ToString();
                        panel.moraleBar.sizeDelta        = new Vector2(emp.morale * 10, 20);
                        panel.speedLabel.text            = emp.speed.ToString();
                        panel.speedBar.sizeDelta         = new Vector2(emp.speed * 10, 20);
                        panel.employeeIcon.sprite        = emp.sprite;
                        panel.ID.text                    = emp.ID.ToString();
                        panel.ProjectID.text             = proj.ID.ToString();
                        panel.rating.text                = emp.skills[proj.category].ToString() + " / 20";
                        panel.requiredSkillBar.sizeDelta = new Vector2(emp.skills[proj.category] * 10, 20);

                        newPanel.transform.SetParent(projectEmployeeContentPanel);
                        panel.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                        break;
                    }
                }
                ratio = (float)proj.workEstimate / proj.initialWorkAmount;
                break;
            }
        }
        ProgressFill.setFinalProgressTo(ratio);
    }
コード例 #17
0
 public void openMenu()
 {
     click.playSound();
     MenuCanvas.enabled = !MenuCanvas.enabled;
 }
コード例 #18
0
ファイル: Continue.cs プロジェクト: johannbjarka/TheGrind
    public void continueGame()
    {
        click.playSound();
        closeEverything();


        myCompany = GameObject.Find("Company").GetComponent <Company>();
        myCompany.weeksPassed++;

        for (int i = 0; i < 20; i++)
        {
            myCompany.tableFlowers[i] = Random.Range(0, 4);
        }
        for (int i = 0; i < myCompany.availableProjects.Count; i++)
        {
            myCompany.availableProjects[i].deadline--;
        }

        for (int i = 0; i < myCompany.availableProjects.Count; i++)
        {
            if (myCompany.availableProjects[i].deadline == 0)
            {
                myCompany.availableProjects.Remove(myCompany.availableProjects[i]);
            }
        }

        for (int i = 0; i < myCompany.projects.Count; i++)
        {
            myCompany.projects[i].deadline--;

            // Calculate the amount of work done on each project
            foreach (Character emp in myCompany.projects[i].employees)
            {
                myCompany.projects[i].workAmount -= emp.speed;
            }
            // If the project is finished, add it to completed projects, add the
            // reward to the budget and remove it from projects.
            if (myCompany.projects[i].workAmount <= 0)
            {
                if (!myCompany.projects[i].isFinished)
                {
                    myCompany.completedProjects.Add(myCompany.projects[i]);
                    myCompany.budget.projectRewards += myCompany.projects[i].reward;
                    myCompany.month.numberOfProjectsFinished++;
                    GameObject         newPanel = Instantiate(projectFinishedPanel) as GameObject;
                    ProjectFinishPanel panel    = newPanel.GetComponent <ProjectFinishPanel>();
                    panel.projName.text     = myCompany.projects[i].projName;
                    panel.rewPen.text       = "Reward for project:";
                    panel.rewPenAmount.text = "$" + myCompany.projects[i].reward.ToString();
                    panel.grade.text        = myCompany.projects[i].calcGrade().ToString();
                    panel.isProjDone.text   = "Good job! You finished the project in time.";
                    newPanel.transform.SetParent(projectFinishedContentPanel);
                    panel.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                    panel.transform.position   = new Vector3(0, 3.5f, 0);
                    // Remove employees from the project
                    foreach (Character emp in myCompany.projects[i].employees)
                    {
                        emp.onProject          = false;
                        emp.transform.position = new Vector3(-8 + Random.value * 10, -2 + Random.value * 5, 0);
                    }
                    myCompany.projects[i].isFinished = true;
                }
            }

            // If a project's deadline has passed and it's not finished we
            // remove it from projects and add the penalty to projectPenalties.
            if (myCompany.projects[i].deadline <= 0 && myCompany.projects[i].workAmount > 0)
            {
                if (!myCompany.projects[i].isFinished)
                {
                    myCompany.budget.projectPenalties += myCompany.projects[i].penalty;
                    myCompany.jobSecurity             -= 5;
                    GameObject         newPanel = Instantiate(projectFinishedPanel) as GameObject;
                    ProjectFinishPanel panel    = newPanel.GetComponent <ProjectFinishPanel>();
                    panel.projName.text     = myCompany.projects[i].projName;
                    panel.rewPen.text       = "Penalty for project";
                    panel.rewPenAmount.text = myCompany.projects[i].penalty.ToString();
                    panel.grade.text        = "-";
                    panel.isProjDone.text   = "Oh no! You didn't finish in time. The project needed more employees.";
                    newPanel.transform.SetParent(projectFinishedContentPanel);
                    panel.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                    panel.transform.position   = new Vector3(0, 3.5f, 0);
                    // Remove employees from the project
                    foreach (Character emp in myCompany.projects[i].employees)
                    {
                        emp.onProject          = false;
                        emp.transform.position = new Vector3(-8 + Random.value * 10, -2 + Random.value * 5, 0);
                    }
                    myCompany.projects[i].isFinished = true;
                }
            }
        }

        for (int i = 0; i < myCompany.projects.Count; i++)
        {
            if ((myCompany.projects[i].workAmount <= 0) ||
                (myCompany.projects[i].deadline == 0))
            {
                myCompany.projects.Remove(myCompany.projects[i]);
            }
        }

        foreach (Project proj in myCompany.availableProjects)
        {
            if (proj.deadline <= 0)
            {
                proj.isFinished = true;
            }
        }

        for (int i = 0; i < myCompany.availableProjects.Count; i++)
        {
            if (myCompany.availableProjects[i].isFinished)
            {
                myCompany.availableProjects.Remove(myCompany.availableProjects[i]);
            }
        }

        // If a month has passed
        if ((myCompany.weeksPassed % 4) == 0)
        {
            MonthlyReview monthly        = GameObject.Find("Monthly").GetComponent <MonthlyReview>();
            int           monthlyBalance = myCompany.budget.getBalance();
            myCompany.month.getGrade();
            myCompany.budget.monthlyAmount = myCompany.month.getNextAllowance();
            myCompany.setPercentageText();
            myCompany.getNextGoal();
            myCompany.budget.lastBalance         = myCompany.budget.getBalance();
            myCompany.budget.totalFunding       += myCompany.budget.monthlyAmount;
            myCompany.budget.totalTotalSalaries += myCompany.budget.totalSalaries;
            myCompany.setTextFields(monthlyBalance);

            if (myCompany.month.numberOfProjectsFinished == 0)
            {
                //TODO; notify player?
                myCompany.jobSecurity -= 10;
            }

            if (myCompany.characters.Count == 0)
            {
                myCompany.firePlayer("You do not have any employees, you can't do this all by yourself! You're FIRED!");
            }
            else
            {
                monthly.openMonthlyReview();
            }
            myCompany.month.numberOfProjectsFinished = 0;
            myCompany.month.totalQuality             = 0;
            myCompany.partialSalaries = 0;
        }

        //Random event
        int ranEvent = Random.Range(1, 5);

        if (ranEvent == 1)
        {
            eventText.text = callEvent();
        }

        //Add new Projects to Available Projects 0-2 each week
        int numProjects;

        if (myCompany.availableProjects.Count == 0)
        {
            numProjects = Random.Range(1, 3);
        }
        else
        {
            numProjects = Random.Range(0, 3);
        }

        bool isNotListed = true;

        for (int i = 0; i < numProjects; i++)
        {
            GameObject projectObj = Instantiate(projectPrefab) as GameObject;
            Project    proj       = projectObj.GetComponent <Project>();
            isNotListed = true;
            for (int j = 0; j < myCompany.availableProjects.Count; j++)
            {
                if (myCompany.availableProjects[j].projName == proj.projName)
                {
                    isNotListed = false;
                    i--;
                }
            }
            for (int j = 0; j < myCompany.projects.Count; j++)
            {
                if (myCompany.projects[j].projName == proj.projName)
                {
                    isNotListed = false;
                    i--;
                }
            }
            if (isNotListed)
            {
                myCompany.availableProjects.Add(proj);
            }
            else
            {
                Destroy(proj);
            }
        }

        //Add new Applicants, Remove old Applicants, 0-3 in 0-2 out.

        int numApplIn = Random.Range(0, 4);

        if (myCompany.maxApplicants <= myCompany.applicants.Count)
        {
            numApplIn = 0;
        }

        if (myCompany.applicants.Count == 0)
        {
            numApplIn = Random.Range(1, 4);
        }

        for (int i = 0; i < numApplIn; i++)
        {
            Vector3    pos          = new Vector3(1000, 1000, -100f);
            GameObject characterObj = Instantiate(employeePrefab, pos, Quaternion.identity) as GameObject;
            Character  newChar      = characterObj.GetComponent <Character>();
            myCompany.applicants.Add(newChar);
        }

        if (myCompany.applicants.Count > 1)
        {
            int numApplOut = Random.Range(0, 2);
            for (int i = 0; i < numApplOut; i++)
            {
                myCompany.applicants.Remove(myCompany.applicants[0]);
            }
        }

        // Employees quit if their morale reaches 0
        for (int i = 0; i < myCompany.characters.Count; i++)
        {
            if (myCompany.characters[i].morale <= 0 && !myCompany.characters[i].hasQuit)
            {
                GameObject         newPanel = Instantiate(employeeQuitsPanel) as GameObject;
                EmployeeQuitsPanel panel    = newPanel.GetComponent <EmployeeQuitsPanel>();
                panel.hasQuit.text = myCompany.characters[i].characterName + " has quit!";
                if (myCompany.characters[i].gender == 'M')
                {
                    panel.detailedQuit.text = "He " + reason[Random.Range(0, reason.Length)];
                }
                else
                {
                    panel.detailedQuit.text = "She " + reason[Random.Range(0, reason.Length)];
                }
                panel.quitImage.sprite = myCompany.characters[i].sprite;

                newPanel.transform.SetParent(employeeQuitsContentPanel);
                panel.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                panel.transform.position   = new Vector3(0, -2f, 0);

                myCompany.characters[i].hasQuit = true;
                // Remove employee from project if he was on one
                foreach (Project proj in myCompany.projects)
                {
                    foreach (Character emp in proj.employees)
                    {
                        if (emp.ID == myCompany.characters[i].ID)
                        {
                            proj.workEstimate -= emp.speed * proj.deadline;
                            proj.employees.Remove(emp);
                            break;
                        }
                    }
                    break;
                }
                // Calculate partial salary and remove from the company
                myCompany.partialSalaries += (int)(myCompany.characters[i].salary * ((myCompany.weeksPassed % 4) / 4.0));
                myCompany.DecrementEmployeeNumber();
            }
        }
        for (int i = 0; i < myCompany.characters.Count; i++)
        {
            if (myCompany.characters[i].morale <= 0)
            {
                myCompany.characters[i].gameObject.transform.position = new Vector3(-1000, -1000, 0);
                myCompany.characters.Remove(myCompany.characters[i]);
            }
        }
        if (myCompany.jobSecurity <= 19)
        {
            int rand = Random.Range(1, 100);
            if (rand > 80)
            {
                myCompany.firePlayer("You're pretty terrible at this, you have been replaced by a monkey with a typewriter!");
            }
        }
        else if (myCompany.jobSecurity <= 35)
        {
            int rand = Random.Range(1, 100);
            if (rand > 95)
            {
                myCompany.firePlayer("We have decided to restructure the company, you have been fired to " +
                                     "afford the monthly dwarf tossing competition.");
            }
        }
    }
コード例 #19
0
ファイル: MainMenu.cs プロジェクト: johannbjarka/TheGrind
 public void StartGame()
 {
     click.playSound();
     SceneManager.LoadScene("Tutorial");
 }