Example #1
0
 //When sim goes to use bathroom, must set objectinuse to null in order to stop the coroutine
 void OnTriggerExit2D(Collider2D col)
 {
     if (col.gameObject.tag == "Sim")
     {
         //this sets the sim's objectinuse to null once it leaves the bench
         //the reason we declare a new SimStats object here is in case another unrelated sim happens to cross through the trigger
         SimAI simAIHere = col.gameObject.GetComponent <SimAI>();
         simAIHere.simStatsScript.objectInUse = null;
     }
 }
Example #2
0
 void OnTriggerStay2D(Collider2D col)
 {
     if (col.gameObject.tag == "Sim")
     {
         simAIScript = col.gameObject.GetComponent <SimAI>();
         if (simAIScript.simFSMScript.mainState == SimFSM.MainFSM.Task && simAIScript.simFSMScript.taskState == SimFSM.TaskFSM.Sales)
         {
             inProgress = true;
         }
     }
 }
Example #3
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Sim")
     {
         if (!isSimObjectDeclared)
         {
             sim                 = col.gameObject;
             simAIScript         = col.gameObject.GetComponent <SimAI>();
             simStatsScript      = col.gameObject.GetComponent <SimStats>();
             isSimObjectDeclared = true;
         }
     }
 }
Example #4
0
 void OnTriggerExit2D(Collider2D col)
 {
     if (sim != null)
     {
         //this (the if statement part after &&) prevents needtohaul sim from dropping widget upon bumping into another sim
         if (col.gameObject.tag == "Sim" && col.gameObject.GetInstanceID() == sim.GetInstanceID())
         {
             sim            = null;
             simAIScript    = null;
             simStatsScript = null;
             bc2d.enabled   = false;
         }
     }
 }
Example #5
0
    // Use this for initialization
    void Start()
    {
        //GET SCRIPT COMPONENTS
        simStatsScript = simObj.GetComponent <SimStats>();
        simAIScript    = simObj.GetComponent <SimAI>();
        simFSMScript   = simObj.GetComponent <SimFSM>();

        //GET CANVAS OBJECT
        //canvasObj = transform.GetChild(0).gameObject;

        //GET TEXT OBJECT COMPONENTS
        simNameTextObj = transform.GetChild(1).gameObject;
        //simNameTextObj = GameObject.Find("SimText");

        simJobTextObj = transform.GetChild(2).gameObject;

        simStatusTextObj = transform.GetChild(3).gameObject;
        //simStatusTextObj = GameObject.Find("SimStatusText");

        simItemTextObj = transform.GetChild(4).gameObject;

        simEnergyTextObj = transform.GetChild(5).gameObject;
        //simEnergyTextObj = GameObject.Find("EnergyText");

        simHungerTextObj = transform.GetChild(6).gameObject;
        //simHungerTextObj = GameObject.Find("HungerText");

        simBladderTextObj = transform.GetChild(7).gameObject;
        //simHungerTextObj = GameObject.Find("HungerText");

        simEngSkillTextObj   = transform.GetChild(8).GetChild(0).gameObject;
        simProdSkillTextObj  = transform.GetChild(9).GetChild(0).gameObject;
        simSalesSkillTextObj = transform.GetChild(10).GetChild(0).gameObject;


        //GET ACTUAL TEXT COMPONENTS FROM OBJECTS
        simNameText       = simNameTextObj.GetComponent <Text>();
        simStatusText     = simStatusTextObj.GetComponent <Text>();
        simJobText        = simJobTextObj.GetComponent <Text>();
        simEnergyText     = simEnergyTextObj.GetComponent <Text>();
        simHungerText     = simHungerTextObj.GetComponent <Text>();
        simBladderText    = simBladderTextObj.GetComponent <Text>();
        simItemText       = simItemTextObj.GetComponent <Text>();
        simEngSkillText   = simEngSkillTextObj.GetComponent <Text>();
        simProdSkillText  = simProdSkillTextObj.GetComponent <Text>();
        simSalesSkillText = simSalesSkillTextObj.GetComponent <Text>();
    }
Example #6
0
    void Update()
    {
        bathroomStallPos = gameObject.transform.position;

        if (inProgress)
        {
            BathroomInProgress();
        }
        else if (!inProgress)
        {
            simAIScript = null;
        }



        //this stuff stops progress from running when sim isn't working on it anymore
        if (simAIScript != null)
        {
            //if this sim has reached the target position outside the stall, finish the bathroom sequence
            if (simAIScript.simStatsScript.simPos == (Vector2)gameObject.transform.GetChild(0).position)
            {
                simAIScript.isFinishedBathroom = false;
                inProgress = false;
                //set state back to idle
                simAIScript.simFSMScript.mainState = SimFSM.MainFSM.Idle;
                simAIScript.simFSMScript.taskState = SimFSM.TaskFSM.None;
            }

            if (simAIScript.simStatsScript.objectInUse == null)
            {
                StopCoroutine(progressCoroutine);
                isProgressCoroutineStarted = false;
                inProgress = false;
            }
            else if (simAIScript.simStatsScript.objectInUse != null)
            {
                if (simAIScript.simStatsScript.objectInUse.tag != "BathroomStall")
                {
                    StopCoroutine(progressCoroutine);
                    isProgressCoroutineStarted = false;
                    inProgress = false;
                }
            }
        }
    }
Example #7
0
    void Update()
    {
        //Update sales bench position
        salesBenchPos = gameObject.transform.position;

        if (inProgress)
        {
            SalesInProgress();
        }
        else if (!inProgress)
        {
            simAIScript = null;
        }

        //this stuff stops bench from running when sim isn't working on it anymore
        if (simAIScript != null)
        {
            if (simAIScript.simStatsScript.objectInUse == null)
            {
                StopCoroutine(progressCoroutine);
                StopCoroutine(skillExpCoroutine);
                isProgressCoroutineStarted = false;
                inProgress = false;
            }
            else if (simAIScript.simStatsScript.objectInUse != null)
            {
                if (simAIScript.simStatsScript.objectInUse.tag != "SalesBench")
                {
                    StopCoroutine(progressCoroutine);
                    StopCoroutine(skillExpCoroutine);
                    isProgressCoroutineStarted = false;
                    inProgress = false;
                }
            }
        }
    }
Example #8
0
 void Start()
 {
     simStatsScript = gameObject.GetComponent <SimStats>();
     simAIScript    = gameObject.GetComponent <SimAI>();
 }
Example #9
0
    void Start()
    {
        simWindowCanvasPrefab = (GameObject)Resources.Load("Prefabs/SimWindowCanvas");

        //GET SCRIPT COMPONENTS
        simStatsScript = gameObject.GetComponent <SimStats>();
        simAIScript    = gameObject.GetComponent <SimAI>();
        simFSMScript   = gameObject.GetComponent <SimFSM>();

        //ADD THIS SIM TO THE SIMLIST
        GameStats.simList.Add(gameObject);



        //GET OTHER SIM OBJECTS ARRAY
        //otherSimArray = GameObject.FindGameObjectsWithTag("Sim");

        //GET CANVAS OBJECT

        /*canvasObj = transform.GetChild(0).gameObject;
         *
         * //GET TEXT OBJECT COMPONENTS
         * simNameTextObj = transform.GetChild(0).GetChild(0).gameObject;
         * //simNameTextObj = GameObject.Find("SimText");
         *
         * simStatusTextObj = transform.GetChild(0).GetChild(1).gameObject;
         * //simStatusTextObj = GameObject.Find("SimStatusText");
         *
         * simEnergyTextObj = transform.GetChild(0).GetChild(2).gameObject;
         * //simEnergyTextObj = GameObject.Find("EnergyText");
         *
         * simHungerTextObj = transform.GetChild(0).GetChild(3).gameObject;
         * //simHungerTextObj = GameObject.Find("HungerText");
         *
         * simItemTextObj = transform.GetChild(0).GetChild(4).gameObject;
         *
         *
         * //GET ACTUAL CANVAS FROM CANVAS OBJECT
         * canvas = canvasObj.GetComponent<Canvas>();
         *
         * //SET CANVAS RENDER CAMERA
         * canvas.renderMode = RenderMode.ScreenSpaceCamera;
         * canvas.worldCamera = Camera.main;
         *
         * //GET ACTUAL TEXT COMPONENTS FROM OBJECTS
         * simNameText = simNameTextObj.GetComponent<Text>();
         * simStatusText = simStatusTextObj.GetComponent<Text>();
         * simEnergyText = simEnergyTextObj.GetComponent<Text>();
         * simHungerText = simHungerTextObj.GetComponent<Text>();
         * simItemText = simItemTextObj.GetComponent<Text>();*/

        //INITIALIZATION OF NEEDS
        simStatsScript.energy  = 100;
        simStatsScript.hunger  = 100;
        simStatsScript.bladder = 100;

        //INITIALIZATION OF EXPERIENCE
        simStatsScript.engineeringExp = 0;
        simStatsScript.laborExp       = 0;
        simStatsScript.salesExp       = 0;

        /*simNameText.enabled = false;
        *  //simNameText.text = "Name: " + simStatsScript.simName;
        *
        *  simEnergyText.enabled = false;
        *  simHungerText.enabled = false;
        *  //simHungerText.text = "Hunger: " + simStatsScript.hunger + "/" + "100";
        *
        *  simItemText.enabled = false;*/

        //Set the job of this sim
        SetSimJob();
    }
Example #10
0
 void Start()
 {
     //GET SCRIPTS
     simAIScript    = gameObject.GetComponent <SimAI>();
     simStatsScript = gameObject.GetComponent <SimStats>();
 }