private void OnEnemyStateUpdateHungry() { if (m_agent != null && m_agent.isActiveAndEnabled) { if (!m_agent.isOnNavMesh) // for some reason, even though the spawning logic is the same, this fool is not on the navmesh { // find a spot close ( within 50 units I guess ) to current position that is on the navmesh NavMeshHit hit; NavMesh.SamplePosition(transform.position, out hit, 50.0f, NavMesh.AllAreas); m_agent.Warp(hit.position); } else { m_currentTargetMushroom = MushroomSpawner.FindClosestMushroom(transform.position); if (m_currentTargetMushroom == null) { return; } // now we can actually move to a mushroom and its legit as f**k m_currentTargetMushroom.GetComponent <Mushroom>().isEnemyTracking = true; Vector3 targetPosition = m_currentTargetMushroom.transform.position; targetPosition.y = transform.position.y; m_agent.destination = targetPosition; m_agent.speed = moveSpeed; SetState(EnemyState.SEEKING_MUSHROOM); } } }
void InitializeControllers() { centipedeSpawner = GetComponent <CentipedeSpawner>(); mushroomSpawner = GetComponent <MushroomSpawner>(); levelsController = GetComponent <LevelsController>(); pointsController = GetComponent <PointsHandler>(); }
public static void ResetStats() { DayNightCycle.RotationSoFar = 0.0f; numMushroomsCollected = 0; mushroomHouseIndex = -1; mushroomHouseSize = 0; currentLevel = 0; SetState(GameState.TitleScreen); MushroomSpawner.Reset(); }
IEnumerator FadeOut() { Color color = spriteRenderer.color; for (int i = 0; i < 10; i++) { color.a -= 0.1f; spriteRenderer.color = color; yield return(new WaitForSeconds(0.05f)); } MushroomSpawner.RemoveShroom(); Destroy(gameObject); }
private void Update() { if (mushroomHome == null) { mushroomHome = GameObject.Find("MushroomHome").GetComponent <MushroomHome>(); mushroomHome.gm = this; swapMeshLevel = numLevels / (mushroomHome.meshes.Length + 1); mushroomHome.scaleFactor = scaleFactor; cameraStretcher.MushroomHome = mushroomHome.gameObject; SetShroomsCollect(); } if (shroomSpawner == null) { shroomSpawner = GameObject.Find("MushroomSpawner").GetComponent <MushroomSpawner>(); } if (enemySpawner == null) { enemySpawner = GameObject.Find("EnemySpawner").GetComponent <EnemySpawner>(); } if (hud == null) { hud = GameObject.Find("HUD").GetComponent <HUD>(); } UpdateHUD(); cameraStretcher.scaleFactor = scaleFactor; cameraStretcher.stretchTime = screenExpandTime; mushroomHome.growthTime = homeGrowthTime; mushroomHome.eatTime = eatTime; cameraStretcher.vignetteInTime = vignetteInTime; cameraStretcher.vignetteOutTime = vignetteOutTime; }
private void OnEnemyStateChasePlayer() { if (m_agent != null && m_agent.isActiveAndEnabled && m_agent.isOnNavMesh) { m_agent.destination = m_player.transform.position; m_agent.speed = moveSpeed * 1.5f; } if (m_player.GetComponent <Player>().PickedMushrooms.Count <= 1) { SetState(EnemyState.HUNGRY); } GameObject mushroom = MushroomSpawner.FindClosestMushroom(transform.position); if (mushroom) { float distanceToTarget = Vector3.Distance(transform.position, mushroom.transform.position); float distanceToPlayer = Vector3.Distance(transform.position, m_player.transform.position); if (distanceToTarget < distanceToPlayer) { SetState(EnemyState.HUNGRY); } } }
private void OnExitIdle() { MushroomSpawner.RemoveIdleMushroom(); }
private void OnDestroy() { MushroomSpawner.RemoveMushroom(); }