internal void AddToPlayerScore(string playerName, AstroJump aj) { if (LevelEnded) { return; } aj.Unhook(); if (playerName == "Player 1" && Astronaut1CarryingRock.mainTexture != RockTextures[0]) { NumberOfRocksPlayer1Delivered++; if (scoreScript != null) { scoreScript.AddToScore(playerName, Astronaut1CarryingRock.mainTexture); } Astronaut1CarryingRock.mainTexture = RockTextures[0]; // } else if (playerName == "Player 2" && Astronaut2CarryingRock.mainTexture != RockTextures[0]) { NumberOfRocksPlayer2Delivered++; scoreScript.AddToScore(playerName, Astronaut2CarryingRock.mainTexture); Astronaut2CarryingRock.mainTexture = RockTextures[0]; // } checkIfLevelOver(); }
// why is this called from outside instead of from OnTriggerEnter public IEnumerator RaiseWithAstronaut(float time, AstroJump aj) { //Lift Astronaut var currentPos = transform.position; var t = 0f; while (t < TimeToRaiseWithAstronaut) { t += Time.deltaTime / time; transform.position = Vector3.Lerp(currentPos, LeavePos, t); yield return(null); } GM.AddToPlayerScore(HookName, aj); SecondsToLowerAndReturn *= HookRepeatSlowDownFactor; StartCoroutine(Wait()); }
void OnTriggerEnter(Collider other) { //print ("Trigger!"); if (!Started || Tripped) { return; } if (other.tag == "Hand") { Tripped = true; StopCoroutine("Lower"); StopCoroutine("Return"); HookDetector hd = (HookDetector)other.GetComponent(typeof(HookDetector)); AstroJump ja = hd.GetAstroJump(); Transform hand = hd.GetThisHand(); //ja.Hook(this.transform); this is now done in gameManager GM.HookTriggered(HookName, ja, this.transform, hand, HookPoint); } }
public void HookTriggered(string hookName, AstroJump ja, Transform hookTransform, Transform handTransform, Transform hookPointTransform) { if (LevelEnded) { return; } if (hookName == "Player 1") { StartCoroutine(Hook1.RaiseWithAstronaut(RaiseHookedAstronautTime, ja)); } else if (hookName == "Player 2") { StartCoroutine(Hook2.RaiseWithAstronaut(RaiseHookedAstronautTime, ja)); } // freeze the avatar that touched the hook ja.Hook(hookTransform, handTransform, hookPointTransform); }
void Start() { ThisHand = (Transform)this.gameObject.transform; astroJump = (AstroJump)BodyRoot.GetComponent(typeof(AstroJump)); rigidBody = (Rigidbody)BodyRoot.GetComponent(typeof(Rigidbody)); }
public void RegisterAstroJump(AstroJump script) { astroJump = script; }