/// <summary> /// GameSetUp(): /// Set up the necessary components before starting a new round. /// /// Steps: /// -If player has money then Set up. /// -Reset both player's positions. /// -Ask user to make a bet on a player. /// -Ask user to input an amount to bet. /// -Subtract bet amount from money pool. /// -Draw the game. /// -Ask user to start game. /// -Else proceed to exit the game. /// </summary> public void GameSetUp() { Console.Clear(); //Set all player's position to 0. if (hasMoney) { for (int i = 0; i < racers.Length; i++) { racerPositions[i] = 0; /*Optional: Randomise min and max step of each player*/ //racers[i].RandomiseStepRange(); } //Ask player to make a bet Console.WriteLine("Place your bet!" + "\n1 = Human" + "\n2 = Cpu"); playerBetOn = (WinScenario)InputValidation.ValidateInput(1, 2); Console.WriteLine("How much do you want to bet?" + "\nYour Balance: {0:C}", playerMoneyPool); playerBetAmount = InputValidation.ValidateInput(1, playerMoneyPool); //Subtract bet from moeny pool playerMoneyPool -= playerBetAmount; //Draw the game. gameGraphics.DrawGraphics(racerPositions[(int)Entity.Human], racerPositions[(int)Entity.Cpu]); Console.WriteLine("\nBetting On: {0}\t\tStaking:{1:C}", playerBetOn, playerBetAmount); Console.WriteLine("\nPress enter to start the race"); Console.ReadLine(); currentlyRacing = true; } else { Console.WriteLine("You have no more money!"); hasMoney = false; } }
/* Function: Update() * Purpose: this function is called once per frame. Generally, it just * calls the Roam function so that the PKA roams around the * Cell Membrane awaiting activation. But, once the PKA becomes * acitve, this function will kick off the process of separation * for the two parts of the PKA, instantiating the Active Kinase * and freeing it from the white portion of the PKA that will * continue to roam around with its cAMPs attached */ void Update() { Roam(); if (this.gameObject.GetComponent <ActivationProperties>().isActive&& !isSeparated) { GameObject oldPKA = getInactivePka(); if (null != oldPKA) { isSeparated = true; this.gameObject.GetComponent <ActivationProperties>().isActive = false; GameObject parentObject = this.gameObject; GameObject newPKA = (GameObject)Instantiate(activePKA, oldPKA.transform.position, oldPKA.transform.rotation); newPKA.transform.parent = GameObject.FindGameObjectWithTag("MainCamera").transform; newPKA.transform.rotation = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f); GameObject.Find("EventSystem").GetComponent <ObjectCollection>().Add(newPKA); oldPKA.gameObject.SetActive(false); if (GameObject.FindWithTag("Win_PKA_Separates")) { WinScenario.dropTag("Win_PKA_Separates"); } } } }
public GameObject parentObject; //Parent object used for unity editor Tree Hierarchy #region Private Methods private void OnTriggerEnter2D(Collider2D other) { //test Debug.Log("OnTriggerEnter2D -> object name = " + this.gameObject.name); //Get reference for parent object in UnityEditor parentObject = GameObject.FindGameObjectWithTag("MainCamera"); //IF signal protein collides with full receptor (level 1) if (other.gameObject.tag == "ECP" && this.gameObject.name.Equals("_ReceptorInactive(Clone)")) { ExternalReceptorProperties objProps = (ExternalReceptorProperties)this.GetComponent("ExternalReceptorProperties"); objProps.isActive = false; other.GetComponent <ExtraCellularProperties>().changeState(false); other.GetComponent <Rigidbody2D>().isKinematic = true; StartCoroutine(transformReceptor(other)); //check if action is a win condition for the scene/level if (GameObject.FindWithTag("Win_FullReceptorActivated")) { WinScenario.dropTag("Win_FullReceptorActivated"); } } //IF signal protein collides with left receptor else if (other.gameObject.tag == "ECP" && this.gameObject.name.Equals("Left_Receptor_Inactive(Clone)")) { ExternalReceptorProperties objProps = (ExternalReceptorProperties)this.GetComponent("ExternalReceptorProperties"); objProps.isActive = false; other.GetComponent <ExtraCellularProperties>().changeState(false); other.GetComponent <Rigidbody2D>().isKinematic = true; StartCoroutine(transformLeftReceptor(other)); //check if action is a win condition for the scene/level if (GameObject.FindWithTag("Win_LeftReceptorWithProtein")) { WinScenario.dropTag("Win_LeftReceptorWithProtein"); } } //IF right receptor collides with left receptor(with protein signaller) else if (other.gameObject.tag == "RightReceptor" && this.gameObject.name.Equals("Left_Receptor_Active(Clone)")) { StartCoroutine(transformLeftReceptorWithProtein(other)); //check if action is a win condition for the scene/level if (GameObject.FindWithTag("Win_ReceptorsCollideWithProtein")) { WinScenario.dropTag("Win_ReceptorsCollideWithProtein"); } } }
/* Function: OnTriggerEnter2D(Collider2D) * Purpose: this function handles the event that the TGProtein collided with the * active GPCR, setting our global isDockedAtGpcr variable true and * setting the properties of the TGProtein. Also handles the event that * the Alpha Subunit has come back after having been separated for * some time and has collided with the Beta-Gamma complex, * making the Alpha a child again */ private void OnTriggerEnter2D(Collider2D other) { GameObject objCollided = other.gameObject; Transform objDoc = null; //IF right receptor collides with left receptor(with protein signaller) if (objCollided.tag == "GPCR_B" && this.gameObject.name.Equals("ABG-ALL(Clone)")) { if (!isAlphaSeparated) { //check if action is a win condition for the scene/level if (GameObject.FindWithTag("Win_TGP_Bound_to_GPCR")) { WinScenario.dropTag("Win_TGP_Bound_to_GPCR"); } isDockedAtGpcr = true; this.GetComponent <ActivationProperties>().isActive = true; dropGdp(); } } else if (objCollided.tag == "Alpha" && this.gameObject.name.Equals("ABG-ALL(Clone)")) { if (objCollided.GetComponent <AlphaMovement>().doFindBetaGamma&& //the Alpha is looking for a parent objCollided.GetComponent <AlphaMovement>().targetBetaGamma == this.gameObject) //and its looking for me { Vector3 newPos = new Vector3(childPosX, childPosY, this.transform.position.z); objCollided.GetComponent <AlphaMovement>().doFindBetaGamma = false; objCollided.GetComponent <AlphaProperties>().isActive = false; objCollided.transform.parent = this.transform; objCollided.transform.position = newPos; objCollided.transform.rotation = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f); childGDP = objCollided.GetComponent <AlphaMovement>().GDP; isAlphaSeparated = false; isDockedAtGpcr = false; objDoc = getDoc(); if (null != objDoc) { objDoc.tag = "tGProteinDock"; } if (GameObject.FindWithTag("Win_Alpha_Rejoins_GProtein")) { WinScenario.dropTag("Win_Alpha_Rejoins_GProtein"); } } } }
/* Function: Update() * Purpose: This function, called once per frame, listens for the event * that the T-G-Protein has docked with a GPCR. If it has not * it seeks one out. This function also checks to see if the * GDP with which the T-G-Protein spawns has been released and * a GTP has docked with it. If so, separates the Alpha * Subunit so it can go find an Adenylyl Cyclase to bind with */ public void Update() { Transform doc = null; if (Time.timeScale != 0) //if we are not paused { if (!isDockedAtGpcr) //if we aren't bound to a GPCR { closestTarget = findClosestTarget(); if (null != closestTarget) { rotationDirection = getRotationDirection(); if (rotationDirection == "right") { transform.RotateAround(cellMembrane.transform.position, Vector3.back, speed * Time.deltaTime); } else if (rotationDirection == "left") { transform.RotateAround(cellMembrane.transform.position, Vector3.forward, speed * Time.deltaTime); } } } doc = getDoc(); if (null != doc) { //when GTP attaches it retags the Doc to OccupiedG_Protein if (doc.tag == "OccupiedG_Protein") { hasGtpAttached = true; } else { hasGtpAttached = false; } } //if we have GTP, we need to separate Alpha if (hasGtpAttached && !isAlphaSeparated) { separateAlpha(); if (GameObject.FindWithTag("Win_GTP_Binds_to_Alpha")) { WinScenario.dropTag("Win_GTP_Binds_to_Alpha"); } } } }
// Cloak retags objects for future reference private void Cloak() { transform.GetComponent <CircleCollider2D> ().enabled = false; transform.GetComponent <Rigidbody2D>().isKinematic = true; transform.position = dockingPosition; transform.parent = myTarget; myTarget.tag = "OccupiedG_Protein"; transform.tag = "DockedGTP"; myTarget = null; //determine if win condition has been reached if (GameObject.FindWithTag("Win_DockedGTP")) { WinScenario.dropTag("Win_DockedGTP"); } }
/* Function: onTriggerEnter2D(Collider2D) * Purpose: handles the event that we collided with an AdenylylCyclase, * setting the Cyclase's isActive property true and setting our * global isDockedAtCyclase variable true */ private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "AdenylylCyclase" && transform.name == "alpha") { if (!doFindBetaGamma) { other.gameObject.GetComponent <ActivationProperties>().isActive = true; inactiveCyclase = other.gameObject; isDockedAtCyclase = true; //check if action is a win condition for the scene/level if (GameObject.FindWithTag("Win_Alpha_Binds_to_Cyclase")) { WinScenario.dropTag("Win_Alpha_Binds_to_Cyclase"); } } } }
// Cloak retags objects for future reference private void Cloak() { //GTP_Script2 (); //GameObject obj = Instantiate(GTP1,gameObject.transform.position, Quaternion.identity) as GameObject; //GameObject.Find("EventSystem").GetComponent<ObjectCollection>().Add (obj); transform.GetComponent <CircleCollider2D> ().enabled = false; transform.GetComponent <Rigidbody2D>().isKinematic = true; transform.position = dockingPosition; transform.parent = myTarget; myTarget.tag = "OccupiedG_Protein"; transform.tag = "DockedGTP"; myTarget = null; //determine if win condition has been reached if (GameObject.FindWithTag("Win_DockedGTP")) { WinScenario.dropTag("Win_DockedGTP"); } }
public GameObject parentObject; //Parent object used for unity editor Tree Hierarchy #region Private Methods /* Function: OnTriggerEnter2D(Collider2D) * Purpose: this function handles the event that the Protein Signaler * collideed with the GPCR, calling the function that transforms * it into an Active GPCR */ private void OnTriggerEnter2D(Collider2D other) { //IF signal protein collides with GPCR if (other.gameObject.tag == "ECP" && this.gameObject.name.Equals("GPCR-A(Clone)")) { //Get reference for parent object in UnityEditor parentObject = GameObject.FindGameObjectWithTag("MainCamera"); this.gameObject.GetComponent <ActivationProperties>().isActive = false; other.GetComponent <ExtraCellularProperties>().changeState(false); other.GetComponent <Rigidbody2D>().isKinematic = true; StartCoroutine(transformReceptor()); //check if action is a win condition for the scene/level if (GameObject.FindWithTag("Win_GPCR_Activated")) { WinScenario.dropTag("Win_GPCR_Activated"); } } }
/// <summary> /// Determine whether there is a winner or not in the current cycle of the game. /// </summary> /// <param name="goal">Goal that would indicate a winner</param> /// <param name="playerPositions">positions that would be compared to the goal </param> /// <returns></returns> private bool DetermineRaceWinner(int goal, int[] playerPositions, ref WinScenario winnerOfRace) { //Count the number of players that reach the goal, if more than 1 then it's a draw. int reachedGoalCount = 0; for (int i = 0; i < playerPositions.Length; i++) { if (playerPositions[i].Equals(goal)) { reachedGoalCount++; } } //Draw if (reachedGoalCount > 1) { winnerOfRace = WinScenario.Draw; return(false); } //Human wins else if (playerPositions[(int)Entity.Human].Equals(goal)) { racers[(int)Entity.Human].Score++; winnerOfRace = WinScenario.Human; return(false); } //Cpu wins else if (playerPositions[(int)Entity.Cpu].Equals(goal)) { racers[(int)Entity.Cpu].Score++; winnerOfRace = WinScenario.Cpu; return(false); } //Continue else { return(true); } }
void FixedUpdate() { // Check if the time if the interaction did not complete reset back to before // The interaction was setup to occur if (timeoutForInteraction > timeoutMaxInterval) { //If the interaction is in the state of looking for a Kinase if (tag == "T_Reg_Prep_A" || tag == "T_Reg_Prep_B") { tag = "T_Reg"; // Reset the tag to when no interaction was setup to occur reset(); // Reset Components of both objects } else if (tag == "ATP_tracking") // If ATP is Tracking this Transcription Regulator { // Reset Components of the Transcription Regulator this.gameObject.GetComponent <CircleCollider2D> ().enabled = true; this.gameObject.GetComponent <BoxCollider2D>().enabled = true; // Reset the Timeout for Interaction timeoutForInteraction = 0.0f; // Set the T_Reg back to is Active isActive = true; this.tag = "ATP_tracking"; } } if (tag == "ATP_tracking") { this.transform.parent = parentObject.transform; //Sets curent object to be under the parent object. active_Kinase_P2 = Roam.FindClosest(transform, "Kinase_Phase_2"); // Set the kinase's parent to be this T_Reg active_Kinase_P2.transform.parent = this.transform; // Switch kinase to move with the its parent active_Kinase_P2.GetComponent <Rigidbody2D>().isKinematic = true; active_Kinase_P2.GetComponent <PolygonCollider2D>().enabled = false; // Enable the Box Collider for this T_Reg this.gameObject.GetComponent <BoxCollider2D>().enabled = true; // Enable the Circle Collider for the ATP to approach and "Dock" this.gameObject.GetComponent <CircleCollider2D>().enabled = true; // Setup state for an ATP to come and dock with T_Regulator timeoutForInteraction = 0; delay = 0; } // Default State when nothing is happening, T_Reg will just roam if (tag == "T_Reg") { Roam.Roaming(this.gameObject); } // Else enter the state of approaching a Kinase else if (tag == "T_Reg_Prep_A") { if ((delay += Time.deltaTime) >= 5.0f) // If Time delay, is less than 5 seconds keep Roaming { if (!midpointSet) // If midpoint not set, setup the midpoint between { // the paired Kinase and this T_Reg midpoint = Roam.CalcMidPoint(active_Kinase_P2, this.gameObject); // Say the has now been set midpointSet = true; } // Else Approach the midpoint, if this point has been achieved setup the next phase T_Reg_Prep_B else if (Roam.ApproachMidpoint(active_Kinase_P2, this.gameObject, midpointAchieved, midpoint, new Vector3(0.0f, 1.75f, 0.0f), 2.5f)) { delay = 0; // Disable Collider Components active_Kinase_P2.GetComponent <PolygonCollider2D> ().enabled = false; this.GetComponent <BoxCollider2D> ().enabled = false; // Set MidpointAchieved back to false midpointAchieved [0] = midpointAchieved [1] = false; tag = "T_Reg_Prep_B"; // Enter the next state by changing the tag to T_Reg_Prep_B } } else { // Continue Roaming for 5 seconds after entering this state Roam.Roaming(this.gameObject); } // Increment the timeout variable by delta time timeoutForInteraction += Time.deltaTime; } // Else if tag is T_Reg_Prep_B, enter the state next phase of approaching the Kinase else if (tag == "T_Reg_Prep_B") { //If Midpoint has not been achieved, approach the midpoint if (!midpointAchieved [0] || !midpointAchieved [1]) { // Proceed to the Kinase midpointAchieved [0] = Roam.ProceedToVector(active_Kinase_P2, midpoint + new Vector3(0.0f, 0.52f, 0.0f)); midpointAchieved [1] = Roam.ProceedToVector(this.gameObject, midpoint + new Vector3(0.0f, -0.52f, 0.0f)); } // Check if the midpoint has been achieved if (midpointAchieved [0] && midpointAchieved [1]) { // Check if the kinase has a parent if (active_Kinase_P2.gameObject.transform.parent.parent == null) { GameObject obj = Instantiate(TReg_P2, gameObject.transform.position, Quaternion.identity) as GameObject; //determine if win condition has been reached if (!WinConMet & (GameObject.FindWithTag("Win_Kinase_TReg_dock"))) { WinScenario.dropTag("Win_Kinase_TReg_dock"); WinConMet = true; } Destroy(this.gameObject); } } //Increment the timeout variable by delta time timeoutForInteraction += Time.deltaTime; } // Else if tag is ATP_Tracking, wait for an ATP to Collide with the CircleCollider else if (tag == "ATP_tracking") { // Check if the T_Reg is active if (isActive == true) { // Find the Closest ATP GameObject ATP = Roam.FindClosest(transform, "ATP"); //Check if the Closest ATP is not null, therefore one exists if (ATP != null) { // Set the z position for the T_Regulator to be off the 0.0f transform.position = new Vector3(transform.position.x, transform.position.y, 2.0f); // Setup a Vector in 2D because we only care about distance in the x and y Vector2[] pos = new Vector2[2]; //Collect the x and y values for this T_Reg and the ATP in separate Vector2 variables pos[0] = new Vector2(transform.position.x, transform.position.y); pos[1] = new Vector2(ATP.transform.position.x, ATP.transform.position.y); // Check if the Distance between the the ATP and the T_Reg is less than 6.0f if (Vector2.Distance(pos [0], pos [1]) < 6.0f) { //Set the T_Reg to be inactive because an ATP is close enough to dock isActive = false; //Disable the box Collider on this T_Reg this.GetComponent <BoxCollider2D> ().enabled = false; } } // Roam while the T_Reg is still active Roam.Roaming(this.gameObject); } //Increment the timeout variable by delta time timeoutForInteraction += Time.deltaTime; } // Else if tag is T_Reg_With_Phosphate, Enter this block else if (tag == "T_Reg_With_Phosphate") { // Check if T_Reg is active if (isActive == true) { // Check if Kinase is still active if (active_Kinase_P2 != null) { //Enter the state of looking for the nearest NPC this.tag = "T_Reg_To_NPC"; //check if action is a win condition for the scene/level if (GameObject.FindWithTag("Win_TranscriptionFactorCompleted")) { WinScenario.dropTag("Win_TranscriptionFactorCompleted"); } //Disable the Circle Collider the ATP was using this.gameObject.GetComponent <CircleCollider2D> ().enabled = false; // Reset the Kinase back to Kinase_Phase_2, when it was looking for a T_Reg active_Kinase_P2.GetComponent <Rigidbody2D> ().isKinematic = false; //Sets curent object to be under the parent object. active_Kinase_P2.transform.parent = parentObject.transform; active_Kinase_P2.GetComponent <KinaseCmdCtrl> ().reset(); active_Kinase_P2.tag = "Kinase_Phase_2"; active_Kinase_P2 = null; } // Roam while T_Reg is Active but not looking for a NPC Roam.Roaming(this.gameObject); } // Wait 3.5 Seconds after entering the stage where we have a phosphate else if ((delay += Time.deltaTime) > 3.5f && isActive == false) { //Time to release the Kinase and start looking for an NPC isActive = true; this.GetComponent <BoxCollider2D> ().enabled = true; } } // If tag is T_Reg_To_NPC, then start moving toward the nearest NPC; else if (tag == "T_Reg_To_NPC") { GameObject NPC = Roam.FindClosest(this.transform, "NPC"); Transform nucTransform = Nucleus.transform; if (NPC != null) { // calculate the distance and the approach vector float diffX = NPC.transform.position.x - nucTransform.position.x; float diffY = NPC.transform.position.y - nucTransform.position.y; float distance = (float)Math.Sqrt((diffX * diffX) + (diffY * diffY)); float rads = (float)Math.Atan2(diffY, diffX); Vector3 tempPosition = NPC.transform.position; tempPosition.x = (distance + distanceOffset) * (float)Math.Cos(rads) + nucTransform.position.x; tempPosition.y = (distance + distanceOffset) * (float)Math.Sin(rads) + nucTransform.position.y; tempPosition.z = 2; ingressDistance = tempPosition; ingressDistance.x = (distance - distanceOffset) * (float)Math.Cos(rads) + nucTransform.position.x; ingressDistance.y = (distance - distanceOffset) * (float)Math.Sin(rads) + nucTransform.position.y; // Check and move to the tempPosition, if we have then change state to T_Reg_To_Nucleus if (Roam.ApproachVector(this.gameObject, tempPosition, new Vector3(0, 0, 2), 0)) { this.tag = "T_Reg_To_Nucleus"; } } else { Roam.Roaming(this.gameObject); } } // Check if Tag is T_Reg_To_Nucleus, proceed to the Nucleus else if (tag == "T_Reg_To_Nucleus") { //Turn off the Collider on the T_Reg so it can pass through the nucleus Physics2D.IgnoreCollision(Nucleus.GetComponent <Collider2D>(), GetComponent <Collider2D>(), true); //Approach the Nucleus's midpoint if (Roam.ProceedToVector(this.gameObject, ingressDistance))// T_Reg is in the Nucleus, Game is won { Physics2D.IgnoreCollision(Nucleus.GetComponent <Collider2D>(), GetComponent <Collider2D>(), false); this.tag = "T_Reg_Complete"; } } else if (tag == "T_Reg_Complete") { if (GameObject.FindWithTag("Win_TFactorEntersNPC")) { WinScenario.dropTag("Win_TFactorEntersNPC"); // FOR CONGRATULATIONS SCREEN } Roam.Roaming(this.gameObject); } }
// Update is called once per frame void FixedUpdate() { if (timeoutForInteraction > timeoutMaxInterval) { if (tag == "Kinase_Prep_A" || tag == "Kinase_Prep_B") { active_G_Protein.GetComponent <G_ProteinCmdCtrl>().resetTarget(); active_G_Protein.GetComponent <BoxCollider2D>().enabled = true; active_G_Protein = null; reset(); tag = "Kinase"; } } if (tag == "Kinase") { Roam.Roaming(this.gameObject); } else if (tag == "Kinase_Prep_A" || tag == "Kinase_Prep_B") { if ((delay += Time.deltaTime) >= 5.0f) { if (!midpointSet && tag == "Kinase_Prep_A") { midpoint = Roam.CalcMidPoint(active_G_Protein, this.gameObject); midpointSet = true; } else if (Roam.ApproachMidpoint(active_G_Protein, this.gameObject, midpointAchieved, midpoint, setupVector(), setupRestraint())) { setupNextPhase(); } } else { Roam.Roaming(this.gameObject); } timeoutForInteraction += Time.deltaTime; } else if (tag == "Kinase_Prep_C") { if (!midpointAchieved [0] || !midpointAchieved [1]) { midpointAchieved[0] = Roam.ProceedToVector(active_G_Protein, midpoint + new Vector3(0.0f, 0.85f, 0.0f)); //these values to be changed midpointAchieved[1] = Roam.ProceedToVector(this.gameObject, midpoint + new Vector3(0.0f, -0.85f, 0.0f)); //for snapping kinase to gprotein } if (midpointAchieved[0] && midpointAchieved[1]) { if ((delay += Time.deltaTime) >= 3) { GameObject obj = Instantiate(Kinase_P2, gameObject.transform.position, Quaternion.identity) as GameObject; obj.transform.parent = parentObject.transform; //Sets curent object to be under the parent object. GameObject.Find("EventSystem").GetComponent <ObjectCollection>().Add(obj); active_G_Protein.GetComponent <G_ProteinCmdCtrl>().resetTarget(); Destroy(gameObject); } else { if (this.gameObject.transform.parent.parent == null) { this.gameObject.GetComponent <Rigidbody2D>().isKinematic = true; this.gameObject.GetComponent <PolygonCollider2D>().enabled = false; this.gameObject.transform.parent = active_G_Protein.transform; active_G_Protein.GetComponent <BoxCollider2D>().enabled = true; } Roam.Roaming(active_G_Protein); //determine if win condition has been reached if (!WinConMet & (GameObject.FindWithTag("Win_KinaseTransformation"))) { WinScenario.dropTag("Win_KinaseTransformation"); WinConMet = true; } } } timeoutForInteraction += Time.deltaTime; } else if (tag == "Kinase_Phase_2") { if (T_Reg == null) { T_Reg = Roam.FindClosest(transform, "T_Reg"); } if (T_Reg != null && !myTarget) { delay = 0; T_Reg.GetComponent <T_RegCmdCtrl>().GetObject(this.gameObject, "T_Reg_Prep_A"); myTarget = T_Reg.transform; } if (myTarget && (delay += Time.deltaTime) >= 5) { } else { Roam.Roaming(this.gameObject); } } }
private void FixedUpdate() { //IF G-Protein does not have a GTP(red) AND it does have GDP(blue) if (!haveGTP && transform.tag == "OccupiedG_Protein") { haveGTP = true; } //IF G-Protein is not targeting a phosphate AND G-Protein is not docked to receptor AND G-Protein does not have a GTP(red) if (!targeting && !docked && !haveGTP) { //Receptor phosphate = closest one to G-Protein openTarget = Roam.FindClosest(transform, "ReceptorPhosphate"); //IF phosphate is found if (openTarget != null) { //Stop movement and set to kinematic (David 03/05) //if(transform.GetComponent<Rigidbody2D>().isKinematic == false) //{ // transform.GetComponent<Rigidbody2D>().velocity = Vector3.zero; // transform.GetComponent<BoxCollider2D>().enabled = true; // transform.GetComponent<Rigidbody2D>().isKinematic = true; // //transform.GetComponent<CircleCollider2D>().enabled = false; //} myTarget = openTarget.transform; dockingPosition = GetOffset(); LockOn(); //call dibs } } //ELSE IF G-Protein is not docked to receptor AND G-Protein does not have a GTP(red) *On route to receptor phosphate else if (!docked && !haveGTP) { docked = ProceedToTarget(); if (docked) { ReleaseGDP(); } } //IF G-Protein has GTP(red) AND G-Protein is not ready to roam with attached GTP(red) AND wait time is over 2 seconds if (haveGTP && !roaming && (delay += Time.deltaTime) > 2) { Undock(); //check if action is a win condition for the scene/level if (GameObject.FindWithTag("Win_GProteinFreed")) { WinScenario.dropTag("Win_GProteinFreed"); } } //ELSE IF G-Protein has GTP(red) AND G-Protein is ready to roam with attached GTP(red) else if (haveGTP && roaming) { /* * if (Kinase == null) * { * Kinase = Roam.FindClosest (transform, "Kinase"); * } * * if (Kinase != null || myTarget != null) * { * Roam.FindAndWait (Kinase.GetComponent<KinaseCmdCtrl> (), this.gameObject, ref myTarget, ref delay, "Kinase_Prep_A"); * if (myTarget != null && (delay) >= 5) * { * * } * } * * else * { * Roam.Roaming (this.gameObject); * } */ GameObject Kinase = Roam.FindClosest(transform, "Kinase"); if (Kinase != null && !myTarget && isActive) { delay = 0; Kinase.GetComponent <KinaseCmdCtrl> ().GetObject(this.gameObject, "Kinase_Prep_A"); myTarget = Kinase.transform; } if (myTarget && (delay += Time.deltaTime) >= 5) { isActive = false; } else if (isActive == true) { Roam.Roaming(this.gameObject); } } //ELSE have G-Protein roam else { Roam.Roaming(this.gameObject); } }
/* Function: FixedUpdate() * Purpose: this function differs from Update in that, rather than being called once per frame, * it may be called once, zero, or multiple times per frame depending on the speed * of the physics frames per second. Not sure of the reasoning behind decision to use * FixedUpdate rather than Update. * Anyway, this function has the G-Protein search around for a Phosphate on a receptor * dropped off by an ATP. If the G-Protein has a GTP instead of GDP, * seeks out a Protein Kinase with which to bind. If there is nothing to seek, * G-Protein roams aimlessly */ private void FixedUpdate() { //IF G-Protein does not have a GTP(red) AND it does have GDP(blue) if (!haveGTP && transform.tag == "OccupiedG_Protein") { haveGTP = true; } //IF G-Protein is not targeting a phosphate AND G-Protein is not docked to receptor AND G-Protein does not have a GTP(red) if (!targeting && !docked && !haveGTP) { //Receptor phosphate = closest one to G-Protein openTarget = Roam.FindClosest(transform, "ReceptorPhosphate"); //IF phosphate is found if (openTarget != null) { myTarget = openTarget.transform; dockingPosition = GetOffset(); LockOn(); //call dibs } } //ELSE IF G-Protein is not docked to receptor AND G-Protein does not have a GTP(red) *On route to receptor phosphate else if (!docked && !haveGTP) { docked = ProceedToTarget(); if (docked) { ReleaseGDP(); } } //IF G-Protein has GTP(red) AND G-Protein is not ready to roam with attached GTP(red) AND wait time is over 2 seconds if (haveGTP && !roaming && (delay += Time.deltaTime) > 2) { Undock(); //check if action is a win condition for the scene/level if (GameObject.FindWithTag("Win_GProteinFreed")) { WinScenario.dropTag("Win_GProteinFreed"); } } //ELSE IF G-Protein has GTP(red) AND G-Protein is ready to roam with attached GTP(red) else if (haveGTP && roaming) { GameObject Kinase = Roam.FindClosest(transform, "Kinase"); if (Kinase != null && !myTarget && isActive) { delay = 0; Kinase.GetComponent <KinaseCmdCtrl> ().GetObject(this.gameObject, "Kinase_Prep_A"); myTarget = Kinase.transform; } if (myTarget && (delay += Time.deltaTime) >= 5) { isActive = false; } else if (isActive == true) { Roam.Roaming(this.gameObject); } } //ELSE have G-Protein roam else { Roam.Roaming(this.gameObject); } }