Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.63 KB | None | 0 0
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.AI;
  4.  
  5. // Token: 0x02000025 RID: 37
  6. public class AgentTest2 : MonoBehaviour
  7. {
  8.     // Token: 0x060000AE RID: 174 RVA: 0x0000653A File Offset: 0x0000493A
  9.     private void Start()
  10.     {
  11.         this.agent = base.GetComponent<NavMeshAgent>(); // Define the AI Agent
  12.         this.Wander(); //Start wandering
  13.     }
  14.  
  15.     // Token: 0x060000AF RID: 175 RVA: 0x0000654E File Offset: 0x0000494E
  16.     private void Update()
  17.     {
  18.         if (this.coolDown > 0f)
  19.         {
  20.             this.coolDown -= 1f * Time.deltaTime;
  21.         }
  22.     }
  23.  
  24.     // Token: 0x060000B0 RID: 176 RVA: 0x00006578 File Offset: 0x00004978
  25.     private void FixedUpdate()
  26.     {
  27.         if (this.playscrpt.jumpRopeStarted == true) //Check if the player has started jumproping
  28.         {
  29.             this.jumping = true; //If the player has started playtime's jumprope minigame
  30.             this.TargetPlayer(); //Head towards the player
  31.         }
  32.         else
  33.         {
  34.             this.jumping = false; //If the player is not jumproping with playtime
  35.             if (this.agent.velocity.magnitude <= 1f & this.coolDown <= 0f)
  36.             {
  37.                 this.Wander(); //Just wander
  38.             }
  39.         }
  40.     }
  41.  
  42.     // Token: 0x060000B1 RID: 177 RVA: 0x00006629 File Offset: 0x00004A29
  43.     private void Wander()
  44.     {
  45.         this.wanderer.GetNewTarget(); //Get a new target on the map
  46.         this.agent.SetDestination(this.wanderTarget.position); //Set its destination to position of the wanderTarget
  47.         this.agent.speed = 10f; //Set the character's speed to 10
  48.         this.coolDown = 1f;
  49.     }
  50.  
  51.     // Token: 0x060000B2 RID: 178 RVA: 0x00006658 File Offset: 0x00004A58
  52.     private void TargetPlayer()
  53.     {
  54.         this.agent.SetDestination(this.player.position); //Target the player
  55.         this.agent.speed = 25f; //Increase character's speed to 25
  56.         this.coolDown = 1f;
  57.     }
  58.  
  59.     void OnTriggerEnter(Collider other)
  60.     {
  61.         if (other.tag == "Player" && this.playscrpt.jumpRopeStarted == true) //If the character touches the player while jumproping
  62.         {
  63.             this.psc.DeactivateJumpRope(); //Deactivate (Cut) Playtime's Jumprope
  64.             this.playscrpt.Disappoint(); //Make playtime sad after cutting her rope
  65.         }
  66.     }
  67.  
  68.     // Token: 0x04000125 RID: 293
  69.     public bool db;
  70.  
  71.     // Token: 0x04000126 RID: 294
  72.     public Transform player; //the player
  73.  
  74.     // Token: 0x04000127 RID: 295
  75.     public Transform wanderTarget;
  76.  
  77.     // Token: 0x04000128 RID: 296
  78.     public AILocationSelectorScript wanderer;
  79.  
  80.     // Token: 0x04000129 RID: 297
  81.     public float coolDown;
  82.  
  83.     // Token: 0x0400012A RID: 298
  84.     private NavMeshAgent agent;
  85.  
  86.     public PlaytimeScript playscrpt; //playtime's script
  87.  
  88.     public bool jumping; //test if the player is jumping
  89.  
  90.     public PlayerScript psc; //the player's script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement