コード例 #1
0
 //copied and modified from "TransitionPoint.cs"
 public static GlobalEnums.GatePosition GetGatePosition(string name)
 {
     if (name.Contains("top"))
     {
         return(GlobalEnums.GatePosition.top);
     }
     if (name.Contains("right"))
     {
         return(GlobalEnums.GatePosition.right);
     }
     if (name.Contains("left"))
     {
         return(GlobalEnums.GatePosition.left);
     }
     if (name.Contains("bot"))
     {
         return(GlobalEnums.GatePosition.bottom);
     }
     if (name.Contains("door"))
     {
         return(GlobalEnums.GatePosition.door);
     }
     Dev.LogError("Gate name " + name + "does not conform to a valid gate position type. Make sure gate name has the form 'left1'");
     return(GlobalEnums.GatePosition.unknown);
 }
コード例 #2
0
        /// <summary>
        /// Iterate through all the scenes in the game in a breadth-first search style. For each scene, the provided onVisit method will be called.
        /// ------
        /// onVisit is a callback that takes:
        /// MapNode current (node being visited)
        /// MapNode previous (node last visited)
        /// Dictionary<string, MapNode> visited (set of visited nodes)
        /// Dictionary<string, MapNode> map (the entire map)
        /// </summary>
        /// <returns></returns>
        public IEnumerator DoLoad(string startScene, Func <MapNode, MapNode, Dictionary <string, MapNode>, Dictionary <string, MapNode>, IEnumerator> onVisit)
        {
            if (map.Count <= 0)
            {
                //build the map
                BuildMap();
            }

            remaining = new Dictionary <string, MapNode>(map);

            if (!map.ContainsKey(startScene))
            {
                Dev.LogError("Scene " + startScene + " not found in game map!");
                yield break;
            }

            MapNode current = null;
            MapNode prev    = null;

            pending.Enqueue(map[startScene]);

            do
            {
                prev    = current;
                current = pending.Dequeue();
                yield return(onVisit(current, prev, visited, map));

                AddNeighborsToQueue(current);
                visited.Add(current.scene.SceneName, current);
            }while(pending.Count > 0);
        }
コード例 #3
0
ファイル: Physics2DSM.cs プロジェクト: natis1/ModCommon
        ///get the farther of the two collision points along the given rays. Null raycastMask defaults to the ground collision layer (8)
        static protected RaycastHit2D?GetRaycastWithMaxDistance(Vector2 origin, Vector2 directionA, Vector2 directionB, LayerMask?raycastMask = null)
        {
            RaycastHit2D testRaycastA = GetRaycastInDirection(origin, directionA, raycastMask);
            RaycastHit2D testRaycastB = GetRaycastInDirection(origin, directionB, raycastMask);

            if (testRaycastA.collider == null && testRaycastB.collider == null)
            {
                //error!
                Dev.LogError("Both raycasts returned null! Collision point was found in either direction! (Likely a bad layermask or origin point)");
                return(null);
            }
            else if (testRaycastA.collider == null)
            {
                return(testRaycastB);
            }
            else if (testRaycastB.collider == null)
            {
                return(testRaycastA);
            }

            if (testRaycastA.distance > testRaycastB.distance)
            {
                return(testRaycastA);
            }
            return(testRaycastB);
        }