private void NotifyMedKitSightLost(PickableMedKit medKit)
 {
     if (OnMedKitSightLost != null)
     {
         OnMedKitSightLost(medKit);
     }
 }
 private void NotifyMedKitSeen(PickableMedKit medKit)
 {
     if (OnMedKitSeen != null)
     {
         OnMedKitSeen(medKit);
     }
 }
Beispiel #3
0
        protected override void FindSomethingToDo()
        {
            //if i dont know where any medkit are
            if (targetMedKit == null)
            {
                //if i see a medkit make it my target
                if (HasMedKitInSight())
                {
                    targetMedKit = medKitSensor.MedKitInSight.First();
                    MoveAndRotateTowardPosition(targetMedKit.transform.position);
                }

                else if (HasTarget())
                {
                    Attack();
                }
                //if not move randomly until i find a medkit
                else
                {
                    if (HasReachedDestination())
                    {
                        FindNewRandomDestination();
                    }

                    MoveAndRotateTowardPosition(randomDestination);
                }
            }

            //Si le camper a vu un medkit.
            if (targetMedKit != null)
            {
                //Ramasse uniquement le medkit si ses points de vie sont trop bas.
                if (health.HealthPoints < health.MaxHealth * .5)
                {
                    MoveAndRotateTowardPosition(targetMedKit.transform.position);
                }
                // "Camp"
                else if (Vector2.Distance(mover.transform.position, targetMedKit.transform.position) >
                         CAMPING_AROUND_MEDKIT_RANGE)
                {
                    MoveAndRotateTowardPosition(targetMedKit.transform.position);
                }

                else if (HasTarget())
                {
                    Attack();
                }

                else
                {
                    mover.Rotate(1);
                }
            }
        }
Beispiel #4
0
        protected override void FindSomethingToDo()
        {
            //if i dont know where any medkit are
            if (targetMedKit == null)
            {
                //if i see a medkit make it my target
                if (HasMedKitInSight())
                {
                    targetMedKit = medKitSensor.MedKitInSight.First();
                    MoveAndRotateTowardPosition(targetMedKit.transform.position);
                }

                else if (HasTarget())
                {
                    Attack();
                }
                //if not move randomly until i find a medkit
                else
                {
                    if (HasReachedDestination())
                    {
                        FindNewRandomDestination();
                    }

                    MoveAndRotateTowardPosition(randomDestination);
                }
            }

            //if i have a target medkit
            if (targetMedKit != null)
            {
                //if haelth is under 50% go to medkit
                if (health.HealthPoints < health.MaxHealth * .5)
                {
                    MoveAndRotateTowardPosition(targetMedKit.transform.position);
                }
                //else stay close to medkit
                else if (Vector2.Distance(mover.transform.position, targetMedKit.transform.position) >
                         CAMPING_AROUND_MEDKIT_RANGE)
                {
                    MoveAndRotateTowardPosition(targetMedKit.transform.position);
                }
                //im im over medkit and see ennnemy i defend it
                else if (HasTarget())
                {
                    Attack();
                }
                //else i try to find other ennemy around medkit
                else
                {
                    mover.Rotate(1);
                }
            }
        }
Beispiel #5
0
 private void InitializeComponent()
 {
     medKit = transform.GetComponent <PickableMedKit>();
 }
        public void LooseSightOf(PickableMedKit weapon)
        {
            medKitsInSight.Remove(weapon);

            NotifyMedKitSightLost(weapon);
        }
        public void See(PickableMedKit medKit)
        {
            medKitsInSight.Add(medKit);

            NotifyMedKitSeen(medKit);
        }