Exemple #1
0
        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);
        }
Exemple #2
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);
        }
 void Start()
 {
     arrivalComponent = transform.GetComponent<ArrivalBehaviour>();
     //arrivalComponent.stoppingRadius = attackRadius-5;
 }