Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BasicMecha : EnemyBase
- {
- protected bool isPatrolling;
- [SerializeField]
- protected bool mechInCombat;
- protected Transform mech_Target;
- //
- public float chargeRange;
- public float chargeSpeed;
- public Transform ambushLoc;
- public override void Init()
- {
- base.Init();
- //player_script = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerControl>();
- //use base.player_script instead if you need to access the PlayerControl component
- Health = base.health;
- mech_Target = base.player_script.transform;
- if(base.waypoints.Length < 2)
- {
- base.anim.SetTrigger("Idle");
- isPatrolling = false;
- mech_Target = base.player_script.transform;
- }
- else if(base.waypoints.Length >= 2)
- {
- //Debug.Log("Following waypoint paths");
- isPatrolling = true;
- }
- }
- public override void Update()
- {
- if(isPatrolling == true)
- {
- base.Update();
- }
- if(isPatrolling == false)
- {
- if(base.isDead == false)
- {
- base.DeathCheck();
- base.FaceTarget();
- base.TargetDistanceCheck();
- ChargeEnemy();
- if(mechInCombat == true)
- {
- base.anim.SetBool("InCombat",true);
- }
- else if(mechInCombat == false)
- {
- base.anim.SetTrigger("Idle");
- }
- }
- }
- }
- void ChargeEnemy()
- {
- float mech_Target_dist = Vector3.Distance(transform.localPosition,mech_Target.position);
- if(mech_Target_dist < chargeRange)
- {
- if(mech_Target_dist > base.d_Check)
- {
- base.anim.SetBool("IsCharging",true);
- transform.position = Vector3.MoveTowards(transform.position,mech_Target.position,chargeSpeed * Time.deltaTime);
- }
- else if(mech_Target_dist < base.d_Check)
- {
- mechInCombat = true;
- Debug.Log("Target in range");
- }
- }
- }
- void AmbushEnemy()
- {
- }
- }
Add Comment
Please, Sign In to add comment