Beispiel #1
0
        public void RenderGraph(GraphMatrix mat)
        {
            if (edgeRendererDict != null)
            {
                foreach (var pair in mat.edgeToPath)
                {
                    edgeRendererDict[pair.Key].property = RectPropertyFromPath(pair.Value);
                }

                return;
            }
            edgeRendererDict = new Dictionary <Edge, RectRenderer>();
            foreach (var pair in mat.edgeToPath)
            {
                // draw edge
                var edge = pair.Key;
                var path = pair.Value;

                var rectRend = ShapeGOFactory.InstantiateRect(RectPropertyFromPath(path));

                edgeRendererDict.Add(edge, rectRend);
            }
        }
Beispiel #2
0
        /*
         * public void Chase(
         *      Player player, GraphMatrix graph,
         *      float deltaTime, bool forceChase=false,
         *      bool playerInSafeZone=false) {
         *  // if active, keep chasing
         *  // if unactive, check if it needs to be active
         *  if (active) {
         *      if (playerInSafeZone) return;
         *      if (RestingAtVertex()) {
         *          destination = FindNextDestination(origin, player.position);
         *      }
         *      Move(graph, deltaTime);
         *  } else if (!playerInSafeZone && (NearPlayer(player, graph) || forceChase)) {
         *      active = true;
         *  }
         * }
         */

        bool NearPlayer(Player player, GraphMatrix graph)
        {
            return(Vector2.Distance(player.position, position) < DETECTION_DISTANCE);
        }