Beispiel #1
0
 // If the agent enter in the area spawn toxic
 public void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.name == "EnergyCoil(Clone)")
     {
         bool batteryHere = false;
         actualBattery = col.GetComponent <PickableEnergy>();
         if (actualBattery._hasPlayer == false)
         {
             foreach (int batteryPresence in listBatteryInArea)
             {
                 if (batteryPresence == actualBattery._idEnergy)
                 {
                     batteryHere = true;
                 }
             }
             if (batteryHere == false)
             {
                 listBatteryInArea.Add(actualBattery._idEnergy);
                 batteryHere = true;
             }
         }
     }
     if (col.gameObject.tag == "agent" && listBatteryInArea.Count > 0)
     {
         actualAgent = col.GetComponent <Agent>();
         if ((actualAgent._currentState == AgentStates.CarryingEnergyToPile || actualAgent._currentState == AgentStates.FindingEnergy) &&
             actualAgent._canTakeEnergy != 0)
         {
             actualBatteryOut = col.GetComponent <Agent>()._canTakeEnergy;
             listBatteryInArea.Remove(actualBatteryOut);
         }
     }
 }
Beispiel #2
0
 // Check if the battery is taked or not
 private void View(PickableEnergy battery)
 {
     if (_identifiant != 0 && battery._matriculAgent == _owner._code)
     {
         _energyPickable   = battery._hasPlayer;
         _ownerCombustible = battery._matriculAgent;
     }
 }
Beispiel #3
0
 // When the agent put energy in the pile
 public void PutEnergy()
 {
     Destroy(_currentObjet);
     _identifiant         = 0;
     _currentObjet        = null;
     _ownerCombustible    = 0;
     _position            = null;
     _battery             = null;
     _toxicFront          = false;
     _energyFront         = false;
     _energyPickable      = false;
     _owner._currentState = AgentStates.PutObject;
 }
Beispiel #4
0
    void OnTriggerEnter(Collider col)
    {
        // Allow to check the number of battery in the zone
        if (col.gameObject.name == "EastInformationBox")
        {
            _numberOfbattery[(int)Direction.EastPoint] = col.GetComponent <SpawnListener>().numberOfPile;
        }
        if (col.gameObject.name == "NorthInformationBox")
        {
            _numberOfbattery[(int)Direction.NorthPoint] = col.GetComponent <SpawnListener>().numberOfPile;
        }
        if (col.gameObject.name == "SouthInformationBox")
        {
            _numberOfbattery[(int)Direction.SouthPoint] = col.GetComponent <SpawnListener>().numberOfPile;
        }
        if (col.gameObject.name == "WestInformationBox")
        {
            _numberOfbattery[(int)Direction.WestPoint] = col.GetComponent <SpawnListener>().numberOfPile;
        }

        if (col.gameObject.name == "EnergyCoil(Clone)" && _owner._currentState == AgentStates.FindingEnergy && _owner._canTakeEnergy == 0)
        {
            // Look roughly the number of pile there are in the area if there are many or not( A VOIR PLUS TARD!!!)
            _battery = col.GetComponent <PickableEnergy>();

            // If the energy enter in the field of view
            if (_battery._hasPlayer == false)
            {
                _energyFront  = true;
                _currentObjet = col.gameObject;
                _position     = col.transform;
                _identifiant  = _battery._idEnergy;
            }
        }

        // If the toxic enter in the field of view
        if (col.gameObject.name == "Toxic(Clone)" && _owner._currentState == AgentStates.FindingAcid && _owner._canTakeEnergy == 0)
        {
            _battery = col.GetComponent <PickableEnergy>();
            if (_battery._hasPlayer == false)
            {
                _toxicFront   = true;
                _currentObjet = col.gameObject;
                _position     = col.transform;
                _identifiant  = _battery._idEnergy;
            }
        }

        // If the box Energy enter in the field of view
        if (col.gameObject.name == "EnergyBoxEnterAgent")
        {
            if (_currentObjet != null && _currentObjet.name == "EnergyCoil(Clone)")
            {
                PutEnergy();
            }
        }

        // If the box Waste enter in the field of view
        if (col.gameObject.name == "WasteBoxEnterAgent")
        {
            if (_currentObjet != null && _currentObjet.name == "Toxic(Clone)")
            {
                PutEnergy();
            }
        }

        // If the box informationBox enter in the field of view
        if (col.gameObject.name == "PileInformationBox")
        {
            _percentOfEnergy = col.GetComponent <InformationPiles>()._energyRate;
            _percentOfWaste  = col.GetComponent <InformationPiles>()._toxicRate;
            _pileFront       = true;
        }

        // If an agent enter in the field of view
        if (col.gameObject.tag == "agent")
        {
            _agentFront  = true;
            _agentMember = col.GetComponent <Agent>();
            if (_agentMember._code != _owner._code && _agentFront == true)
            {
                _agentMemberDialogue = _agentMember._currentDialogue;
                _agentMemberState    = _agentMember._currentState;
                _agentMemberTarget   = _agentMember._currentTarget;
            }
        }

        // Check if the Agent Friend is near enough to consider if he is front of him or not
        if (_agentMember != null)
        {
            if (Vector2.Distance(new Vector2(_agentMember.transform.position.x, _agentMember.transform.position.z), new Vector2(transform.position.x, transform.position.z)) > 2.2)
            {
                _agentFront = false;
            }
            if (Vector2.Distance(new Vector2(_agentMember.transform.position.x, _agentMember.transform.position.z), new Vector2(transform.position.x, transform.position.z)) <= 2.2)
            {
                _agentFront = true;
            }
        }
    }