当前位置: 首页>>代码示例>>C#>>正文


C# Transform.Intersect方法代码示例

本文整理汇总了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;
    }
开发者ID:hugobozzshih007,项目名称:BattleCard,代码行数:43,代码来源:Decisions.cs

示例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;
    }
开发者ID:hugobozzshih007,项目名称:BattleCard,代码行数:46,代码来源:Decisions.cs


注:本文中的Transform.Intersect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。