コード例 #1
0
        // TODO: this function seems WEIRD!
        private float ActualCost(RoomGroup pStart, RoomGroup pGoal)
        {
            if (pStart.Equals(pGoal))
            {
                return(50f);
            }

            return(100.0f);

            /*Dictionary<RoomGroup, float> innerCache;
             *
             * if (_costCache.TryGetValue (pStart, out innerCache)) {
             *      float cachedCost;
             *      if (innerCache.TryGetValue (pGoal, out cachedCost)) {
             *              return cachedCost;
             *      }
             * }
             *
             * float cost = pStart.room == pGoal.room ? 0.1f : 1.0f;
             *
             * if (innerCache == null) {
             *      innerCache = new Dictionary<RoomGroup, float> ();
             *      _costCache.Add (pStart, innerCache);
             * }
             *
             * innerCache [pGoal] = cost;
             *
             * return cost;*/
        }
コード例 #2
0
        private float CostEstimate(RoomGroup pStart, RoomGroup pGoal)
        {
            if (pStart.Equals(pGoal))
            {
                return(1f);
            }
            int   dx       = pStart.room.worldPosition.x - pGoal.room.worldPosition.x;
            int   dy       = pStart.room.worldPosition.y - pGoal.room.worldPosition.y;
            float estimate = Math.Abs(dx) + Math.Abs(dy);

#if LOG
            D.Log("Estimate: " + estimate);
#endif
            return(estimate);
        }