Placido_GDD

Soldier_AI

Jul 1st, 2021 (edited)
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Soldier : EnemyBase
  6. {
  7.     public bool soldier_InCombat;
  8.     public GameObject soldier_proj;
  9.     protected GameObject projectile;
  10.     public Transform muzzle;
  11.     public float delayBetweenShots;
  12.     public float reloadDur;
  13.     public float proj_force;
  14.     public int max_bcount;
  15.     protected int b_count;
  16.     protected bool isPatrolling;
  17.     protected bool  is_Shooting;
  18.     protected Transform soldier_Target;
  19.     protected Rigidbody2D proj_RB;
  20.     protected SoldierRifle s_Rifle;
  21.     public override void Init()
  22.     {
  23.         base.Init();
  24.         Health = base.health;
  25.         s_Rifle = GetComponentInChildren<SoldierRifle>();
  26.         soldier_Target = base.player_script.transform;
  27.            if(base.waypoints.Length < 2)
  28.            {
  29.                base.anim.SetTrigger("Idle");
  30.                isPatrolling = false;
  31.                soldier_Target = base.player_script.transform;
  32.            }
  33.            else if(base.waypoints.Length >= 2)
  34.            {
  35.                //Debug.Log("Following waypoint paths");
  36.                isPatrolling = true;
  37.            }
  38.     }
  39.    
  40.      public override void Update()
  41.        {
  42.             SoldierAI_Update();
  43.        }
  44.        
  45.      void SoldierAI_Update()
  46.      {
  47.             if(isPatrolling == true)
  48.             {
  49.                 base.Update();
  50.             }
  51.            
  52.             if(isPatrolling == false)
  53.             {
  54.                 if(base.isDead == false)
  55.                 {
  56.                     base.DeathCheck();
  57.                     base.FaceTarget();
  58.                     base.TargetDistanceCheck();
  59.                 }
  60.             }
  61.             if(base.inCombat == true)
  62.             {
  63.                 //acess and run GunScript//
  64.                 //Debug.Log("Acessing Rifle Script....");
  65.                 //s_Rifle.inCombat = true;
  66.                 //Debug.Log("In combat:" + s_Rifle.inCombat);
  67.                
  68.             }
  69.             else if(base.inCombat == false)
  70.             {
  71.                 //Debug.Log("In combat:" + s_Rifle.inCombat);
  72.                 //s_Rifle.inCombat = false;
  73.             }
  74.      }
  75.      
  76. }
  77.  
Add Comment
Please, Sign In to add comment