public void AddDoublet(GameObject acc) { if (acc.GetComponents <Doublet>().Length >= MaxDoublets) { return; // Already to many doublets, Stop adding } Doublet d = acc.AddComponent <Doublet>(); d.Atome = acc; d.DrawDoublet(); doublets.Add(d.doublet); UpdateArrow(acc); }
public void CorrectDoublet() { foreach (GameObject acc in GameObject.FindGameObjectsWithTag("Accepteur")) { Doublet[] dbs = acc.transform.GetComponents <Doublet>(); List <Doublet> doublets = new List <Doublet>(); //doublets.AddRange(dbs); foreach (Doublet d in dbs) { ElementManager el = d.doublet.GetComponent <ElementManager>(); if (el.inReaction == true) { Debug.Log("inreact"); doublets.Insert(0, d); } else { doublets.Add(d); } } int number = doublets.Count; int k = 0; if (IsElement(acc, Plus1)) { k = 1; } if (IsElement(acc, Plus2)) { k = 2; } if (IsElement(acc, Plus3)) { k = 3; } if (IsElement(acc, Plus4)) { k = 4; } for (int i = 0; i < k - number; i++) { Doublet d = acc.AddComponent <Doublet>(); d.Atome = acc; d.color = Color.red; d.DrawDoublet(); } for (int i = 0; i < number && i < k; i++) { doublets[i].SetGood(); } for (int i = k; i < number; i++) { doublets[i].SetWrong(); } transform.GetComponentInParent <GameControllerArrowDoublet>().UpdateArrow(acc); } }