// Use this for initialization private void Start() { Parent = GetComponent <Rigidbody>(); Target = TargetObject.GetComponent <Rigidbody>(); NavAgent = GetComponent <NavMeshAgent>(); var childObjects = GetChildrenComponents(); GameObject _turretPointObject = childObjects.Find(child => child.name == "DroneTurretPoint"); _turretPoint = _turretPointObject.transform; _stateCache[typeof(BossPatrolState)] = new BossPatrolState(this, Parent.rotation, PatrolPath); _stateCache[typeof(BossAttackState)] = new BossAttackState (this, MuzzleFlash, BloodParticles, ImpactParticles, _turretPointObject, AimDistortion, AimSteadiness, AcceptableShotRangeInDeg, ShotsPerSecond ); _stateCache[typeof(BossReturnState)] = new BossReturnState(this, Parent.position, Parent.rotation); _stateCache[typeof(BossLookoutState)] = new BossLookoutState(this); SetState(typeof(BossPatrolState)); }
// Use this for initialization void Start() { sm = new FSMSystem(); Debug.Log("Add IdleState"); BossIdleState bis = new BossIdleState(); bis.AddTransition(Transition.NearPlayer, StateID.BossAttack); BossAttackState bas = new BossAttackState(); bas.AttackProjPrefab(proj); bas.AddTransition(Transition.LostPlayer, StateID.BossIdle); bas.shootInterval = shootInterval; sm.AddState(bis); sm.AddState(bas); //player = Global.Instance.player; Rigidbody2D rigidBody2D = GetComponent <Rigidbody2D>(); rigidBody2D.velocity = new Vector3(Random.value, Random.value, 0).normalized *flySpd; Global.Instance.boss = this.gameObject; hp = GetComponent <Health>(); hp.SetHp(_hp); EnemyHealthBar ehbscript = GetComponent <EnemyHealthBar>(); ehbscript.cam = Global.Instance.cam; }
public static BossAttackState GetInstance() { if (_instance == null) { _instance = new BossAttackState(); } return(_instance); }
public override void Update(BossAgent agent) { if (agent.GetIsPlayerInRange()) { agent.SetState(BossFollowPlayerState.GetInstance()); } if (agent.GetIsBaseInAttackRange()) { agent.SetState(BossAttackState.GetInstance()); } }
public override void Update(BossAgent agent) { agent.SetPlayerAsTarget(); if (agent.GetIsPlayerInAttackRange()) { agent.SetState(BossAttackState.GetInstance()); } if (!agent.GetIsPlayerInRange()) { agent.SetState(BossChargeTownState.GetInstance()); } }
private void Awake() { anim = GetComponent <Animator>(); agent = GetComponent <NavMeshAgent>(); agent.speed = speed; outlineScript = GetComponentInChildren <Outline>(); player = GameObject.FindGameObjectWithTag("Player").transform; attackState = new BossAttackState(this); walkState = new BossWalkState(this); defendState = new BossDefendState(this); SetState(walkState); }