// Use this for initialization
    void Start()
    {
        steeringBasics  = GetComponent <SteeringBasics>();
        hide            = GetComponent <Hide>();
        obstacleSpawner = GameObject.Find("ObstacleSpawner").GetComponent <Spawner>();

        wallAvoid = GetComponent <WallAvoidance>();
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        path.calcDistances();

        steeringBasics = GetComponent <SteeringBasics>();
        wallAvoidance  = GetComponent <WallAvoidance>();
        followPath     = GetComponent <FollowPath>();
    }
Esempio n. 3
0
        /// <summary>
        /// Initializes the robot's fields.
        /// </summary>
        private void InitializeFields()
        {
//            TODO make singleton? Do I need X instances of this?
            WallAvoidance = new WallAvoidance(Robot);

            //Events
            Robot.SendScannedRobotEvent += UpdateEnemyData;
        }
Esempio n. 4
0
    private void OnSceneGUI()
    {
        Handles.color = Color.white;

        WallAvoidance agent = (WallAvoidance)target;

        Handles.DrawWireArc(agent.transform.position, agent.transform.forward, agent.transform.up, 360, agent.radius);
    }
Esempio n. 5
0
    // Use this for initialization
    void Start()
    {
        steeringBasics = GetComponent<SteeringBasics>();
        hide = GetComponent<Hide>();
        //obstacleSpawner = GameObject.Find("ObstacleSpawner").GetComponent<Spawner>();

        wallAvoid = GetComponent<WallAvoidance>();
    }
    // Use this for initialization
    void Start()
    {
        path.calcDistances();

        steeringBasics = GetComponent<SteeringBasics>();
        wallAvoidance = GetComponent<WallAvoidance>();
        followPath = GetComponent<FollowPath>();
    }
Esempio n. 7
0
File: Goblin.cs Progetto: 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);
        }
Esempio n. 8
0
        public MovingEntity(World world)
        {
            this.Mass        = 30;
            this.MaxSpeed    = .01f;
            this.MinSpeed    = 1.0f;
            this.Velocity    = new Vector2();
            this.Orientation = new Vector2(1, 0);

            this.wallAvoidance     = new WallAvoidance(this, world, 15f, 1.5f);
            this.obstacleAvoidance = new ObstacleAvoidance(this, world);
        }
Esempio n. 9
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        steeringBasics = GetComponent <SteeringBasics>();
        wallAvoidance  = GetComponent <WallAvoidance>();

        player = GameObject.Find("Player").transform;

        rb = GetComponent <Rigidbody>();

        Vector3 screenDiag = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, 10)) - Camera.main.ViewportToWorldPoint(new Vector3(0, 0, 10));

        awakeDist = 0.95f * Mathf.Max(screenDiag.x, screenDiag.z);
    }
Esempio n. 10
0
 /// <summary>
 /// Creates a new instance
 /// </summary>
 public Behaviors()
 {
     Alignment = new Alignment();
     Arrive = new Arrive();
     Cohesion = new Cohesion();
     Evade = new Evade();
     Flee = new Flee();
     Hide = new Hide();
     Interpose = new Interpose();
     ObstacleAvoidance = new ObstacleAvoidance();
     OffsetPursuit = new OffsetPursuit();
     PathFollowing = new PathFollowing();
     Pursuit = new Pursuit();
     Seek = new Seek();
     Separation = new Separation();
     WallAvoidance = new WallAvoidance();
     Wander = new Wander();
 }
Esempio n. 11
0
 /// <summary>
 /// Creates a new instance
 /// </summary>
 public Behaviors()
 {
     Alignment         = new Alignment();
     Arrive            = new Arrive();
     Cohesion          = new Cohesion();
     Evade             = new Evade();
     Flee              = new Flee();
     Hide              = new Hide();
     Interpose         = new Interpose();
     ObstacleAvoidance = new ObstacleAvoidance();
     OffsetPursuit     = new OffsetPursuit();
     PathFollowing     = new PathFollowing();
     Pursuit           = new Pursuit();
     Seek              = new Seek();
     Separation        = new Separation();
     WallAvoidance     = new WallAvoidance();
     Wander            = new Wander();
 }
Esempio n. 12
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);
        }
Esempio n. 13
0
    protected void ApplyActuator()
    {// Aqui el Actuator suma los steerings, los aplica a las velocidades, y las limita, teniendo en cuenta los costes
        NodeT node  = Map.NodeFromPosition(position).type;
        float tCost = GetTerrainCost(position);

        Steering steering = ApplySteering();

        if (velocity.magnitude > 0.1f)
        {
            steering += Face.GetSteering(position + velocity, this, interiorAngle, exteriorAngle, 0.1f, false); // Mover a ApplySteering
            steering += WallAvoidance.GetSteering(this, 10000f, Map.terrainMask, 0.7f, 0.7f, 0.5f, false);
            steering += AvoidUnits.GetSteering(this, 1000f, false);
        }

        velocity  += steering.linear * Time.deltaTime / tCost;
        rotation  += steering.angular * Time.deltaTime / tCost;
        velocity.y = 0;

        velocity = Vector3.ClampMagnitude(velocity, (float)MaxVelocity / tCost);
        rotation = Mathf.Clamp(rotation, -MaxRotation, MaxRotation);
    }
Esempio n. 14
0
    void Awake()
    {
        InitUnit();

        wallAvoid = this.GetComponent <WallAvoidance>();
    }