using System;
using UnityEngine;
public class EN11_Babi : Enemy
{
private float _babiScale;
public AnimState animState;
public AudioClip[] audioAttack;
public AudioClip[] audioChase;
public AudioClip[] audioDead;
public AudioClip[] audioHit;
public AudioClip[] audioIdle;
public AudioClip[] audioKejepit;
public AudioClip[] audioNgorok;
public AudioClip[] audioPatrol;
public AudioClip[] audioRetreat;
private float effectAmount;
public EnemyState enemyState;
public float hitForce;
private float hitForceMod;
public float idleDuration;
public GameObject mesh;
public Transform retreatPoint;
public SubState subState;
public EN11_Babi()
{
this.idleDuration = 10f;
this._babiScale = 0.87f;
this.hitForce = 5f;
base..ctor();
return;
}
public object _debugBabi(params string[] args)
{
if ((args[1] == "sleep") == null)
{
goto Label_0025;
}
this.enemyState = 7;
this.subState = 1;
goto Label_006A;
Label_0025:
if ((args[1] == "wakeup") == null)
{
goto Label_004A;
}
this.enemyState = 8;
this.subState = 1;
goto Label_006A;
Label_004A:
if ((args[1] == "stuck") == null)
{
goto Label_006A;
}
this.enemyState = 6;
this.subState = 1;
Label_006A:
return ("Babi state: " + args[1]);
}
protected override void Awake()
{
base.Awake();
return;
}
private unsafe void DoAttackCharge()
{
Vector3 vector;
if (this.subState != 1)
{
goto Label_0025;
}
base.audio.Stop();
this.animState = 4;
this.subState = 2;
Label_0025:
if (this.subState != 2)
{
goto Label_0150;
}
if (base.isImmobilize != null)
{
goto Label_0062;
}
if (base.hasNavMeshAgent == null)
{
goto Label_0062;
}
base.agent.destination = base.attackTarget.transform.position;
Label_0062:
if (base.damagePoint == null)
{
goto Label_0109;
}
if (base.isAttacking != null)
{
goto Label_0109;
}
vector = base.attackTarget.transform.position - base.damagePoint.position;
&vector.y = 0f;
if (&vector.magnitude >= 1f)
{
goto Label_00EA;
}
NotificationCenter.instance.PostNotification(new Notification(0x56, base.gameObject, base.attackTarget, base.attackDamage));
base.isAttacking = 1;
goto Label_0109;
Label_00EA:
if (base.distanceToTarget <= base.attackDistance)
{
goto Label_0109;
}
this.enemyState = 3;
this.subState = 1;
Label_0109:
if (base.isAttacking == null)
{
goto Label_0150;
}
base.delayTimer += Time.deltaTime;
if (base.delayTimer < base.attackDelay)
{
goto Label_0150;
}
base.delayTimer = 0f;
this.enemyState = 5;
this.subState = 1;
Label_0150:
return;
}
private void DoChase()
{
Vector3 vector;
if (this.subState != 1)
{
goto Label_004E;
}
base.audio.Stop();
base.isAttacking = 0;
if (base.hasNavMeshAgent == null)
{
goto Label_0040;
}
base.agent.speed = base.movingSpeed * 2f;
Label_0040:
this.animState = 3;
this.subState = 2;
Label_004E:
if (this.subState != 2)
{
goto Label_0138;
}
this.effectAmount -= Time.deltaTime * 2f;
if (base.isImmobilize != null)
{
goto Label_00F6;
}
if (base.hasNavMeshAgent == null)
{
goto Label_00A8;
}
base.agent.destination = base.attackTarget.transform.position;
goto Label_00F6;
Label_00A8:
if (base.hasCharacterController == null)
{
goto Label_00F6;
}
if (base.controller.isGrounded == null)
{
goto Label_00F6;
}
vector = base.transform.TransformDirection(Vector3.forward);
base.controller.SimpleMove((vector * base.movingSpeed) * 1.5f);
Label_00F6:
if (base.distanceToTarget >= base.attackDistance)
{
goto Label_011A;
}
this.enemyState = 4;
this.subState = 1;
goto Label_0138;
Label_011A:
if (base.distanceToTarget <= 10f)
{
goto Label_0138;
}
this.enemyState = 1;
this.subState = 1;
Label_0138:
return;
}
private void DoDead()
{
if (this.subState != 1)
{
goto Label_0034;
}
base.audio.Stop();
if (base.hasNavMeshAgent == null)
{
goto Label_002D;
}
base.agent.Stop();
Label_002D:
this.subState = 2;
Label_0034:
if (this.subState != 2)
{
goto Label_009E;
}
base.isDead = 1;
base.delayTimer += Time.deltaTime;
if (base.delayTimer <= base.dyingDuration)
{
goto Label_009E;
}
NotificationCenter.instance.PostNotification(new Notification(0xb0, this));
NotificationCenter.instance.PostNotification(new Notification(0x95, base.gameObject.name));
Label_009E:
return;
}
private void DoHit()
{
if (base.isInvincible == null)
{
goto Label_000C;
}
return;
Label_000C:
if (this.subState != 1)
{
goto Label_0094;
}
this.hitForceMod = this.hitForce;
base.audio.Stop();
base.delayTimer = 0f;
if (base.hasNavMeshAgent == null)
{
goto Label_0050;
}
base.agent.Stop();
Label_0050:
base.isShot = 1;
base.health -= base.damageReceived;
this.animState = 9;
base.stunDuration = base.animation["hit"].length;
this.subState = 2;
Label_0094:
if (this.subState != 2)
{
goto Label_0166;
}
base.delayTimer += Time.deltaTime;
this.effectAmount += Time.deltaTime * 5f;
this.hitForceMod -= Time.deltaTime;
base.transform.Translate((Vector3.back * Time.deltaTime) * this.hitForceMod);
if (base.delayTimer <= base.stunDuration)
{
goto Label_0166;
}
this.hitForceMod = this.hitForce;
base.delayTimer = 0f;
if (base.health > 0f)
{
goto Label_0158;
}
base.health = 0f;
this.enemyState = 11;
this.subState = 1;
goto Label_0166;
Label_0158:
this.enemyState = 3;
this.subState = 1;
Label_0166:
return;
}
private void DoIdle()
{
if (this.subState != 1)
{
goto Label_0046;
}
this.effectAmount = 0f;
base.audio.Stop();
if (base.hasNavMeshAgent == null)
{
goto Label_0038;
}
base.agent.Stop();
Label_0038:
this.animState = 1;
this.subState = 2;
Label_0046:
if (this.subState != 2)
{
goto Label_00B7;
}
if (base.IsInsideFOV(base.attackTarget.transform) == null)
{
goto Label_007B;
}
this.enemyState = 3;
this.subState = 1;
goto Label_00B7;
Label_007B:
base.delayTimer += Time.deltaTime;
if (base.delayTimer <= this.idleDuration)
{
goto Label_00B7;
}
base.delayTimer = 0f;
this.enemyState = 2;
this.subState = 1;
Label_00B7:
return;
}
private void DoPostAttack()
{
if (this.subState != 1)
{
goto Label_003B;
}
base.audio.Stop();
if (base.hasNavMeshAgent == null)
{
goto Label_002D;
}
base.agent.Stop();
Label_002D:
this.animState = 5;
this.subState = 2;
Label_003B:
if (this.subState != 2)
{
goto Label_0082;
}
base.delayTimer += Time.deltaTime;
if (base.delayTimer <= 3.5f)
{
goto Label_0082;
}
base.delayTimer = 0f;
this.enemyState = 3;
this.subState = 1;
Label_0082:
return;
}
private void DoRetreat()
{
if (this.subState != 1)
{
goto Label_0042;
}
base.audio.Stop();
this.PlayAudioRetreat();
this.animState = 3;
this.subState = 2;
base.agent.speed = base.movingSpeed * 3f;
Label_0042:
if (this.subState != 2)
{
goto Label_0121;
}
this.effectAmount -= Time.deltaTime * 2f;
this._babiScale -= 0.1f * Time.deltaTime;
base.transform.localScale = new Vector3(this._babiScale, this._babiScale, this._babiScale);
if (this._babiScale >= 0.5f)
{
goto Label_00BB;
}
this._babiScale = 0.5f;
Label_00BB:
if (base.isImmobilize != null)
{
goto Label_00E7;
}
if (base.hasNavMeshAgent == null)
{
goto Label_00E7;
}
base.agent.destination = this.retreatPoint.position;
Label_00E7:
if (base.distanceToTarget >= 2f)
{
goto Label_0121;
}
NotificationCenter.instance.PostNotification(new Notification(0x56, base.gameObject, base.attackTarget, base.attackDamage));
base.isAttacking = 1;
Label_0121:
return;
}
private void DoSleep()
{
if (this.subState != 1)
{
goto Label_0052;
}
base.audio.Stop();
base.health = base.maxHealth;
base.delayTimer = 0f;
if (base.hasNavMeshAgent == null)
{
goto Label_0044;
}
base.agent.Stop();
Label_0044:
this.animState = 7;
this.subState = 2;
Label_0052:
if (this.subState != 2)
{
goto Label_005E;
}
Label_005E:
return;
}
private void DoStuck()
{
if (this.subState != 1)
{
goto Label_003B;
}
base.audio.Stop();
if (base.hasNavMeshAgent == null)
{
goto Label_002D;
}
base.agent.Stop();
Label_002D:
this.animState = 6;
this.subState = 2;
Label_003B:
if (this.subState != 2)
{
goto Label_0081;
}
if (base.distanceToTarget >= 2f)
{
goto Label_0081;
}
NotificationCenter.instance.PostNotification(new Notification(0x56, base.gameObject, base.attackTarget, base.attackDamage));
base.isAttacking = 1;
Label_0081:
return;
}
private void DoWakeUp()
{
if (this.subState != 1)
{
goto Label_0025;
}
base.audio.Stop();
this.animState = 8;
this.subState = 2;
Label_0025:
if (this.subState != 2)
{
goto Label_007C;
}
base.delayTimer += Time.deltaTime;
if (base.delayTimer <= base.animation["sleep_end_brutal"].length)
{
goto Label_007C;
}
base.delayTimer = 0f;
this.enemyState = 1;
this.subState = 1;
Label_007C:
return;
}
private void DoWalk()
{
object[] objArray1;
if (this.subState != 1)
{
goto Label_007E;
}
this._babiScale = 0.87f;
base.transform.localScale = new Vector3(this._babiScale, this._babiScale, this._babiScale);
base.audio.Stop();
if (base.hasNavMeshAgent == null)
{
goto Label_0070;
}
base.agent.speed = base.movingSpeed;
base.agent.stoppingDistance = 0f;
Label_0070:
this.animState = 2;
this.subState = 2;
Label_007E:
if (this.subState != 2)
{
goto Label_015B;
}
if (base.isImmobilize != null)
{
goto Label_0100;
}
Label_0095:
try
{
if (base.hasNavMeshAgent == null)
{
goto Label_00BB;
}
base.agent.destination = base.wpTarget.transform.position;
Label_00BB:
goto Label_0100;
}
catch (NullReferenceException)
{
Label_00C0:
objArray1 = new object[] { "ERROR BABI !!!!!!!!!!!! : Agent : ", base.agent, " ; wpTarget : ", base.wpTarget, " ; " };
Debug.LogError(string.Concat(objArray1));
goto Label_0100;
}
Label_0100:
if (base.distanceToWP >= 2f)
{
goto Label_0137;
}
base.wpNumber += 1;
base.ChangeWaypoint();
this.enemyState = 1;
this.subState = 1;
goto Label_015B;
Label_0137:
if (base.IsInsideFOV(base.attackTarget.transform) == null)
{
goto Label_015B;
}
this.enemyState = 3;
this.subState = 1;
Label_015B:
return;
}
public override void End()
{
base.End();
NotificationCenter.instance.RemoveListener(new OnNotificationDelegate(this.OnAttacked), 0x56);
NotificationCenter.instance.RemoveListener(new OnNotificationDelegate(this.OnSleep), 0x98);
NotificationCenter.instance.RemoveListener(new OnNotificationDelegate(this.OnWakeUp), 0x99);
this.retreatPoint = null;
this.mesh = null;
return;
}
public override void Init()
{
base.Init();
this.enemyState = 0;
this.subState = 0;
return;
}
private void OnAttacked(Notification note)
{
GameObject obj2;
GameObject obj3;
obj2 = (GameObject) note.sender;
obj3 = (GameObject) note.target;
base.damageReceived = note.fParam;
if ((obj2.name == "LindaAbilities") == null)
{
goto Label_00CD;
}
if (base.isInvincible != null)
{
goto Label_00CD;
}
if (this.enemyState == 11)
{
goto Label_00CD;
}
if (base.isShot != null)
{
goto Label_00CD;
}
if ((obj3 == base.gameObject) == null)
{
goto Label_00CD;
}
base.shotDelayTimer = base.shotDelay;
base.health -= base.damageReceived;
base.hitCounter += 1;
if (base.health <= 0f)
{
goto Label_00BE;
}
this.enemyState = 10;
this.subState = 1;
goto Label_00CD;
Label_00BE:
this.enemyState = 11;
this.subState = 1;
Label_00CD:
return;
}
protected override void OnDestroy()
{
base.OnDestroy();
return;
}
private void OnSleep(Notification note)
{
this.enemyState = 7;
this.subState = 1;
return;
}
private void OnWakeUp(Notification note)
{
this.enemyState = 8;
this.subState = 1;
return;
}
private void PlayAudioAttack()
{
if (((int) this.audioAttack.Length) != null)
{
goto Label_000E;
}
return;
Label_000E:
if (base.audio.isPlaying != null)
{
goto Label_0049;
}
base.audio.clip = this.audioAttack[UnityEngine.Random.Range(0, (int) this.audioAttack.Length)];
base.audio.Play();
Label_0049:
return;
}
private void PlayAudioChase()
{
if (((int) this.audioChase.Length) != null)
{
goto Label_000E;
}
return;
Label_000E:
if (base.audio.isPlaying != null)
{
goto Label_0049;
}
base.audio.clip = this.audioChase[UnityEngine.Random.Range(0, (int) this.audioChase.Length)];
base.audio.Play();
Label_0049:
return;
}
private void PlayAudioDead()
{
if (((int) this.audioDead.Length) != null)
{
goto Label_000E;
}
return;
Label_000E:
if (base.audio.isPlaying != null)
{
goto Label_0049;
}
base.audio.clip = this.audioDead[UnityEngine.Random.Range(0, (int) this.audioDead.Length)];
base.audio.Play();
Label_0049:
return;
}
private void PlayAudioHit()
{
if (((int) this.audioHit.Length) != null)
{
goto Label_000E;
}
return;
Label_000E:
if (base.audio.isPlaying != null)
{
goto Label_0049;
}
base.audio.clip = this.audioHit[UnityEngine.Random.Range(0, (int) this.audioHit.Length)];
base.audio.Play();
Label_0049:
return;
}
private void PlayAudioIdle()
{
if (((int) this.audioIdle.Length) != null)
{
goto Label_000E;
}
return;
Label_000E:
if (base.audio.isPlaying != null)
{
goto Label_0049;
}
base.audio.clip = this.audioIdle[UnityEngine.Random.Range(0, (int) this.audioIdle.Length)];
base.audio.Play();
Label_0049:
return;
}
private void PlayAudioKejepit()
{
if (((int) this.audioKejepit.Length) != null)
{
goto Label_000E;
}
return;
Label_000E:
if (base.audio.isPlaying != null)
{
goto Label_0049;
}
base.audio.clip = this.audioKejepit[UnityEngine.Random.Range(0, (int) this.audioKejepit.Length)];
base.audio.Play();
Label_0049:
return;
}
private void PlayAudioNgorok()
{
if (((int) this.audioNgorok.Length) != null)
{
goto Label_000E;
}
return;
Label_000E:
if (base.audio.isPlaying != null)
{
goto Label_0049;
}
base.audio.clip = this.audioNgorok[UnityEngine.Random.Range(0, (int) this.audioNgorok.Length)];
base.audio.Play();
Label_0049:
return;
}
private void PlayAudioPatrol()
{
if (((int) this.audioPatrol.Length) != null)
{
goto Label_000E;
}
return;
Label_000E:
if (base.audio.isPlaying != null)
{
goto Label_0049;
}
base.audio.clip = this.audioPatrol[UnityEngine.Random.Range(0, (int) this.audioPatrol.Length)];
base.audio.Play();
Label_0049:
return;
}
private void PlayAudioRetreat()
{
if (((int) this.audioRetreat.Length) != null)
{
goto Label_000E;
}
return;
Label_000E:
if (base.audio.isPlaying != null)
{
goto Label_0049;
}
base.audio.clip = this.audioRetreat[UnityEngine.Random.Range(0, (int) this.audioRetreat.Length)];
base.audio.Play();
Label_0049:
return;
}
private void RegisterDebug()
{
DebugConsole.RegisterCommand("babi", new DebugConsole.DebugCommand(this._debugBabi));
return;
}
protected override void Start()
{
base.Start();
NotificationCenter.instance.AddListener(new OnNotificationDelegate(this.OnAttacked), 0x56);
NotificationCenter.instance.AddListener(new OnNotificationDelegate(this.OnSleep), 0x98);
NotificationCenter.instance.AddListener(new OnNotificationDelegate(this.OnWakeUp), 0x99);
this.RegisterDebug();
return;
}
protected override void Update()
{
base.Update();
if (base.isActing != null)
{
goto Label_0012;
}
return;
Label_0012:
if (base.damagePoint == null)
{
goto Label_0061;
}
if (this.enemyState == 4)
{
goto Label_003A;
}
if (this.enemyState != 6)
{
goto Label_0050;
}
Label_003A:
base.damagePoint.gameObject.SetActive(1);
goto Label_0061;
Label_0050:
base.damagePoint.gameObject.SetActive(0);
Label_0061:
this.UpdateEnemyState();
this.UpdateAnimation();
this.UpdateSound();
this.UpdateShader();
return;
}
private void UpdateAnimation()
{
AnimState state;
switch ((this.animState - 1))
{
case 0:
goto Label_003C;
case 1:
goto Label_0051;
case 2:
goto Label_0066;
case 3:
goto Label_007B;
case 4:
goto Label_0090;
case 5:
goto Label_00A5;
case 6:
goto Label_00BA;
case 7:
goto Label_00CF;
case 8:
goto Label_00E4;
case 9:
goto Label_00F9;
}
goto Label_010E;
Label_003C:
base.animation.CrossFade("idle");
goto Label_010E;
Label_0051:
base.animation.CrossFade("walk");
goto Label_010E;
Label_0066:
base.animation.CrossFade("run");
goto Label_010E;
Label_007B:
base.animation.CrossFade("attack_charge");
goto Label_010E;
Label_0090:
base.animation.CrossFade("post_attack");
goto Label_010E;
Label_00A5:
base.animation.CrossFade("nyangkut");
goto Label_010E;
Label_00BA:
base.animation.CrossFade("sleep_idle");
goto Label_010E;
Label_00CF:
base.animation.CrossFade("sleep_end_brutal");
goto Label_010E;
Label_00E4:
base.animation.CrossFade("hit");
goto Label_010E;
Label_00F9:
base.animation.CrossFade("dead");
Label_010E:
return;
}
private void UpdateEnemyState()
{
EnemyState state;
switch ((this.enemyState - 1))
{
case 0:
goto Label_0040;
case 1:
goto Label_004B;
case 2:
goto Label_0056;
case 3:
goto Label_0061;
case 4:
goto Label_006C;
case 5:
goto Label_008D;
case 6:
goto Label_0077;
case 7:
goto Label_0082;
case 8:
goto Label_0098;
case 9:
goto Label_00A3;
case 10:
goto Label_00AE;
}
goto Label_00B9;
Label_0040:
this.DoIdle();
goto Label_00B9;
Label_004B:
this.DoWalk();
goto Label_00B9;
Label_0056:
this.DoChase();
goto Label_00B9;
Label_0061:
this.DoAttackCharge();
goto Label_00B9;
Label_006C:
this.DoPostAttack();
goto Label_00B9;
Label_0077:
this.DoSleep();
goto Label_00B9;
Label_0082:
this.DoWakeUp();
goto Label_00B9;
Label_008D:
this.DoStuck();
goto Label_00B9;
Label_0098:
this.DoRetreat();
goto Label_00B9;
Label_00A3:
this.DoHit();
goto Label_00B9;
Label_00AE:
this.DoDead();
Label_00B9:
return;
}
private void UpdateShader()
{
this.mesh.renderer.material.SetFloat("_DecalAmount", this.effectAmount);
this.mesh.renderer.material.SetFloat("_DecalLitAmount", this.effectAmount);
if (this.effectAmount >= 0f)
{
goto Label_005B;
}
this.effectAmount = 0f;
Label_005B:
if (this.effectAmount <= 0.5f)
{
goto Label_0076;
}
this.effectAmount = 0.5f;
Label_0076:
return;
}
private void UpdateSound()
{
EnemyState state;
switch ((this.enemyState - 1))
{
case 0:
goto Label_0040;
case 1:
goto Label_008D;
case 2:
goto Label_0056;
case 3:
goto Label_006C;
case 4:
goto Label_008D;
case 5:
goto Label_0061;
case 6:
goto Label_004B;
case 7:
goto Label_008D;
case 8:
goto Label_008D;
case 9:
goto Label_0077;
case 10:
goto Label_0082;
}
goto Label_008D;
Label_0040:
this.PlayAudioIdle();
goto Label_008D;
Label_004B:
this.PlayAudioNgorok();
goto Label_008D;
Label_0056:
this.PlayAudioChase();
goto Label_008D;
Label_0061:
this.PlayAudioKejepit();
goto Label_008D;
Label_006C:
this.PlayAudioAttack();
goto Label_008D;
Label_0077:
this.PlayAudioHit();
goto Label_008D;
Label_0082:
this.PlayAudioDead();
Label_008D:
return;
}
public enum AnimState
{
None,
Idle,
Walk,
Chase,
AttackCharge,
PostAttack,
Stuck,
Sleep,
WakeUp,
Hit,
Dead
}
public enum EnemyState
{
None,
Idle,
Walk,
Chase,
AttackCharge,
PostAttack,
Stuck,
Sleep,
WakeUp,
Retreat,
Hit,
Dead
}
public enum SubState
{
None,
Init,
Active
}
}
↧