// Moving agent to a point public void moveTo(Point point) { Collider2D hitCollider = Physics2D.OverlapCircle(position, 0.3f, 1 << 9); // Moving is now using translate to make the game more consistent Vector2 dir = currTarget.getCurrPosition() - position; // half the movement speed if the enemy are shocked, stop when freeze or stopped this.transform.Translate(dir.normalized * property.speed * Time.deltaTime * (shockTimer > 0 ? 0.5f : 1f) * (status == EnemyStatus.STOPPED || status == EnemyStatus.FROZEN ? 0f : 1f) * (hitCollider != null && truck != null && !truck.isExploding() ? 0f : 1f), Space.World); position = this.gameObject.transform.position; if (isNowAt(point.getCurrPosition()) && point.getIsStartPoint()) { // activate the enemy (change layer) activate(); } // if lost the truck and not near the tower if (hitCollider == null && !(isNowAt(point.getCurrPosition()) && point.getIsEndPoint()) && !(status == EnemyStatus.STOPPED || status == EnemyStatus.FROZEN)) { status = EnemyStatus.MOVING; } // prioritize the truck if (hitCollider != null && !(status == EnemyStatus.STOPPED || status == EnemyStatus.FROZEN) && !hitCollider.GetComponent <TruckBehaviour>().isExploding()) { truck = hitCollider.GetComponent <TruckBehaviour>(); // attack truck attackTruck(); } else if (isNowAt(point.getCurrPosition()) && point.getIsEndPoint()) { // attack koto tower attackKotoTower(); } else if (isNowAt(point.getCurrPosition())) { // If the agent reach a destination that is not end point changeTargetFromCurrPoint(currTarget); } }
// initialize variables private void Awake() { isTouchedLeft = false; isTouchedRight = false; rightTimer = 0f; leftTimer = 0f; // based on the game type change camera position if (GameManager.instance.isTutorial) { cameraPosition = new Vector3(0f, 0f, -10f); } else { this.gameObject.transform.position = new Vector3(minX - 2, 0f, -10f); cameraPosition = new Vector3(minX - 2, 0f, -10f); } cam = this.GetComponent <Camera>(); truck = GameObject.FindGameObjectWithTag("Truck").GetComponent <TruckBehaviour>(); }
// Initialization void Start() { truck = this.transform.parent.GetComponent <TruckBehaviour>(); arrows = new List <ArrowsDirection>(this.GetComponentsInChildren <ArrowsDirection>(true)); }
// initialization private void Awake() { truck = GameObject.FindGameObjectWithTag("Truck").GetComponent <TruckBehaviour>(); }
// variable initialization private void Awake() { // find all object truck = GameObject.FindGameObjectWithTag("Truck").GetComponent <TruckBehaviour>(); charCharge = GameObject.FindGameObjectWithTag("Char Charge").GetComponent <TextMesh>(); truck.gameObject.SetActive(false); // for koto Tower truckSpawnPoint = GameObject.FindGameObjectWithTag("Koto Tower").GetComponent <Point>(); kotoTower = GameObject.FindGameObjectWithTag("Koto Tower").GetComponent <ClickOnKotoTower>(); // possible answer's button possibleAnswers = new List <Button>(); possibleAnswers.AddRange(kotoTower.gameObject.GetComponentsInChildren <Button>()); // possible anwer possibleAnswersText = new List <Text>(); foreach (Button answer in possibleAnswers) { possibleAnswersText.Add(answer.GetComponentInChildren <Text>()); } // easy : all 5 easy // medium : 3 easy + 5 medium // hard : 2 easy + 3 medium + 5 hard questions = new Queue <DifficultyType>(); switch (GameManager.instance.difficultyIdx) { case 0: for (int i = 0; i < 5; i++) { questions.Enqueue(DifficultyType.EASY); } break; case 1: for (int i = 0; i < 3; i++) { questions.Enqueue(DifficultyType.EASY); } for (int i = 0; i < 5; i++) { questions.Enqueue(DifficultyType.MEDIUM); } break; case 2: for (int i = 0; i < 2; i++) { questions.Enqueue(DifficultyType.EASY); } for (int i = 0; i < 3; i++) { questions.Enqueue(DifficultyType.MEDIUM); } for (int i = 0; i < 5; i++) { questions.Enqueue(DifficultyType.HARD); } break; default: break; } GameManager.instance.isNewQuestion = true; }
void Awake() { behaviour = GetComponent <TruckBehaviour>(); }