private string GetBestSavedScoreLookUp() { string levelKey = ChunkSpawner.GetInstance().GetLevelKey(); string lookUp = levelKey; return(lookUp); }
public void SpawnWorld(Vector3 center, int extends) { //Get Spawner ChunkSpawner spawner = WorldServ.Entity.GetComponent <ChunkSpawner>(); //Spawn spawner.SpawnAtArea(center, extends, WorldServ); }
private static ChunkSpawner GetInstance() { if (instance == null) { instance = FindObjectOfType <ChunkSpawner>(); } return(instance); }
public override void OnInspectorGUI() { chunkSpawner = GameObject.Find("ChunkSpawner").GetComponent <ChunkSpawner>(); if (GUILayout.Button("Assign Avaliable Chunks")) { FindChunks(); } }
private void HandleWallClimb() { // wall climb if (isGrabbingWall) { Vector2 climbVector = new Vector2(0, inputVerticalAxis * speed); if (isStuck) { climbVector /= stuckSlowdownFactor; } rigidbody2d.velocity = climbVector; if (inputVerticalAxis != 0 && !ObstructionAboveOverlapCircle(0.1f, 0.1f)) { StartWallClimbSound(); anim.SetBool("isClimbing", true); } else { StopWallClimbSound(); anim.SetBool("isClimbing", false); } anim.SetBool("isWallGrabbing", true); // Set off climb tooltip if player hasn't climbed in level yet if (GameManager.GetInstance().GetState() == GameManager.GameState.Play && GameManager.GetInstance().levelInputConfig.includeTutorialChunks&& IsOnRightWall() && !ChunkSpawner.GetInstance().IsKnownSkill(Skill.WallClimb) && !wallClimbTooltipShown) { wallClimbTooltip.parent = ChunkSpawner.GetInstance().LastChunk().transform; wallClimbTooltip.Activate(transform.position + wallClimbTooltip.position); wallClimbTooltipShown = true; } // Set off detach tooltip if player hasn't attached to left side yet if (GameManager.GetInstance().GetState() == GameManager.GameState.Play && GameManager.GetInstance().levelInputConfig.includeTutorialChunks&& IsOnLeftWall() && !ChunkSpawner.GetInstance().IsKnownSkill(Skill.WallJump) && !wallDetachTooltipShown) { wallDetachTooltip.parent = ChunkSpawner.GetInstance().LastChunk().transform; wallDetachTooltip.Activate(transform.position + wallDetachTooltip.position); wallDetachTooltipShown = true; } } else { anim.SetBool("isWallGrabbing", false); anim.SetBool("isClimbing", false); StopWallClimbSound(); } }
/// <summary> /// Gets the index of the chunk that we want. /// </summary> /// <param name="_spawner">the spawner we want the index from.</param> /// <returns>The index of the chunk.S</returns> private int GetIndexOfChunk(ChunkSpawner _spawner) { for (int i = 0; i < chunks.Count; i++) { if (chunks[i] == _spawner) { return(i); } } return(0); }
private void Awake() { listener = new UnityAction(SpeedBoost); if (cs == null) { cs = this; } else { Destroy(this); Debug.Log("Only one chunk Spawner is allowed"); } }
/// <summary> /// Creates a new chunk. /// </summary> /// <param name="name">name of the new chunk.</param> private void CreateChunk(string name) { GameObject spawner = new GameObject(name); spawner.transform.parent = map.transform; ChunkSpawner chunkspawner = spawner.AddComponent <ChunkSpawner>(); chunks.Add(chunkspawner); newChunkName = ""; RebuildChunkList(); selectedChunkIndex = GetIndexOfChunk(chunkspawner); FocusChunk(selectedChunkIndex); }
public PatchManager(SpawnSystem spawnSystem, ProcessSystem processSystem, CompoundCloudSystem compoundCloudSystem, TimedLifeSystem timedLife, DirectionalLight worldLight, GameProperties currentGame) { this.spawnSystem = spawnSystem; this.processSystem = processSystem; this.compoundCloudSystem = compoundCloudSystem; this.timedLife = timedLife; this.worldLight = worldLight; CloudSpawner = new CompoundCloudSpawner(compoundCloudSystem); ChunkSpawner = new ChunkSpawner(compoundCloudSystem); MicrobeSpawner = new MicrobeSpawner(compoundCloudSystem, currentGame); }
public GameObject GetResourceToSpawn() { ResourceType type; if (SafeChunk() && CurrentSpawnIndex <= 2) { type = (ResourceType)CurrentSpawnIndex; } else { if (CurrentAlienSpawn > AlienSpawnLimit) { type = (ResourceType)Random.Range(0, 2); } else { type = (ResourceType)Random.Range(0, 3); } } CurrentSpawnIndex++; ChunkSpawner cs = GetComponentInParent <ChunkSpawner>(); switch (type) { case ResourceType.Stone: return(cs.Stones[Random.Range(0, cs.Stones.Length)]); case ResourceType.Wood: return(cs.Wood[Random.Range(0, cs.Wood.Length)]); case ResourceType.Alien: CurrentAlienSpawn++; return(cs.Aliens[Random.Range(0, cs.Aliens.Length)]); } Debug.Log("Retornando nulo! " + type); return(null); }
/// <summary> /// Gets the index of the chunk that we want. /// </summary> /// <param name="_spawner">the spawner we want the index from.</param> /// <returns>The index of the chunk.S</returns> private int GetIndexOfChunk(ChunkSpawner _spawner) { for (int i = 0; i < chunks.Count; i++) { if(chunks[i] == _spawner) { return i; } } return 0; }
void Start() { chunkSpawner = GameObject.Find("SpawmPipe").GetComponent <ChunkSpawner>(); }
private void HandleHorizontalMovement() { if (!isDashing) { bool justStartedWallJumping = wallJumpTimeLeft > wallJumpResetTime - 0.1; // move sidewards if (!isGrabbingWall && !justStartedWallJumping) { // sliding while background not moving - slow down amount that horizontal movement has one speed if (GameManager.GetInstance().GetState() != GameManager.GameState.Play && isSliding) { rigidbody2d.velocity = new Vector2(inputHorizontalAxis * speed / 2, rigidbody2d.velocity.y); } else if (GameManager.GetInstance().GetState() == GameManager.GameState.Play && isStuck) { float velX = -1 * stuckSlowdownFactor; velX += (inputHorizontalAxis * speed) / stuckSlowdownFactor; rigidbody2d.velocity = new Vector2(velX, rigidbody2d.velocity.y); } // ground movement else if (!isWallJumpingLeft && !isWallJumpingRight && IsGrounded()) { if (isSliding && inputHorizontalAxis < 0) { inputHorizontalAxis /= 2; } rigidbody2d.velocity = new Vector2(inputHorizontalAxis * speed, rigidbody2d.velocity.y); } // normal air movement else if (!isWallJumpingLeft && !isWallJumpingRight && !IsGrounded()) { rigidbody2d.velocity = Vector2.Lerp(rigidbody2d.velocity, new Vector2(inputHorizontalAxis * speed, rigidbody2d.velocity.y), airAcceleration * Time.deltaTime); } // prevent moving back to the wall if jumping away from it else { rigidbody2d.velocity = Vector2.Lerp(rigidbody2d.velocity, new Vector2(inputHorizontalAxis * speed, rigidbody2d.velocity.y), wallJumpStopMultiplier * Time.deltaTime); } } bool isOnWall = IsOnLeftWall() || IsOnRightWall(); // Running sound bool isRunning = (GameManager.GetInstance().GetState() == GameManager.GameState.Play && IsGrounded() && !isSliding && !isOnWall) || (GameManager.GetInstance().GetState() != GameManager.GameState.Play && IsGrounded() && inputHorizontalAxis != 0 && !isSliding && !isOnWall); runParticles.gameObject.SetActive(isRunning); // Stop at ledge if (GameManager.GetInstance().GetState() == GameManager.GameState.Play && AtRightLedge() && inputHorizontalAxis == 0 && ledgeAutoStop) { Vector2 pos = transform.position; pos.x -= ChunkSpawner.GetInstance().levelConfig.speed *Time.deltaTime; transform.position = pos; isRunning = false; } if (isRunning) { StartRunSound(); anim.SetBool("isRunning", true); } else { StopRunSound(); anim.SetBool("isRunning", false); } } }
public override IEnumerable <ISpawned> Spawn() { yield return(ChunkSpawner.Spawn(Position, chunkType, WorldNode)); }
public ChunkItem(ChunkConfiguration chunkType, ChunkSpawner chunkSpawner) { this.chunkType = chunkType; ChunkSpawner = chunkSpawner; }
private void Awake() { instance = this; }
private void HandleSlide() { bool canSlide = CanSlideRight(boxCollider2d.bounds.size.y / 2); // TODO: replace this parameter with the slide collider height when it is known if (GameManager.GetInstance().GetState() != GameManager.GameState.Play) { canSlide = canSlide && CanSlideLeft(boxCollider2d.bounds.size.y / 2); } if (inputVerticalAxisDown < 0 && IsGrounded() && !isSliding && canSlide) { StartSlide(); } if (isSliding && slideTimeLeft > 0) { if (slideFxPrefab) { var slideParticles = Instantiate(slideFxPrefab); Vector3 particlesPosition = slideParticles.transform.position; particlesPosition.x = transform.position.x; particlesPosition.y = transform.position.y - 0.5f; slideParticles.transform.position = particlesPosition; if ((GameManager.GetInstance().GetState() == GameManager.GameState.Play || GameManager.GetInstance().GetState() == GameManager.GameState.RunSummary) && ChunkSpawner.GetInstance().LastChunk() != null) { // attach particles to a chunk so that they move left if the game is being played slideParticles.transform.parent = ChunkSpawner.GetInstance().LastChunk().transform; } } ; // If we're not playing the game, then the game is not moving - get player slide to move if (GameManager.GetInstance().GetState() != GameManager.GameState.Play) { float speed; if (slideDirection == HorizontalDirection.Left) { speed = -slideSpeed; } else { speed = slideSpeed; } Vector2 velocity = rigidbody2d.velocity; velocity.x += speed; rigidbody2d.velocity = velocity; } slideTimeLeft -= Time.deltaTime; } else if (isSliding && slideTimeLeft <= 0 && !ObstructionAbove(0.5f)) { StopSlide(); } // Stop sliding if we hit a wall or for some reason we're no longer on the ground if (isSliding && !canSlide) { StopSlide(); } if (isSliding && !IsGrounded()) { StopSlide(); } }