本文整理汇总了C#中Transform.Intersect方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.Intersect方法的具体用法?C# Transform.Intersect怎么用?C# Transform.Intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform.Intersect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSummonPosition
public Transform GetSummonPosition(Transform chess)
{
CharacterProperty chessP = chess.GetComponent<CharacterProperty>();
Transform summonPos = null;
IList possiblePos = new List<Transform>();
foreach(Transform map in currentRC.PlayerBTerritory){
if(!MapHelper.IsMapOccupied(map))
possiblePos.Add(map);
}
Transform[] pPos = new Transform[possiblePos.Count];
possiblePos.CopyTo(pPos,0);
Transform currentPos = chess.GetComponent<CharacterSelect>().getMapPosition();
Transform[] closestPos = currentPos.GetComponent<Identy>().neighbor;
IEnumerable<Transform> bothPos = pPos.Intersect(closestPos);
IList interSect = new List<Transform>();
if(bothPos.ToArray().Length>0){
foreach(Transform map in bothPos){
if(!MapHelper.IsMapOccupied(map)){
interSect.Add(map);
}
}
if(interSect.Count>0){
int rnd = Random.Range(0,interSect.Count-1);
summonPos = interSect[rnd] as Transform;
}
if(summonPos==null){
IList pPosList = new List<Transform>();
foreach(Transform g in pPos){
pPosList.Add(g);
}
foreach(Transform map in bothPos){
pPosList.Remove(map);
}
summonPos = MapHelper.GetClosestMap(chess, pPosList);
}
}
return summonPos;
}
示例2: GetMoveTarget
public Transform GetMoveTarget(Transform chess)
{
IList mapList = new List<Transform>();
IList selfTerritory = new List<Transform>();
IList closeList = new List<Transform>();
Transform targetMap = null;
CharacterSelect chessSel = chess.GetComponent<CharacterSelect>();
currentSelect.updateMapSteps();
Transform currentPos = chessSel.getMapPosition();
chessSel.findMoveRange(currentPos,0,chess.GetComponent<CharacterProperty>().BuffMoveRange);
foreach(Transform map in chessSel.MoveRangeList){
if(!MapHelper.IsMapOccupied(map))
mapList.Add(map);
}
chessSel.MoveRangeList.Clear();
foreach(Transform map in currentRC.PlayerBTerritory){
if(!MapHelper.IsMapOccupied(map))
selfTerritory.Add(map);
}
Transform closestOne = Camera.main.GetComponent<MoveCharacter>().GetClosetChess(chess);
closeList = MapHelper.GetClosestMaps(closestOne, mapList);
//print("The Closest One: "+closestOne);
if(closeList.Count == 1){
targetMap = closeList[0] as Transform;
}else if(closeList.Count > 1){
Transform[] pPos = new Transform[selfTerritory.Count];
selfTerritory.CopyTo(pPos, 0);
Transform[] closestPos = new Transform[closeList.Count];
closeList.CopyTo(closestPos, 0);
IEnumerable<Transform> bothPos = pPos.Intersect(closestPos);
Transform[] bothArray = bothPos.ToArray();
if(bothArray.Length == 1){
targetMap = bothArray[0] as Transform;
}else if(bothArray.Length > 1){
int rnd = Random.Range(0, bothArray.Length-1);
targetMap = bothArray[rnd] as Transform;
}else if(bothArray.Length == 0){
int rnd = Random.Range(0, closeList.Count-1);
targetMap = closeList[rnd] as Transform;
}
}
return targetMap;
}