public void ResortExps() { int[] newSorted = new int[numToSort]; expSpots = new Vector2[numToSort]; float minDist, tempDist; int counter = 0, minIndex; foreach (Vector2 spot in GroupValues.ExpSpots[numToSort]) { minDist = Mathf.Infinity; minIndex = -1; for (int i = 0; i < numToSort; i++) { if (sortedExps[i] < 0) { continue; } if ((tempDist = Vector3.Distance(soc.GetExpWithId(sortedExps[i]).transform.position, (Vector3)spot)) < minDist) { minIndex = i; minDist = tempDist; } } expSpots [counter] = spot; newSorted [counter++] = sortedExps [minIndex]; sortedExps [minIndex] = -1; } sortedExps = newSorted; }
public bool CanTrigger() { if (!repeatable && triggered) { return(false); } if (onNumExps && numExpsInSociety != society.GetNumOfExps()) { return(false); } if (exp != null) { if (!EqualIfNotNull(expState, exp.GetState(), checkExp)) { return(false); } //if (!EqualIfNotNull (expAnimState, ... } if (!EqualIfNotNull(socState, society.GetState(), checkSoc)) { return(false); } print(onAttack + " " + (!society.ExpsAreAttackingEachOther())); if (onAttack && !society.ExpsAreAttackingEachOther()) { return(false); } if (onFactoryExp && onFilledGenes && !society.GetExpWithId(-1).dna.HasFilledGenes()) { return(false); } if (onSameGenes && !society.GetExpWithId(-1).dna.SameTypeOfExp(expGeneMap)) { return(false); } if (onSocietyCompletion && !society.GetState().Equals(Society.SocState.Finished)) { return(false); } triggered = true; return(true); }