Example #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("RedTruck"))
     {
         RedTruckSim r = other.gameObject.GetComponent <RedTruckSim>();
         if (r != null)
         {
             Debug.Log(transform.name + " intercepts " + other.name);
         }
     }
     if (other.CompareTag("RedDismount"))
     {
         RedDismountSim r = other.gameObject.GetComponent <RedDismountSim>();
         if (r != null)
         {
             Debug.Log(transform.name + " intercepts " + other.name);
         }
     }
     if (other.CompareTag("BlueBase"))
     {
         // Get an observation about the blue base
         BlueBaseSim b = other.gameObject.GetComponent <BlueBaseSim>();
         if (b != null)
         {
             thisSoaActor.RegisterSiteObservation(new soa.Belief_Base(
                                                      b.destination_id, b.gridCells, b.Supply));
         }
     }
     if (other.CompareTag("NGO"))
     {
         // Get an observation about the NGO
         NgoSim n = other.gameObject.GetComponent <NgoSim>();
         if (n != null)
         {
             thisSoaActor.RegisterSiteObservation(new soa.Belief_NGOSite(
                                                      n.destination_id, n.gridCells, n.Supply, n.Casualties, n.Civilians));
         }
     }
     if (other.CompareTag("Village"))
     {
         // Get an observation about the village
         VillageSim v = other.gameObject.GetComponent <VillageSim>();
         if (v != null)
         {
             thisSoaActor.RegisterSiteObservation(new soa.Belief_Village(
                                                      v.destination_id, v.gridCells, v.Supply, v.Casualties));
         }
     }
 }
Example #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("BlueBase"))
        {
            // Instant refuel
            thisSoaActor.fuelRemaining_s = fuelTankSize_s;

            // Get an observation about the blue base
            BlueBaseSim b = other.gameObject.GetComponent <BlueBaseSim>();
            if (b != null)
            {
                thisSoaActor.RegisterSiteObservation(new soa.Belief_Base(
                                                         b.destination_id, b.gridCells, b.Supply));
            }
        }
        if (other.CompareTag("NGO"))
        {
            // Get an observation about the NGO
            NgoSim n = other.gameObject.GetComponent <NgoSim>();
            if (n != null)
            {
                thisSoaActor.RegisterSiteObservation(new soa.Belief_NGOSite(
                                                         n.destination_id, n.gridCells, n.Supply, n.Casualties, n.Civilians));
            }
        }
        if (other.CompareTag("Village"))
        {
            // Get an observation about the village
            VillageSim v = other.gameObject.GetComponent <VillageSim>();
            if (v != null)
            {
                thisSoaActor.RegisterSiteObservation(new soa.Belief_Village(
                                                         v.destination_id, v.gridCells, v.Supply, v.Casualties));
            }
        }
    }
Example #3
0
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("BlueBase"))
        {
            // Instant refuel
            thisSoaActor.fuelRemaining_s = fuelTankSize_s;

            // Process casualties/supplies
            BlueBaseSim b = other.gameObject.GetComponent <BlueBaseSim>();
            if (b != null)
            {
                // Deliver specified # of casualties first
                int numCasualtiesToDeliver = RequestCasualtyDelivery((int)thisSoaActor.numCasualtiesStored);
                for (int i = 0; i < numCasualtiesToDeliver; i++)
                {
                    simControlScript.soaEventLogger.LogCasualtyDelivery(gameObject.name, other.name);
                }
                b.Casualties += numCasualtiesToDeliver;
                thisSoaActor.numCasualtiesStored = (uint)(thisSoaActor.numCasualtiesStored - numCasualtiesToDeliver);

                // Pick up specified # of supplies next
                int numSuppliesToPickup = RequestSupplyPickup((int)thisSoaActor.GetNumFreeSlots(), b.Supply);
                b.Supply -= numSuppliesToPickup;
                thisSoaActor.numSuppliesStored = (uint)(thisSoaActor.numSuppliesStored + numSuppliesToPickup);

                // Make a new observation about the site
                thisSoaActor.RegisterSiteObservation(new soa.Belief_Base(
                                                         b.destination_id, b.gridCells, b.Supply));
            }
        }

        if (other.CompareTag("NGO"))
        {
            NgoSim n = other.gameObject.GetComponent <NgoSim>();
            if (n != null)
            {
                // Deliver specified # of supplies first
                int numSuppliesToDeliver = RequestSupplyDelivery((int)thisSoaActor.numSuppliesStored, n.destination_id);
                for (int i = 0; i < numSuppliesToDeliver; i++)
                {
                    simControlScript.soaEventLogger.LogSupplyDelivered(gameObject.name, other.name);
                }
                n.Supply += numSuppliesToDeliver;
                thisSoaActor.numSuppliesStored = (uint)(thisSoaActor.numSuppliesStored - numSuppliesToDeliver);

                // Pickup specified # of casualties next
                int numCasualtiesToPickup = RequestCasualtyPickup((int)thisSoaActor.GetNumFreeSlots(), n.Casualties, n.destination_id);
                n.Casualties -= numCasualtiesToPickup;
                thisSoaActor.numCasualtiesStored = (uint)(thisSoaActor.numCasualtiesStored + numCasualtiesToPickup);

                // Make a new observation about the site
                thisSoaActor.RegisterSiteObservation(new soa.Belief_NGOSite(
                                                         n.destination_id, n.gridCells, n.Supply, n.Casualties, n.Civilians));
            }
        }

        if (other.CompareTag("Village"))
        {
            VillageSim v = other.gameObject.GetComponent <VillageSim>();
            if (v != null)
            {
                // Deliver specified # of supplies first
                int numSuppliesToDeliver = RequestSupplyDelivery((int)thisSoaActor.numSuppliesStored, v.destination_id);
                for (int i = 0; i < numSuppliesToDeliver; i++)
                {
                    simControlScript.soaEventLogger.LogSupplyDelivered(gameObject.name, other.name);
                }
                v.Supply += numSuppliesToDeliver;
                thisSoaActor.numSuppliesStored = (uint)(thisSoaActor.numSuppliesStored - numSuppliesToDeliver);

                // Pickup specified # of casualties next twupy1
                int numCasualtiesToPickup = RequestCasualtyPickup((int)thisSoaActor.GetNumFreeSlots(), v.Casualties, v.destination_id);
                v.Casualties -= numCasualtiesToPickup;
                thisSoaActor.numCasualtiesStored = (uint)(thisSoaActor.numCasualtiesStored + numCasualtiesToPickup);

                // Make a new observation about the site
                thisSoaActor.RegisterSiteObservation(new soa.Belief_Village(
                                                         v.destination_id, v.gridCells, v.Supply, v.Casualties));
            }
        }
    }