protected override State EvaluateAttacking()
        {
            UpdateCampedMedicalKit();

            if (isCamping)
            {
                if (CurrentEnemyTarget == null)
                {
                    return(State.Idle);
                }

                if (Vector3.Distance(NpcSensorSight.GetClosestNpc().transform.root.position, campedMedKit.transform.root.position) - 3
                    <
                    Vector3.Distance(Mover.transform.root.position, campedMedKit.transform.root.position) ||
                    Health.HealthPoints < HealthRetreatTolerance)
                {
                    return(State.Engaging);
                }

                return(State.Attacking);
            }

            if (!NpcSensorSight.NpcsInSight.Any())
            {
                return(State.Idle);
            }

            if (Health.HealthPoints < HealthRetreatTolerance)
            {
                return(State.Retreating);
            }

            return(DistanceToCurrentEnemy < DistanceSwitchFromEngagingToAttacking ? State.Attacking : State.Engaging);
        }
Exemplo n.º 2
0
 public OpStrategy(Mover mover, HandController handController, Health health,
                   NpcSensorSight npcSensorSight, NpcSensorSound npcSensorSound) : base(mover, handController,
                                                                                        health, npcSensorSight, npcSensorSound)
 {
     HealthRetreatTolerance    = 400;
     retreatingMovementRoutine = new RetreatWhileDodgingMovementRoutine(Mover);
     engagingMovementRoutine   = new AdvanceWhileDodgingMovementRoutine(Mover);
     noEnemySightRoutine       = new LookAroundSightRoutine(Mover);
 }
 public CowboyBehavior(Mover mover, HandController handController, Health health,
                       NpcSensorSight npcSensorSight, NpcSensorSound npcSensorSound)
     : base(mover, handController, health, npcSensorSight, npcSensorSound)
 {
     HealthRetreatTolerance = 0;
     noEnemySightRoutine    = new LookAroundSightRoutine(Mover);
     DistanceSwitchFromAttackingToEngaging = 6f;
     DistanceSwitchFromEngagingToAttacking = 5f;
 }
 public CamperBehavior(Mover mover, HandController handController, Health health,
                       NpcSensorSight npcSensorSight, NpcSensorSound npcSensorSound) : base(mover, handController,
                                                                                            health, npcSensorSight, npcSensorSound)
 {
     HealthRetreatTolerance    = 600;
     retreatingMovementRoutine = new RetreatWhileDodgingMovementRoutine(Mover);
     noEnemySightRoutine       = new LookAroundSightRoutine(Mover);
     isCamping = false;
 }
Exemplo n.º 5
0
		public CarefulBehavior(Mover mover, HandController handController, Health health,
			NpcSensorSight npcSensorSight, NpcSensorSound npcSensorSound) : base(mover, handController,
			health, npcSensorSight, npcSensorSound)
		{
			noEnemySightRoutine = new LookAroundSightRoutine(Mover);

			HealthRetreatTolerance = 800;
			DistanceSwitchFromAttackingToEngaging = 20f;
			DistanceSwitchFromEngagingToAttacking = 19f;
		}
Exemplo n.º 6
0
        protected override void DoRetreating()
        {
            if (!IsOutsideOfZone)
            {
                retreatingMovementRoutine.UpdateMovementRoutine(NpcSensorSight.GetClosestNpc().transform.root.position);
            }

            Mover.RotateTowardsDirection(GetPredictiveAimDirection(CurrentEnemyTarget));

            HandController.Use();
        }
 protected BaseNpcBehavior(Mover mover, HandController handController
                           , Health health, NpcSensorSight npcSensorSight, NpcSensorSound npcSensorSound)
 {
     currentState      = State.Idle;
     Mover             = mover;
     HandController    = handController;
     Health            = health;
     NpcSensorSight    = npcSensorSight;
     MovementDirection = new Vector3();
     NpcSensorSound    = npcSensorSound;
 }
Exemplo n.º 8
0
        protected override void DoAttacking()
        {
            if (CurrentEnemyTarget == null)
            {
                CurrentEnemyTarget = NpcSensorSight.GetClosestNpc();
            }

            Mover.RotateTowardsDirection(GetPredictiveAimDirection(CurrentEnemyTarget));

            HandController.Use();
        }
Exemplo n.º 9
0
        protected override void DoEngaging()
        {
            if (CurrentEnemyTarget == null)
            {
                CurrentEnemyTarget = NpcSensorSight.GetClosestNpc();
            }

            Mover.RotateTowardsDirection(GetPredictiveAimDirection(CurrentEnemyTarget));
            Mover.MoveTowardsPosition(CurrentEnemyTarget.transform.root.position);

            HandController.Use();
        }
Exemplo n.º 10
0
        private void InitializeComponent()
        {
            health    = GetComponent <Health>();
            mover     = GetComponent <Mover>();
            destroyer = GetComponent <RootDestroyer>();

            var rootTransform = transform.root;

            npcSensorSight = rootTransform.GetComponentInChildren <NpcSensorSight>();
            npcSensorSound = rootTransform.GetComponentInChildren <NpcSensorSound>();
            hitSensor      = rootTransform.GetComponentInChildren <HitSensor>();
            handController = hand.GetComponent <HandController>();

            npcDeathEventChannel = GameObject.FindWithTag(Tags.GameController).GetComponent <NpcDeathEventChannel>();
            hitEventChannel      = GameObject.FindWithTag(Tags.GameController).GetComponent <HitEventChannel>();
        }