示例#1
0
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (target == null)
     {
         animator.SetBool("PowerUpInSight", false);
     }
     else if (playerController.state == MinifigControllerWTH.State.Idle)
     {
         currentPath = new NavMeshPath();
         NavMesh.CalculatePath(player.transform.position, target.position, NavMesh.AllAreas, currentPath);
         if (currentPath.corners.Length < 2)
         {
             animator.SetBool("PowerUpInSight", false);
         }
         else
         {
             if (Vector3.Distance(player.transform.position, currentPath.corners[1]) > 0.5f)
             {
                 playerController.MoveTo(currentPath.corners[1]);
             }
             else if (currentPath.corners.Length > 2)
             {
                 Vector3 jumpGoal = currentPath.corners[2];
                 playerController.MoveTo(jumpGoal);
                 playerController.AddForce(new Vector3(0, playerController.jumpSpeed, 0));
             }
         }
     }
 }
示例#2
0
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     animator.SetBool("IsInMiddle", isPlayerInMiddle(player.transform.position));
     animator.SetBool("PlayerInSight", playerInRange(player.transform.position));
     animator.SetBool("PowerUpInSight", powerUpInRange(player.transform.position));
     if (playerController.state == MinifigControllerWTH.State.Idle)
     {
         currentPath = new NavMeshPath();
         Vector3 targetPosition = new Vector3(0, 0, 0);
         if (playerController.hasPowerUp())
         {
             playerController.SpawnPowerUp();
             playerController.MoveTo(targetPosition, maxMoveTime: 1.5f);
         }
         else
         {
             NavMesh.CalculatePath(player.transform.position, targetPosition, NavMesh.AllAreas, currentPath);
             if (currentPath.corners.Length >= 2)
             {
                 if (Vector3.Distance(player.transform.position, currentPath.corners[1]) > 0.5f)
                 {
                     playerController.MoveTo(currentPath.corners[1]);
                 }
                 else if (currentPath.corners.Length > 2)
                 {
                     Vector3 jumpGoal = currentPath.corners[2];
                     playerController.MoveTo(jumpGoal);
                     playerController.AddForce(new Vector3(0, playerController.jumpSpeed, 0));
                 }
             }
         }
     }
 }
示例#3
0
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     animator.SetBool("IsInMiddle", isPlayerInMiddle(player.transform.position));
     hasBat = playerController.hasEquipment();
     if (timeSinceLastMove < 0 && playerController.state == MinifigControllerWTH.State.Idle)
     {
         Transform target = powerUpInRange(player.transform.position);
         if (target != null)
         {
             //go to pickup bat and use it
             currentPath = new NavMeshPath();
             NavMesh.CalculatePath(player.transform.position, target.position, NavMesh.AllAreas, currentPath);
             if (currentPath.corners.Length >= 2)
             {
                 if (Vector3.Distance(player.transform.position, currentPath.corners[1]) > 0.5f)
                 {
                     playerController.MoveTo(currentPath.corners[1]);
                 }
             }
             timeSinceLastHit = 0f;
         }
         else
         {
             int goalIndex = Random.Range(0, goals.Count);
             currentPath = new NavMeshPath();
             NavMesh.CalculatePath(player.transform.position, goals[goalIndex], NavMesh.AllAreas, currentPath);
             if (currentPath.corners.Length >= 2)
             {
                 if (Vector3.Distance(player.transform.position, currentPath.corners[1]) > 0.5f)
                 {
                     playerController.MoveTo(currentPath.corners[1]);
                 }
             }
         }
         timeSinceLastMove = 6f;
     }
     else if (playerInRange(player.transform.position) && hasBat)
     {
         // Hit player every x seconds
         if (timeSinceLastHit > 0f)
         {
             timeSinceLastHit -= Time.deltaTime;
         }
         else
         {
             playerController.HitWithBat();
             timeSinceLastHit = 1f;
         }
     }
     timeSinceLastMove -= Time.deltaTime;
 }
示例#4
0
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (playerController.state == MinifigControllerWTH.State.Idle)
     {
         currentPath = new NavMeshPath();
         NavMesh.CalculatePath(player.transform.position, targetPlayer.transform.position, NavMesh.AllAreas, currentPath);
         if (currentPath.corners.Length < 2)
         {
             animator.SetBool("PlayerInSight", false);
         }
         else
         {
             playerController.MoveTo(currentPath.corners[1]);
         }
     }
 }