public override void Execute(EnemyController enemyController) { PatrolController patrolController = (PatrolController)enemyController; if (!_currentState.checkValid(patrolController) || _isFinished) { // randomly change current state int randomStateCase; do { randomStateCase = UnityEngine.Random.Range(0, 3); } while (randomStateCase == _currentStateCase); _currentStateCase = randomStateCase; switch (_currentStateCase) { case 0: _currentState = new Idle(); break; case 1: _currentState = new WalkingLeft(); break; case 2: _currentState = new WalkingRight(); break; } patrolController.StartCoroutine(executeCoroutine(patrolController.behaveInterval())); } _currentState.Execute(patrolController); }
public override void Execute(EnemyController enemyController) { PatrolController patrolController = (PatrolController)enemyController; float dist = patrolController.playerEnemyDistance(); patrolController.walk(Math.Abs(dist) < 0.1f ? 0 : dist); }
private void AttackThief() { DeathmatchAgent agent = GetComponentInParent <DeathmatchAgent>(); PatrolController patrolController = GetComponentInParent <PatrolController>(); agent.TrackLayerAndTag(m_InteractorGameObject.layer, m_InteractorGameObject.tag); patrolController.CheckAlarm(m_InteractorGameObject); }
void Awake() { rigidBody = GetComponent <Rigidbody2D>(); circleCollider2D = GetComponent <CircleCollider2D>(); patrolController = GetComponent <PatrolController>(); spriteRenderer = GetComponent <SpriteRenderer>(); audioSource = GetComponent <AudioSource>(); animator = GetComponent <Animator>(); soulPrefab = Resources.Load("Prefabs/Soul"); }
public void Alarm(float radius) { Collider[] hitColliders = Physics.OverlapSphere(transform.position, radius, layerMask.value); foreach (Collider collider in hitColliders) { PatrolController controller = collider.GetComponent <PatrolController>(); if (controller != null) { controller.CheckAlarm(gameObject); } } }
public MiteEnemyController(MiteEnemy e) : base(e) { this.enemy = e; this.enemyAnimator = e.GetComponentInChildren <Animator>(); this.transform = e.transform; this.rb = e.GetComponent <Rigidbody2D>(); this.patrolController = e.GetComponent <PatrolController>(); this.playerTransform = PlayerManager.instance.playerObject.transform; this.playerCharacter = PlayerManager.instance.playerCharacter; this.playerDamageable = this.playerTransform.GetComponent <IDamageableEntity>(); }
void Start() { if (flowchart == null && flowchartName != null && flowchartName.Trim().Length != 0) { flowchart = GameObject.Find(flowchartName).GetComponent <Fungus.Flowchart>(); } patrolController = GetComponentInParent <PatrolController>(); health = GetComponentInParent <CustomHealth>(); behaviorTree = GetComponentInParent <BehaviorTree>(); navMeshAgent = GetComponentInParent <NavMeshAgent>(); deathmatchAgent = GetComponentInParent <DeathmatchAgent>(); }
private void Teleport(GameObject character, GameObject teleport) { PatrolController patrolController = character.GetComponent <PatrolController>(); if (patrolController != null && patrolController.enabled) { patrolController.TeleportToWaypoint(teleport); } else { character.transform.position = teleport.transform.position; character.transform.rotation = teleport.transform.rotation; } }
public override void OnInspectorGUI() { PatrolController script = (PatrolController)target; DrawDefaultInspector(); if (GUILayout.Button("Reset")) { Undo.RecordObject(script, "Reset point"); script.points.Clear(); Vector2 pos = script.transform.position; script.points.Add(pos + Vector2.right * 1f); script.points.Add(pos - Vector2.right * 1f); } }
protected virtual void OnSceneGUI() { PatrolController script = (PatrolController)target; for (int i = 0; i < script.points.Count; i++) { EditorGUI.BeginChangeCheck(); Vector2 newPoint = Handles.PositionHandle(script.points[i], Quaternion.identity); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(script, "Change point"); script.points[i] = newPoint; script.OnValidate(); } } }
private void Awake() { rb = GetComponent <Rigidbody2D>(); originalAngle = rb.transform.rotation; los_rb = lineOfSight.GetComponent <Rigidbody2D>(); playerRb = player.GetComponent <Rigidbody2D>(); playerCol = player.GetComponent <CircleCollider2D>(); playerMov = player.GetComponent <PlayerMovement>(); destinationSetter = GetComponent <AIDestinationSetter>(); pathfinding = GetComponent <AIPath>(); audioMgr = GameObject.Find("AudioManager").GetComponent <AudioManager>(); patrol = GetComponent <PatrolController>(); anim = gfx.GetComponent <Animator>(); }
void Awake() { patrolController = transform.parent.GetComponent <PatrolController>(); }
public override void Execute(PatrolController patrolController) { patrolController.walk(1); }
public override bool checkValid(PatrolController patrolController) { return(patrolController.reachEdge() != 1); }
public abstract void Execute(PatrolController enemyController);
public abstract bool checkValid(PatrolController enemyController);