public particulasB(int tam, float vel, Chaves cha, ParticulasSA psa) { nivelTamanho = tam; velocidade = vel; chaves = cha; particulasSA = psa; }
void criaFilhos(Chaves chaves, ParticulasSA particulasSA) { //x' = x cos θ − y sin θ //y' = x sin θ + y cos θ Vector2 directionForce = new Vector2(1, 0); GameObject[] listaIrmao = new GameObject[3]; int numIrmaos = 0; if (chaves.plasma == true) { GameObject newFilho = criaFilhoB("plasma", directionForce); listaIrmao[numIrmaos] = newFilho; directionForce = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2)); numIrmaos++; } if (chaves.gasoso == true) { GameObject newFilho = criaFilhoB("gasoso", directionForce); listaIrmao[numIrmaos] = newFilho; directionForce = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2)); numIrmaos++; } if (chaves.liquido == true) { GameObject newFilho = criaFilhoB("liquido", directionForce); listaIrmao[numIrmaos] = newFilho; directionForce = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2)); numIrmaos++; } if (chaves.solido == true) { GameObject newFilho = criaFilhoB("solido", directionForce); listaIrmao[numIrmaos] = newFilho; directionForce = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2)); numIrmaos++; } if (particulasSA.sonar == true) { GameObject newFilho = criaFilhoB("sonar", directionForce); listaIrmao[numIrmaos] = newFilho; directionForce = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2)); numIrmaos++; } if (particulasSA.magnetico == true) { GameObject newFilho = criaFilhoB("magnetico", directionForce); listaIrmao[numIrmaos] = newFilho; directionForce = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2)); numIrmaos++; } if (particulasSA.invisibildade == true) { GameObject newFilho = criaFilhoB("invisibildade", directionForce); listaIrmao[numIrmaos] = newFilho; directionForce = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2)); numIrmaos++; } if (particulasSA.camaraLenta == true) { GameObject newFilho = criaFilhoB("camaraLenta", directionForce); listaIrmao[numIrmaos] = newFilho; directionForce = new Vector2(directionForce.x * Mathf.Cos(Mathf.PI / 2) - directionForce.y * Mathf.Sin(Mathf.PI / 2), directionForce.x * Mathf.Sin(Mathf.PI / 2) + directionForce.y * Mathf.Cos(Mathf.PI / 2)); numIrmaos++; } for (int i = 0; i < numIrmaos; i++) { listaIrmao[i].GetComponent <particulasC>().numIrmaos = numIrmaos; listaIrmao[i].GetComponent <particulasC>().irmaos = listaIrmao; } }