void Awake() { if (hexagonLayer == 0) { hexagonLayer = 1 << LayerMask.NameToLayer("Hexagon"); } staticState = new HexagonStaticState(this); idleState = new HexagonIdleState(this); borderWallState = new HexagonBorderWallState(this); movingState = new HexagonMovingState(this); enterExitState = new HexagonEnterExitState(this); infectedState = new HexagonInfectedState(this); warningState = new HexagonWarningState(this); belowAttackState = new HexagonBelowAttackState(this); belowAttackAdjacentState = new HexagonBelowAttackAdjacentState(this); belowAttackWallState = new HexagonBelowAttackWallState(this); aboveAttackState = new HexagonAboveAttackState(this); aboveAttackAdjacentState = new HexagonAboveAttackAdjacentState(this); meteorAttackState = new HexagonMeteorAttackState(this); minDistanceToPlayer = minHexagonsToPlayer * DISTANCE_BETWEEN_HEXAGONS; sphereCollider = GetComponent <SphereCollider>(); geometryOffset = transform.FindDeepChild("GeometryOffset").gameObject; geometryOriginalY = geometryOffset.transform.position.y; spawnPoint = transform.FindDeepChild("SpawnPoint").gameObject; wormProbesInRange = 0; //enemyProbesInRange = 0; enemiesInRange.Clear(); playerProbesInRange = 0; CheckNeighbours(); turret = null; if (isStatic) { Transform turretTrf = transform.FindDeepChild("Turret"); if (turretTrf != null) { turret = turretTrf.GetComponent <TurretAIBehaviour>(); } else { columnColliders.transform.localPosition = new Vector3(0f, 10f, 0f); } currentState = staticState; navMeshObstacles.SetActive(true); columnRend.sharedMaterial = floorStaticMat; } else { currentState = idleState; navMeshObstacles.SetActive(false); } }
void OnTriggerEnter(Collider other) { if (other.tag == "Enemy") { EnemyBaseAIBehaviour enemy = other.GetComponent <EnemyBaseAIBehaviour>(); //Mosquito has the collider in a children object so we need to search for script in parent if (enemy == null) { enemy = other.GetComponentInParent <EnemyBaseAIBehaviour>(); } if (enemy != null) { bb.enemiesInRange.Add(enemy); } } else if (other.tag == "Shot") { EnemyShotControllerBase shot = other.GetComponent <EnemyShotControllerBase>(); if (shot != null) { bb.shotsInRange.Add(shot); } } else if (other.tag == "WormHead") { WormAIBehaviour worm = other.GetComponent <WormAIBehaviour>(); if (worm != null) { bb.worm = worm; worm.SpecialAttackInRange(); } } else if (other.tag == "Vortex") { VortexController vortex = other.GetComponent <VortexController>(); if (vortex != null) { bb.vortexInRange.Add(vortex); } } else if (other.tag == "Turret") { TurretAIBehaviour turret = other.GetComponent <TurretAIBehaviour>(); if (turret != null) { bb.turretsInRange.Add(turret); } } }
void Awake() { turret = GetComponentInParent <TurretAIBehaviour>(); }