void Start()
 {
     scrpt = transform.parent.GetComponent<DeliberativeFireFighter>();
     lineRenderer.material = mat;
     lineRenderer.SetColors(c1, c2);
     lineRenderer.useWorldSpace = true;
     lineRenderer.SetWidth(0.13F, 0.13F);
     lineRenderer.SetVertexCount(lengthOfLineRenderer);
 }
Exemplo n.º 2
0
 void mergeDiscoveredLists(DeliberativeFireFighter me, DeliberativeFireFighter other)
 {
     foreach(Vector3 v in me.discoveredNodes)
     {
         if(!other.discoveredNodes.Contains(v))
         {
             other.discoveredNodes.Add(v);
         }
     }
 }
    public void Start()
    {
        //Get a reference to the Seeker component we added earlier
        seeker = GetComponent<Seeker>();
        //OnPathComplete will be called every time a path is returned to this seeker
        seeker.pathCallback += OnPathComplete;
        //Generating random position
        genCompRandomPos();
        //Starting path from transform.position to targetPosition
        seeker.StartPath(transform.position, targetPosition);

        hub = GameObject.FindWithTag("Hub").GetComponent<Hub>();
        gameSpeed = hub.gameSpeed;
        agent = GetComponent<DeliberativeFireFighter>();
    }
Exemplo n.º 4
0
 void checkFireRefill(DeliberativeFireFighter newParticipant)
 {
     //DO WE NEED WATER?
     if (needtoGetWater(newParticipant.currentWater))
     {
         fireParticipants.Add(newParticipant);
         //GRAB ONE AND ORDER HIM TO GET WATER
         DeliberativeFireFighter scrpt = sendFigtherWithLessWaterToGetWater();
         if (scrpt == null)
         {
             if (fire != null)
             {
                 if(needHelp() && sentHelp < 1)
                 {
                     redistributeWater(newParticipant);
                     if(newParticipant.currentWater < 0.1 * newParticipant.MaxWater)
                     {
                         newParticipant.goGetWater();
                     }
                     else
                     {
                         sentHelp++;
                         newParticipant.setState(STATE.RECRUIT_A_HELPER, transform.position);
                     }
                 }
                 else
                 {
                     redistributeWater(newParticipant);
                     if (newParticipant.currentWater < 0.1 * newParticipant.MaxWater)
                         newParticipant.goGetWater();
                     else newParticipant.helpWithFire(fire);
                 }
             }
             return;
         }
         else if (scrpt.helping != newParticipant.helping)
         {
             newParticipant.helpWithFire(fire);
             return;
         }
         fireParticipants.Remove(scrpt);
         scrpt.goGetWater();
     }
     else
     {
         if (needHelp())
         {
             fireParticipants.Add(newParticipant);
             newParticipant.helpWithFire(fire);
         }
     }
 }
Exemplo n.º 5
0
    /***************************************************************/

    void redistributeWater(DeliberativeFireFighter figther)
    {
        int valueToFill = (MaxWater - currentWater);
        if(valueToFill >= figther.currentWater)
        {
            currentWater += figther.currentWater;
            figther.currentWater -= figther.currentWater;
        }
        else if(valueToFill < figther.currentWater)
        {
            currentWater += valueToFill;
            figther.currentWater-= valueToFill;
        }
        foreach(DeliberativeFireFighter scrpt in fireParticipants)
        {
            valueToFill = scrpt.MaxWater - scrpt.currentWater;
            if(valueToFill >= figther.currentWater)
            {
                scrpt.currentWater += figther.currentWater;
                figther.currentWater -= figther.currentWater;
            }
            else if(valueToFill < figther.currentWater)
            {
                scrpt.currentWater += valueToFill;
                figther.currentWater-= valueToFill;
            }
        }
    }