public override void Execute(RoboPadron owner) { if (owner.anim == null) { return; } owner.anim.SetFloat(forwardAnimatorText, owner.rigid.velocity.magnitude, 0.1f, owner.delta); owner.anim.SetBool(aimingAnimatorText, owner.isAiming); if (owner.gunModel != null) { if (!owner.isAiming) { owner.gunModel.localPosition = Vector3.Lerp(owner.gunModel.localPosition, new Vector3(0.165f, -0.44f, -0.037f), gunMoveSpeed * owner.delta); owner.gunModel.localRotation = Quaternion.Slerp(owner.gunModel.localRotation, Quaternion.Euler(new Vector3(33.174f, 2.666f, -140.91f)), gunMoveSpeed * owner.delta); } else { owner.gunModel.localPosition = Vector3.Lerp(owner.gunModel.localPosition, new Vector3(0.434f, -0.104f, 0.091f), gunMoveSpeed * owner.delta); owner.gunModel.localRotation = Quaternion.Slerp(owner.gunModel.localRotation, Quaternion.Euler(new Vector3(48.13f, 18.673f, -70.551f)), gunMoveSpeed * owner.delta); } } }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { Debug.Log("Setting navigation to last known location"); owner.waypointNavigator.StartNavigation(owner.playerLastKnownLocation.position); return(AivoTree.AivoTreeStatus.Success); }
public override AivoTree.AivoTreeStatus Act(float TimeTick, RoboPadron owner) { if (owner.deathFallProgress.timer == 0) { float angleFall = Random.value * 360 * Mathf.Deg2Rad; owner.deathFallProgress.fallTowards = new Vector3(Mathf.Sin(angleFall), 0, Mathf.Cos(angleFall)); owner.deathFallProgress.originalRotation = owner.mTransform.rotation; owner.anim.SetFloat("Vertical", 0); } if (owner.deathFallProgress.timer < secondsToFall) { owner.deathFallProgress.timer += owner.delta; Vector3 vectorFall = owner.deathFallProgress.fallTowards; float progression = fallProgression.Evaluate((owner.deathFallProgress.timer / secondsToFall)); Vector3 currentFall = Vector3.Slerp(Vector3.up, vectorFall, progression); owner.mTransform.rotation = owner.deathFallProgress.originalRotation * Quaternion.FromToRotation(Vector3.up, currentFall); } else { return(AivoTree.AivoTreeStatus.Success); } return(AivoTree.AivoTreeStatus.Running); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { if (owner.canSeePlayer) { return(AivoTree.AivoTreeStatus.Success); } return(AivoTree.AivoTreeStatus.Failure); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { if (sisVariable.value == null || sisVariable.value.isDead) { return(AivoTree.AivoTreeStatus.Success); } return(AivoTree.AivoTreeStatus.Failure); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { owner.isAiming = targetBool; //Debug.Log("Setting Aiming to " + targetBool); return(AivoTree.AivoTreeStatus.Success); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { if (!owner.waypointNavigator.PathFinished) { return(AivoTree.AivoTreeStatus.Success); } return(AivoTree.AivoTreeStatus.Failure); }
public override void Execute(RoboPadron owner) { int roomAmount = owner.waypointNavigator.dungeon.RoomCount; int randomRoom = Random.Range(0, roomAmount); owner.waypointNavigator.SetWaypointGraph(); owner.waypointNavigator.StartNavigation(randomRoom); }
public override void Execute(RoboPadron owner) { if (owner.vision == null) { return; } //Update Timer if (timer < frequencyInSeconds) { timer += owner.delta; return; } timer = 0; if (playerTransform.value != null) { Vector3 playerPos = playerTransform.value.position; Vector3 headAngle = owner.headBone.forward; Vector3 headPos = owner.headBone.position; float playerDist = Vector3.Distance(playerPos, owner.mTransform.position); if (playerDist <= owner.vision.maxDistance) { //Debug.Log("Within Dist!"); Vector3 dir = (playerPos - headPos).normalized; if (Vector3.Angle(headAngle, dir) < owner.vision.angleFOV * 0.5f) { //Debug.Log("Within Angle! Dir: " + dir + " - HeadAngle: " + headAngle); RaycastHit raycastHit; LayerMask mapAndPlayer = LayerMask.NameToLayer("Player") | LayerMask.NameToLayer("Map"); Ray ray = new Ray(headPos, dir); if (Physics.Raycast(ray, out raycastHit, owner.vision.maxDistance, ~mapAndPlayer)) { //Debug.Log("Hit Something. Tag is " + raycastHit.collider.tag + ". Name is " + raycastHit.collider.name); if (raycastHit.collider.tag == "Player") { Debug.DrawLine(headPos, playerPos, Color.blue, 0.25f); if (!owner.canSeePlayer) { if (onPlayerSightEvent != null) { onPlayerSightEvent.Raise(); } } //Update Last Known Location owner.playerLastKnownLocation.position = playerPos; owner.playerLastKnownLocation.timeSeen = Time.realtimeSinceStartup; owner.canSeePlayer = true; } else { owner.canSeePlayer = false; } } } } } }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { int roomAmount = owner.waypointNavigator.dungeon.RoomCount; int randomRoom = Random.Range(0, roomAmount); owner.waypointNavigator.StartNavigation(randomRoom); return(AivoTree.AivoTreeStatus.Success); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { timer += timeTick; if (timer > secondsToWait) { timer = 0; return(AivoTree.AivoTreeStatus.Success); } return(AivoTree.AivoTreeStatus.Running); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { if (maxDistanceVar != null) { maxDistance = maxDistanceVar.value; } owner.vision.angleFOV = fov; owner.vision.maxDistance = maxDistance; return(AivoTree.AivoTreeStatus.Success); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { float dist = Vector3.SqrMagnitude(owner.playerLastKnownLocation.position - owner.mTransform.position); //Debug.Log("Range to LKL: " + Mathf.Sqrt(dist)); if (dist <= range * range) { return(AivoTree.AivoTreeStatus.Success); } return(AivoTree.AivoTreeStatus.Failure); }
public override bool CheckCondition(RoboPadron owner) { if (owner.canSeePlayer) { if (wanderRoot != null) { Debug.Log("Resetting Wander Root"); wanderRoot.Reset(owner); } } return(owner.canSeePlayer); }
public override bool CheckCondition(RoboPadron owner) { if (node.Tick(owner.delta, owner) == AivoTree.AivoTreeStatus.Success) { if (rootToReset != null) { Debug.Log("Resetting Root"); rootToReset.Reset(owner); } return(true); } return(false); }
public override bool CheckCondition(RoboPadron owner) { if (inShootingRange.Tick(owner.delta, owner) == AivoTree.AivoTreeStatus.Success && owner.canSeePlayer) { if (fightRoot != null) { Debug.Log("Resetting Fight Root"); fightRoot.Reset(owner); } return(true); } return(false); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { timer += owner.delta; if (timer > 1 / fireRate) { timer = 0; owner.projectileOnHit.UpdateOnHitSettings(owner, owner.bulletSystem.shape.rotation, 0, 1); owner.bulletSystem.Play(); return(AivoTree.AivoTreeStatus.Success); } return(AivoTree.AivoTreeStatus.Running); }
public override bool CheckCondition(RoboPadron owner) { if (owner.transitionToWander) { if (fightRoot != null) { Debug.Log("Resetting Fight Root"); fightRoot.Reset(owner); } } bool temp = owner.transitionToWander; owner.transitionToWander = false; return(temp); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { Vector3 pos = owner.playerLastKnownLocation.position; Room room = dungeon.GetRoom((int)pos.x, (int)pos.z); int roomIndex = dungeon.GetRoomIndex(room); if (roomIndex == -1) { roomIndex = dungeon.GetClosestRoomIndex(pos); } owner.waypointNavigator.StartNavigation(roomIndex); Debug.Log("Setting navigation to last known room"); return(AivoTree.AivoTreeStatus.Success); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { Vector3 pos = owner.playerLastKnownLocation.position; Room room = dungeon.GetRoom((int)pos.x, (int)pos.z); if (room == null) { return(AivoTree.AivoTreeStatus.Failure); } if (room.rect.Contains(new Vector2(owner.mTransform.position.x, owner.mTransform.position.z))) { return(AivoTree.AivoTreeStatus.Success); } return(AivoTree.AivoTreeStatus.Failure); }
public override void Execute(RoboPadron owner) { if (owner.waypointNavigator.PathFinished) { return; } Vector3 direction = owner.waypointNavigator.DirectionToWaypoint; owner.mTransform.rotation = Quaternion.Slerp(owner.mTransform.rotation, Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z)), turnSpeed * owner.delta); Vector3 motion = owner.mTransform.forward * moveSpeed * owner.delta; //owner.rigid.AddForce(motion); owner.mTransform.position = owner.mTransform.position + motion; }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { if (overrideFireRate != null) fireRate = overrideFireRate.value; owner.shootTimer += owner.delta; if (owner.shootTimer > 1 / fireRate) { owner.shootTimer = 0; owner.projectileOnHit.UpdateOnHitSettings(owner, owner.bulletSystem.shape.rotation, ignoreLayers, 1); owner.bulletSystem.Play(); owner.audioSource.PlayOneShot(gunShotSound, 0.1f); return AivoTree.AivoTreeStatus.Success; } return AivoTree.AivoTreeStatus.Running; }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { owner.rigid.velocity = Vector3.zero; if (owner.waypointNavigator.PathFinished) { return(AivoTree.AivoTreeStatus.Success); } //Debug.Log((owner.mTransform.position - previousPosition).sqrMagnitude); if ((owner.mTransform.position - previousPosition).sqrMagnitude < 0.002f) { timer += owner.delta; if (timer >= timeoutTime) { Debug.Log("Navigation failed"); timer = 0; return(AivoTree.AivoTreeStatus.Failure); } } else { timer = 0; } previousPosition = owner.mTransform.position; Vector3 direction = owner.waypointNavigator.DirectionToWaypoint; owner.mTransform.rotation = Quaternion.Slerp(owner.mTransform.rotation, Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z)), turnSpeed * owner.delta); if (overrideMoveSpeed != null) { moveSpeed = overrideMoveSpeed.value; } Vector3 motion = owner.mTransform.forward * moveSpeed * owner.delta; //owner.rigid.AddForce(motion); owner.rigid.velocity = motion; //owner.mTransform.position = owner.mTransform.position + motion; return(AivoTree.AivoTreeStatus.Running); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { //Change X Rotation of Head float current = owner.headBone.transform.localRotation.eulerAngles.x; Vector3 eulers = owner.headBone.transform.localRotation.eulerAngles; eulers.x = Mathf.MoveTowardsAngle(current, angleTarget, rotateSpeed * timeTick); owner.headBone.localRotation = Quaternion.Euler(eulers); //Debug.Log("current = " + current + " and target = " + angleTarget); //Debug.Log("Delta angle is " + Mathf.DeltaAngle(current, angleTarget)); if (Mathf.Abs(Mathf.DeltaAngle(current, angleTarget)) < 1f) { //Debug.Log("Head angle reached target!"); return(AivoTree.AivoTreeStatus.Success); } return(AivoTree.AivoTreeStatus.Running); }
void UpdateMeshAlpha(RoboPadron owner) { if (originalMeshAlpha == -1f) { originalMeshAlpha = owner.vision.MeshAlpha; } float targetAlpha; if (owner.canSeePlayer || owner.health == 0) { targetAlpha = 0; } else { targetAlpha = originalMeshAlpha; } owner.vision.MeshAlpha = Mathf.Lerp(owner.vision.MeshAlpha, targetAlpha, owner.delta * lightSwitchSpeed); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { owner.rigid.velocity = Vector3.zero; if (owner.waypointNavigator.PathFinished) { return(AivoTree.AivoTreeStatus.Success); } Vector3 direction = owner.waypointNavigator.DirectionToWaypoint; owner.mTransform.rotation = Quaternion.Slerp(owner.mTransform.rotation, Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z)), turnSpeed * owner.delta); Vector3 motion = owner.mTransform.forward * moveSpeed * owner.delta; //owner.rigid.AddForce(motion); owner.rigid.velocity = motion; //owner.mTransform.position = owner.mTransform.position + motion; return(AivoTree.AivoTreeStatus.Running); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { //Towards Player Vector3 dir = (playerTransform.value.position - owner.mTransform.position).normalized; dir.y = 0; Quaternion towardsPlayer = Quaternion.LookRotation(dir, Vector3.up); //Quaternion headRot = owner.headBone.rotation; owner.mTransform.rotation = Quaternion.Slerp(owner.mTransform.rotation, towardsPlayer, bodyRotateSpeed * owner.delta); Quaternion newHeadRot = owner.headBone.transform.localRotation; newHeadRot = Quaternion.Slerp(newHeadRot, Quaternion.identity, headRotateSpeed * owner.delta); owner.headBone.localRotation = newHeadRot; if (Mathf.Abs(Quaternion.Angle(owner.mTransform.rotation, towardsPlayer)) < 1f) { //Debug.Log("Aiming successful!"); return(AivoTree.AivoTreeStatus.Success); } return(AivoTree.AivoTreeStatus.Running); }
public override bool CheckCondition(RoboPadron owner) { return(owner.health == 0); }
void Start() { robo = transform.parent.GetComponent <RoboPadron>(); }
public override AivoTree.AivoTreeStatus Act(float timeTick, RoboPadron owner) { //Debug.Log("Stopping Navigation"); owner.waypointNavigator.StopNavigate(); return(AivoTree.AivoTreeStatus.Success); }