Placido_GDD

BasicMecha

Jun 23rd, 2021 (edited)
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class BasicMecha : EnemyBase
  6. {
  7.  
  8.     protected bool isPatrolling;
  9.     [SerializeField]
  10.     protected bool mechInCombat;
  11.     protected Transform mech_Target;
  12.     //
  13.     public float chargeRange;
  14.     public float chargeSpeed;
  15.     public Transform ambushLoc;
  16.    
  17.     public override void Init()
  18.        {
  19.            base.Init();
  20.            //player_script = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerControl>();
  21.            //use base.player_script instead if you need to access the PlayerControl component
  22.            Health = base.health;
  23.            mech_Target = base.player_script.transform;
  24.            if(base.waypoints.Length < 2)
  25.            {
  26.                base.anim.SetTrigger("Idle");
  27.                isPatrolling = false;
  28.                mech_Target = base.player_script.transform;
  29.            }
  30.            else if(base.waypoints.Length >= 2)
  31.            {
  32.                //Debug.Log("Following waypoint paths");
  33.                isPatrolling = true;
  34.            }
  35.            
  36.        }
  37.        
  38.       public override void Update()
  39.        {
  40.             if(isPatrolling == true)
  41.             {
  42.                 base.Update();
  43.             }
  44.            
  45.             if(isPatrolling == false)
  46.             {
  47.                 if(base.isDead == false)
  48.                 {
  49.                     base.DeathCheck();
  50.                     base.FaceTarget();
  51.                     base.TargetDistanceCheck();
  52.                     ChargeEnemy();
  53.                     if(mechInCombat == true)
  54.                     {
  55.                         base.anim.SetBool("InCombat",true);
  56.                     }
  57.                     else if(mechInCombat == false)
  58.                     {
  59.                         base.anim.SetTrigger("Idle");
  60.                     }
  61.                 }
  62.             }
  63.        }
  64.        
  65.  
  66.        
  67.        void ChargeEnemy()
  68.        {
  69.            float mech_Target_dist = Vector3.Distance(transform.localPosition,mech_Target.position);
  70.             if(mech_Target_dist < chargeRange)
  71.             {
  72.                 if(mech_Target_dist > base.d_Check)
  73.                 {
  74.                 base.anim.SetBool("IsCharging",true);
  75.                 transform.position = Vector3.MoveTowards(transform.position,mech_Target.position,chargeSpeed * Time.deltaTime);
  76.                 }
  77.                 else if(mech_Target_dist < base.d_Check)
  78.                 {
  79.                     mechInCombat = true;
  80.                     Debug.Log("Target in range");
  81.                 }
  82.                    
  83.             }
  84.            
  85.        }
  86.        
  87.        void AmbushEnemy()
  88.        {
  89.            
  90.            
  91.        }
  92.        
  93.            
  94.    
  95. }
Add Comment
Please, Sign In to add comment