コード例 #1
0
ファイル: TestingSteering.cs プロジェクト: bjck/AMFU
    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
ファイル: Flee.cs プロジェクト: CabbageWarrior/AIExamples
        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);
 }
コード例 #9
0
 /// <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();
 }
コード例 #12
0
 public void FleeOff()
 {
     _flee  = null;
     _dFlee = 0;
 }
コード例 #13
0
 public void FleeOn(BaseGameEntity enemy, double intensity)
 {
     _flee  = new FleeBehaviour(_movingEntity, enemy);
     _dFlee = intensity;
 }