Exemplo n.º 1
0
    // Store information on whether each red unit is carrying a civilian or not
    void updateRedUnitDatabase()
    {
        // Clear
        redUnitDatabase.Clear();

        // Get all red units
        redUnits = new List <GameObject>();
        redUnits.AddRange(GameObject.FindGameObjectsWithTag("RedTruck"));
        redUnits.AddRange(GameObject.FindGameObjectsWithTag("RedDismount"));

        // Loop through all actor beliefs and update the database
        foreach (Belief_Actor b in actorBeliefs)
        {
            // We care only about red units
            Belief_Actor ba = (Belief_Actor)b;

            if (ba.getAffiliation().Equals((int)Affiliation.RED))
            {
                // Save the info if the belief is new enough
                // Note: Watch out for the difference of two unsigned numbers!
                if (thisSoaActor.getCurrentTime_ms() <= ba.getBeliefTime() ||
                    (float)(thisSoaActor.getCurrentTime_ms() - ba.getBeliefTime()) <= beliefTimeout_ms)
                {
                    RedUnitInfo redUnitInfo = new RedUnitInfo(ba, redUnits, redBases, protectedSites);
                    if (redUnitInfo.distToClosestRedBase > redBaseKeepoutDist * SimControl.KmToUnity)
                    {
                        redUnitDatabase.Add(ba.getId(), new RedUnitInfo(ba, redUnits, redBases, protectedSites));
                    }
                }
            }
        }
    }