예제 #1
0
    private Vector3 GetEvadeDirection(TestingSteering PlayerSteering, TestingSteering EvadeSteering)
    {
        Vector3 distance       = EvadeSteering.CurrentPosition - PlayerSteering.CurrentPosition;
        float   futureTime     = distance.magnitude / PlayerSteering.MoveMaxSpeed;
        Vector3 futurePosition = EvadeSteering.CurrentPosition + EvadeSteering.CurrentVelocity * futureTime;

        return(FleeBehaviour.GetDirectionVector(PlayerSteering.CurrentPosition, futurePosition));
    }
예제 #2
0
파일: Goblin.cs 프로젝트: Foxion7/AI
        public Goblin(string name, Vector2D pos, World w, MovingEntity Target) : base(name, pos, w)
        {
            // State.
            hunting    = new Hunting(this);
            retreating = new Retreating(this);
            guarding   = new Guarding(this);
            wandering  = new Wandering(this);
            regroup    = new Regroup(this);
            obey       = new Obeying(this);
            equip      = new Equip(this);
            setState(guarding); // Starting state.

            FollowingOrder = false;

            Key = _lastKey + 1;
            _lastKey++;
            debugText       = new List <string>();
            this.Target     = Target;
            Mass            = 50;
            MaxSpeed        = 5;
            MaxForce        = 25;
            DamagePerAttack = 10;
            AttackRange     = 10;
            AttackSpeed     = 15; // Lower is faster.

            GroupValue     = 10;
            NeighborsRange = 100;

            SeparationValue = 8;
            CohesionValue   = 1;
            AlignmentValue  = 16;

            FollowValue = 20;

            _SB     = new ArrivalBehaviour(me: this, target: Target, slowingRadius: SlowingRadius);
            _FleeB  = new FleeBehaviour(me: this, target: Target, panicDistance: PanicDistance);
            _FlockB = new FlockBehaviour(me: this, groupValue: GroupValue, cohesionValue: CohesionValue, alignmentValue: AlignmentValue, separationValue: SeparationValue);
            _LFB    = new LeaderFollowingBehaviour(me: this, leader: Leader, slowingRadius: SlowingRadius, leaderBehindDist: 30, groupValue: GroupValue, followValue: FollowValue, separationValue: SeparationValue);
            _OA     = new ObstacleAvoidance(this);
            _WA     = new WallAvoidance(this);
            _WB     = new WanderBehaviour(this, 100, 200);

            Velocity        = new Vector2D(0, 0);
            SlowingRadius   = 100;
            PanicDistance   = 200;  // Distance at which goblin starts fleeing.
            PassiveDistance = 1000; // Distance at which goblin goes to guard.
            BraveryDistance = 100;
            WanderRadius    = 10;
            WanderDistance  = 1;
            Scale           = 4;
            VColor          = Color.Black;

            AddDebugText("Current state: " + currentState, 0);
            AddDebugText("Previous state: " + previousState, 1);
        }
예제 #3
0
        public override TaskState Run()
        {
            SeekBehaviour seekBe = myAgent.GetComponent <SeekBehaviour>();
            FleeBehaviour fleeBe = myAgent.GetComponent <FleeBehaviour>();

            myAgent.maximumLinearVelocity = 1;

            Transform baseTransform = FindObjectOfType <Base>().transform;

            seekBe.weight = 0;
            fleeBe.weight = 1;

            fleeBe.targetTransform = baseTransform;

            return(TaskState.SUCCESS);
        }
예제 #4
0
    public override void SetUpEntityComponent(GameEntity entity)
    {
        base.SetUpEntityComponent(entity);

        SetUpCombatActionsAnimationHashes();

        myTransform = entity.myTransform;

        //Time.timeScale = 0.25f; //if we with for slow mo
        ChangeStance(1);

        nextBehaviourChangeCheckeTime = Time.time + Random.Range(0, behaviourChangeCheckInterval);
        nextBehaviourUpdateTime       = Time.time + Random.Range(0, behaviourUpdateInterval);

        //construct the bahaviours, assign the starting behaviour
        fleeBehaviour        = new FleeBehaviour(entity, myTransform);
        meleeAttackBehaviour = new MeleeAttackBehaviour(entity, myTransform);
        currentBehaviour     = meleeAttackBehaviour;
    }
예제 #5
0
        public Hobgoblin(string name, Vector2D pos, World w, MovingEntity Target) : base(name, pos, w)
        {
            // State.
            hunting    = new Hunting(this);
            retreating = new Retreating(this);
            guarding   = new Guarding(this);
            wandering  = new Wandering(this);
            command    = new Command(this);
            equip      = new Equip(this);
            setState(guarding); // Starting state.
            Key = _lastKey + 1;
            _lastKey++;
            debugText = new List <string>();

            Mass     = 100;
            MaxSpeed = 5;
            MaxForce = 40;

            DamagePerAttack = 25;
            AttackRange     = 20;
            AttackSpeed     = 30;  // Lower is faster.
            CurrentCommand  = 3;   // Default command.
            CommandRadius   = 125; // Size of area where goblins will respond to commanding.

            SlowingRadius   = 100;
            PanicDistance   = 200; // Distance at which hobgoblin starts fleeing.
            PassiveDistance = 250; // Distance at which hobgoblin goes to guard.

            _SB    = new ArrivalBehaviour(me: this, target: Target, slowingRadius: SlowingRadius);
            _FleeB = new FleeBehaviour(me: this, target: Target, panicDistance: PanicDistance);
            _OA    = new ObstacleAvoidance(this);
            _WA    = new WallAvoidance(this);
            _WB    = new WanderBehaviour(this, 100, 200);

            Velocity      = new Vector2D(0, 0);
            SlowingRadius = 100;
            Scale         = 10;
            VColor        = Color.Black;

            AddDebugText("Current state: " + currentState, 0);
            AddDebugText("Previous state: " + previousState, 1);
        }
예제 #6
0
파일: ShootEnemy.cs 프로젝트: Grog84/AITest
        public override TaskState Run()
        {
            SeekBehaviour seekBe = m_Agent.GetComponent <SeekBehaviour>();
            FleeBehaviour fleeBe = m_Agent.GetComponent <FleeBehaviour>();

            m_Agent.maximumLinearVelocity = 0f;

            var allAgents = FindObjectsOfType <Agent>();

            if (btdm.currentEnemy != null)
            {
                seekBe.weight          = 1;
                fleeBe.weight          = 0;
                seekBe.targetTransform = btdm.currentEnemy.transform;
                m_Agent.GetComponent <ShootAction>().Shoot();
                return(TaskState.SUCCESS);
            }

            return(TaskState.FAILURE);
        }
예제 #7
0
파일: GoToHealth.cs 프로젝트: Grog84/AITest
        public override TaskState Run()
        {
            SeekBehaviour seekBe = m_Agent.GetComponent <SeekBehaviour>();
            FleeBehaviour fleeBe = m_Agent.GetComponent <FleeBehaviour>();

            m_Agent.maximumLinearVelocity = 1f;

            var pickups = FindObjectsOfType <HealthPickup>();

            foreach (var pickup in pickups)
            {
                if (pickup.isEnabled)
                {
                    seekBe.weight          = 1;
                    fleeBe.weight          = 0;
                    seekBe.targetTransform = pickup.transform;
                    return(TaskState.SUCCESS);
                }
            }

            return(TaskState.FAILURE);
        }
예제 #8
0
 public EvadeBehaviour( SteeringManager manager )
     : base(manager)
 {
     this.tag = "Evade";
     flee = new FleeBehaviour (manager);
 }
 /// <summary>
 /// Constructor for flee behaviour.
 /// </summary>
 /// <param name="behaviour">
 /// Details for this behaviour.
 /// </param>
 /// <param name="parentBehaviour">
 /// Reference to component to decorate.
 /// </param>
 public FleeBehaviourDecorator(AbstractBehaviourComponent parentBehaviour, MovementBehaviour behaviour)
     : base(parentBehaviour, behaviour)
 {
     this.behaviour = behaviour as FleeBehaviour;
 }
예제 #10
0
 public EvadeBehaviour(SteeringManager manager) : base(manager)
 {
     this.tag = "Evade";
     flee     = new FleeBehaviour(manager);
 }
 public TankCreateDistanceBetweenPlayer()
 {
     flee = new FleeBehaviour();
 }
 public void FleeOff()
 {
     _flee  = null;
     _dFlee = 0;
 }
 public void FleeOn(BaseGameEntity enemy, double intensity)
 {
     _flee  = new FleeBehaviour(_movingEntity, enemy);
     _dFlee = intensity;
 }