bool ReachedDestination(EyeRok eyeRok) { //TODO: Test //NOTE: This only works if auto-braking is turned ON in the navAgent //It's on by default so it should be ok return(!eyeRok.navAgent.hasPath); }
public override EyeRokState Update(EyeRok eyeRok) { //Check if player is in range if (PositionInRange(eyeRok.transform.position, eyeRok.Player.transform.position, sightRange) && handNearEyeRok && ReachedDestination(eyeRok)) { //We reached the destination so prepare for attacking //Return a new state here //TODO: for now return null to check if patrol works return(new EyeRokThrowHandsUp()); } else { //Bring hands close to EyeRok Vector2 leftHandWorldPos = eyeRok.LeftHand.transform.position; Vector2 rightHandWorldPos = eyeRok.RightHand.transform.position; Vector3 LeftHandInitialWorldPosition = eyeRok.transform.TransformPoint(LeftHandInitialLocalPosition); Vector3 RightHandInitialWorldPosition = eyeRok.transform.TransformPoint(RightHandInitialLocalPosition); eyeRok.LeftHand.transform.position = MovePosition(leftHandWorldPos, LeftHandInitialWorldPosition, handSpeed); eyeRok.RightHand.transform.position = MovePosition(rightHandWorldPos, RightHandInitialWorldPosition, handSpeed); //If the hands are in their initial position (near EyeRok) if (ArrivedAtDestination(eyeRok.LeftHand.transform.position, LeftHandInitialWorldPosition) && ArrivedAtDestination(eyeRok.RightHand.transform.position, RightHandInitialWorldPosition)) { handNearEyeRok = true; } return(null); } }
public override void OnEnter(EyeRok eyeRok) { //Calculate hand positions based on the player position //Left hand on top of the player leftHandDestination = eyeRok.Player.transform.position; //Right hand on a circle around the player rightHandDestination = GetLocationAroundPoint(eyeRok.Player.transform.position, 1.5f, 3.0f); //Spawn prefabs var leftHandWarning = Object.Instantiate(eyeRok.HandWarningPrefab, leftHandDestination, Quaternion.identity); var rightHandWarning = Object.Instantiate(eyeRok.HandWarningPrefab, rightHandDestination, Quaternion.identity); //Also get rid of the prefab at the end eyeRok.StartCoroutine(SmashFloor(eyeRok.LeftHand, leftHandDestination, eyeRok.LeftHandCollider, () => { leftHandFinished = true; Object.Destroy(leftHandWarning); })); eyeRok.StartCoroutine(SmashFloor(eyeRok.RightHand, rightHandDestination, eyeRok.RightHandCollider, () => { rightHandFinished = true; Object.Destroy(rightHandWarning); })); }
public override void OnEnter(EyeRok eyeRok) { //TODO: Is there a way to get a position within a specific boundary (i.e: the boss room)? //For now We'll make it so the boss chooses a random location around it's previous location. //It's not good but it's honest work Vector2 newDestination = GetLocationAroundPoint(eyeRok.transform.position, MaxWalkRange / 2.0f, MaxWalkRange); SetDestination(eyeRok, newDestination); }
public override EyeRokState Update(EyeRok eyeRok) { if (HandsReadyToAttack) { return(new EyeRokSmashFloor()); } else { return(null); } }
public override void OnEnter(EyeRok eyeRok) { /* * Hands should be near the EyeRok from the previous state. Just throw them up in the air. * How? Disable the colliders of both hands and increment the Y position LOOOOL */ eyeRok.StartCoroutine(WaitForSeconds(TimeDelayBeforeAttack)); //Disable the colliders eyeRok.LeftHandCollider.enabled = false; eyeRok.RightHandCollider.enabled = false; //And move the hands eyeRok.StartCoroutine(ThrowHands(eyeRok.LeftHand)); eyeRok.StartCoroutine(ThrowHands(eyeRok.RightHand)); }
public override EyeRokState Update(EyeRok eyeRok) { if (leftHandFinished && rightHandFinished) { eyeRok.StartCoroutine(WaitForSeconds(timeHandsInGround, () => handsCooldown = true)); if (handsCooldown) { return(new EyeRokPatrol()); } else { return(null); } } else { return(null); } }
void SetDestination(EyeRok eyeRok, Vector2 destination) { eyeRok.navAgent.destination = destination; }
//Return type is optional public abstract EyeRokState Update(EyeRok eyeRok);
public abstract void OnEnter(EyeRok eyeRok);