/// <summary> /// This is agent's field of view. If next item appears in agent's fov then it decides to transition to other state /// </summary> private void OnTriggerEnter(Collider other) { if (!this.enabled || (thisGrowController.score > maxAllowedScore && !visibilityController.isVisible)) { return; } /* THIS IS SiMULATION OF GROW FOR AI TO SIMULATE DIFFICULTY*/ if (!visibilityController.isVisible) { if (currentGrowRate >= simulateGrowRate) { thisGrowController.SimulateGrow(); currentGrowRate = 0; } else { currentGrowRate++; } } food = other.GetComponent <Food>(); controller = other.GetComponent <GrowController>(); if (food && state != States.Follow && food.points == 0) { if (arrayLength < foodPositions.Length) { foodPositions[arrayLength] = other.transform; arrayLength++; if (state != States.Search) { SetSearch(); } } } if (controller && canHit && thisGrowController.score > startKillScore) { if (state != States.Follow) { if (controller.score < thisGrowController.score) { SetFollow(controller.transform, controller.gameObject); } } } }
WaitForSeconds followUpdate; //update of aim position private void Start() { state = States.Null; visibilityController = GetComponentInChildren <Visibility>(); thisTransform = transform; thisGrowController = GetComponent <GrowController>(); path = WorldBounds.singleton.GetRandomPath(); pathCount = path.positions.Count; index = Random.Range(0, pathCount); walkUpdate = new WaitForSeconds(updateTime); followUpdate = new WaitForSeconds(updateTime / 2f); ai = GetComponent <NavMeshAgent>(); anim = GetComponent <Animator>(); SetIdle(); }
private void Start() { _draggable = gameObject.GetComponent <Draggable>(); _rigidBody = gameObject.GetComponent <Rigidbody>(); _growController = gameObject.GetComponent <GrowController>(); }