// Use this for initialization void Start() { anim = GetComponent <Animator>(); levelScaleToDays = gameController.getLevelScale(); levelStartRatio = gameController.getLevelStartRatio(); day = sundial.getDayCount(); hungerFactor = (maxHungerFactor * levelStartRatio) + ((maxHungerFactor * (1 - levelStartRatio)) / levelScaleToDays) * sundial.getDayCount(); }
// Use this for initialization void Start() { anim = GetComponent <Animator>(); SF_throwSpearObj = GameObject.Find("SF_ThrowSpear"); SF_throwSpear = SF_throwSpearObj.GetComponent <AudioSource>(); SF_hunterRunawayObj = GameObject.Find("SF_HunterRunaway"); SF_hunterRunaway = SF_hunterRunawayObj.GetComponent <AudioSource>(); SF_hunterChaseObj = GameObject.Find("SF_HunterChase"); SF_hunterChase = SF_hunterChaseObj.GetComponent <AudioSource>(); alertBox = this.transform.FindChild("Alert").gameObject; ahhhBox = this.transform.FindChild("Ahhh").gameObject; levelScaleToDays = gameController.getLevelScale(); levelStartRatio = gameController.getLevelStartRatio(); dayCount = sundial.getDayCount(); walkSpeed = (maxWalkSpeed * levelStartRatio) + ((maxWalkSpeed * (1 - levelStartRatio)) / levelScaleToDays) * sundial.getDayCount(); runSpeed = (maxRunSpeed * levelStartRatio) + ((maxRunSpeed * (1 - levelStartRatio)) / levelScaleToDays) * sundial.getDayCount(); screenHeight = Camera.main.orthographicSize; screenWidth = Camera.main.aspect * screenHeight; }
// Update is called once per frame void Update() { dayCount = sundial.getDayCount(); float moveSpeed = 0; moveSpeed = (maxMoveSpeed * levelStartRatio) + ((maxMoveSpeed * (1 - levelStartRatio)) / levelScaleToDays) * sundial.getDayCount(); if (moveSpeed > maxMoveSpeed) { moveSpeed = maxMoveSpeed; } interpSpeed = moveSpeed / Vector3.Distance(originalPosition, target); lifeTime += Time.deltaTime; u += interpSpeed * Time.deltaTime; if (u >= 1.0f) { u = 1.0f; finished = true; } else if (lifeTime >= maxLifeTime) { finished = true; } transform.position = Vector3.Lerp(originalPosition, target, u); /* * Original spear kill rabbit code, moving it to PlayerTrigger.cs * if(Vector3.Distance(player.transform.position, transform.position) < 0.1) * { * if(!gameController.IsReviving()){ * player.SetActive(false); * gameController.GameOverDisplay(); * }else{ * Debug.Log("resetting revival"); * StartCoroutine(gameController.Wait()); * gameController.Reviving(false); * } * // remove this spear * Destroy(gameObject); * } else if(finished) * { * Destroy(gameObject); * } */ if (finished) { Destroy(gameObject); } }
// Update is called once per frame void Update() { if (player.activeSelf) { spawnTimer -= Time.deltaTime; if (sundial.day > day) { day = sundial.day; avgSpawnTime = Mathf.Max(startingAverageSpawnTime * Mathf.Pow((1.0f / spawnDivisor), (sundial.day + 1) / 2), 0.5f); maxEnemyCount = maxEnemyCount + sundial.getDayCount() * maxEnemyByDayRatio; } if (spawnTimer <= 0) { GameObject[] getEnemyCount; int currentEnemyCount; try { getEnemyCount = GameObject.FindGameObjectsWithTag("Enemy"); currentEnemyCount = getEnemyCount.Length; } catch (UnityException ex) { currentEnemyCount = 0; } Debug.Log(currentEnemyCount + "/" + maxEnemyCount); if (currentEnemyCount < maxEnemyCount) { float screenWidth, screenHeight; float enemyWidth, enemyHeight; float spawnWidth, spawnHeight; screenHeight = Camera.main.orthographicSize; screenWidth = Camera.main.aspect * screenHeight; enemyHeight = enemyPrefab.renderer.bounds.extents.y; enemyWidth = enemyPrefab.renderer.bounds.extents.x; spawnWidth = Random.Range(screenWidth, screenWidth + enemyWidth); //returns 0 or 1, 0 = left side of screen, 1 = right side of screen if (Random.Range(0, 2) < 1) { spawnWidth = 0 - spawnWidth; } spawnHeight = Random.Range(screenHeight, screenHeight + enemyHeight); //returns 0 or 1, 0 = above screen, 1 = below screen if (Random.Range(0, 2) < 1) { spawnHeight = 0 - spawnHeight; } Vector3 spawnPosition = new Vector3(spawnWidth, spawnHeight, 0); Enemy instance; instance = Instantiate(enemyPrefab, spawnPosition, Quaternion.identity) as Enemy; instance.player = player; instance.sundial = sundial; instance.gameController = gameController; instance.goal = spawnPosition; spawnTimer = Random.Range(avgSpawnTime * 0.5f, avgSpawnTime * 1.5f); } } } }