//寻找配偶 public CellBug SearchMate(CellBug cellBug) { Const.CellBugGroup group = cellBug.GetAbility().GetGroup(); ArrayList mateBugList = new ArrayList(); for (int i = 0; i < cellBugAllList.Count; i++) { CellBug tempBug = cellBugAllList[i] as CellBug; if (tempBug && tempBug.GetAbility().GetStatus() != Const.StutasEnum.SearchMateEnum && tempBug.GetAbility().GetGroup() == group && tempBug != cellBug) { mateBugList.Add(tempBug); } } if (mateBugList.Count != 0) { CellBug mate = mateBugList[0] as CellBug; for (int m = 1; m < mateBugList.Count; m++) { CellBug tempMate = mateBugList[m] as CellBug; if (Vector3.Magnitude(cellBug.transform.position - tempMate.transform.position) < Vector3.Magnitude(cellBug.transform.position - mate.transform.position)) { mate = tempMate; } } return(mate); } return(null); }
private void GroupNumChangeVision(bool isResult = false, Const.CellBugGroup group = Const.CellBugGroup.GodChildEnum) { int numGodChild = 0; int numOrc = 0; int numHuman = 0; int numEidolon = 0; for (int i = 0; i < cellBugAllList.Count; i++) { CellBug bug = cellBugAllList[i] as CellBug; if (bug.GetAbility().GetGroup() == group) { numGodChild++; } if (bug.GetAbility().GetGroup() == Const.CellBugGroup.OrcEnum) { numOrc++; } if (bug.GetAbility().GetGroup() == Const.CellBugGroup.HumanEnum) { numHuman++; } if (bug.GetAbility().GetGroup() == Const.CellBugGroup.EidolonEnum) { numEidolon++; } } groupNum.text = "GodChild number:" + numGodChild; otherGroupLabelArray[0].text = "Orc number:" + numOrc; otherGroupLabelArray[1].text = "Human number:" + numHuman; otherGroupLabelArray[2].text = "Eidolon number:" + numEidolon; if (isResult) { if (numGodChild == 0) { GameResult(false); } if (numEidolon == 0 && numHuman == 0 && numOrc == 0 && numGodChild >= 1) { GameResult(true); } } }
public void SetGroup(Const.CellBugGroup group) { this.cellBugGroup = group; }