Exemple #1
0
 // function to high light the current line segment that agent is following
 public void updateHighLightLineSeg()
 {
     // when this agent is just created
     if (this.highlightLine == null)
     {
         if (this.path.Count >= 2)
         {
             Vector3 end1 = ((Graph.Node)path[0]).getPosition();
             Vector3 end2 = ((Graph.Node)path[1]).getPosition();
             this.currentLineFollowed.Add(end1);
             this.currentLineFollowed.Add(end2);
             this.highlightLine = GameFlowManager.gameFlowManager.highLightPath(end1, end2);  // set the current highlight line gameobject
         }
         else
         {
             Vector3 end1 = this.agent.transform.position;
             Vector3 end2 = ((Graph.Node)path[0]).getPosition();
             this.currentLineFollowed.Add(end1);
             this.currentLineFollowed.Add(end2);
             this.highlightLine = GameFlowManager.gameFlowManager.highLightPath(end1, end2);  // set the current highlight line gameobject
         }
     }
     else
     {
         if (path.Count >= 1)
         {
             // if the current path has to be update
             if (((Graph.Node) this.path[0]).getPosition() != (Vector3)this.currentLineFollowed[1])
             {
                 Vector3 end = ((Graph.Node)path[0]).getPosition();
                 //Vector3 end2 = ((Graph.Node)path[1]).getPosition();
                 this.currentLineFollowed[0] = this.currentLineFollowed[1];
                 this.currentLineFollowed[1] = end;
                 GameFlowManager.Destroy(this.highlightLine);                                                                   // destroy the current highlight line
                 this.highlightLine = GameFlowManager.gameFlowManager.highLightPath((Vector3)this.currentLineFollowed[0], end); // set the new highlight line gameobject
             }
         }
     }
 }