public static GameObject[] RemoveByType(GameObject[] allBlocks, CrossyBlockType type) { List <GameObject> listGO = allBlocks.ToList(); listGO.RemoveAll(go => go.GetComponent <CrossyBlock>().type == type); return(listGO.ToArray()); }
public void SpawnBlock(GameObject prefab) { GameObject spawned = GameObject.Instantiate(prefab, currentPosition, Quaternion.identity, this.transform); int size = spawned.GetComponent <CrossyBlock>().blockSize; //Actualizamos el lastType lastType = spawned.GetComponent <CrossyBlock>().type; currentPosition.z += blockSize * size; //agregar el tamaño del terreno al contador createdRowsCount += size; }
private void DetectGround() { Vector3 rayDirection = new Vector3(0, -1f, 0f); RaycastHit hit; //Detectar un collider con ground layermask if (Physics.Raycast(groundRayOrigin.position, rayDirection, out hit, groundRayDistance, groundLayermask)) { CrossyPlatform detectedPlatform = hit.collider.GetComponent <CrossyPlatform>(); if (detectedPlatform != null) { currentGroundType = detectedPlatform.type; if (detectedPlatform.tag == "MovingPlatform") { currentMovingPlatform = detectedPlatform.GetComponent <MovingObject>(); } return; } CrossyBlock detectedBlock = hit.collider.GetComponentInParent <CrossyBlock>(); if (detectedBlock != null) { currentGroundType = detectedBlock.type; if (currentGroundType == CrossyBlockType.Water) { IsDead = true; myAnimator.SetTrigger("Idle to DeathByDrowning"); } } } else { Debug.Log("No existe suelo para detectar"); } }