public static string GetInverseColor(CelestialAlignment a) { if(a == CelestialAlignment.HEAVEN) return "red"; else return "blue"; }
void GameOver(CelestialAlignment winner) { Debug.LogError("GameOver, gano: " + winner.ToString()); // FIXME poner en game manager o ver que onda Application.LoadLevel(0); }
void Spwan(CelestialAlignment alignment, Soul soul) { // Ya hay en el escenario el maximo permitido? if(powerUpsOnScreen.Count >= maxPowerUpsOnScreen) return; // De que pool voy a sacar powerUps PowerUpsPool[] pool = pooledHeavenPowerUps; int alignmentCorrection = 1; if(alignment == CelestialAlignment.HELL){ pool = pooledHellPowerUps; alignmentCorrection = -1; } // Que powerUp lanzar int powerUpTypeIndex = -1; for(int i=0; i<pool.Length;++i){ float randomNum = Random.value; if(pool[i].hasAvailableInstances && randomNum <= pool[i].spawnChances){ powerUpTypeIndex = i; posibleTypesIndices.Add(i); } } if(posibleTypesIndices.Count != 0){ powerUpTypeIndex = posibleTypesIndices[Mathf.FloorToInt(Random.Range(0f, posibleTypesIndices.Count -1))]; posibleTypesIndices.Clear(); } if(powerUpTypeIndex == -1) return; // Donde lanzarlo float xPos, yPos; // Horizontalmente xPos = HorizontalPos(soul); // Verticalmente bool tryOtherPos = true; // me sirve una posicion tal, o tengo que revisar a ver si pisa algo? yPos = -soul.normalizedSoulValue + (0.2f * alignmentCorrection); yPos = (yPos > 0) ? Random.Range(0, yPos) : Random.Range(yPos, 0); yPos *= Game.soul.screenHeight; if(powerUpsOnScreen.Count == 0){ tryOtherPos = false; // no hay nada mas en el escenario, me sirve cualquiera Debug.Log("<color=green>Primero</color>"); } int loops = 0; while(loops <= 5 && tryOtherPos){ for(int i = 0; i<powerUpsOnScreen.Count;++i){ if(Lanes.AlmostEquals(yPos, powerUpsOnScreen[i].transform.position.y, minDistBetweenPowerUps) && Lanes.PosToLane(xPos) == Lanes.PosToLane(powerUpsOnScreen[i].transform.position.x)){ tryOtherPos = true; Debug.Log("<color=blue>Hay algo cerca!</color>"); break; }else tryOtherPos = false; } if(tryOtherPos){ yPos = -soul.normalizedSoulValue + (0.2f * alignmentCorrection); yPos = (yPos > 0) ? Random.Range(0, yPos) : Random.Range(yPos, 0); yPos *= Game.soul.screenHeight; yPos += (0.25f*loops*alignmentCorrection); }else{ Debug.Log("<color=green>Found one!</color>"); } ++loops; } if(tryOtherPos) xPos = HorizontalPos(soul, xPos); Vector3 powerUpPosition = new Vector3(xPos, yPos, 0f); PowerUp p = pool[powerUpTypeIndex].GetInstance(); p.InitializeAt(powerUpPosition); powerUpsOnScreen.Add(p); Debug.Log("<color=white>Spawn</color>"); }
void EvaluateWinCondition(int playerIndex, CelestialAlignment celestialAlignment) { if(Mathf.Abs(transform.position.x - players[playerIndex].stats.transform.position.x) < 0.5f){ GameOver(celestialAlignment); }else{ // FIXME cambiar por algo no hardcodeado que dependa del height de soul float correction = (celestialAlignment == CelestialAlignment.HEAVEN) ? -0.6f : 0.6f; // transform.position = new Vector3(transform.position.x, bottomLeftCoords.y + correction, transform.position.z); // rigidBody.velocity = Vector2.zero; Debug.LogError("<color=purple>SE FUE A LA MIERDA</color>"); } }