Esempio n. 1
0
        public int DecisionQueueMaximum    = 8;                   //Maximum amount of steps I can think ahead in time to approach my goal

        public HenchmanMind(WaypointState wpState, AttackState atkState, Goal goal, Mood mood)
        {
            this.wpState  = wpState;
            this.atkState = atkState;
            this.goal     = goal;
            this.mood     = mood;
        }
Esempio n. 2
0
        public HenchmanMind(Goal goal, Mood mood)
        {
            this.wpState  = WaypointState.NONE;
            this.atkState = AttackState.NONE;

            this.goal = goal;
            this.mood = mood;
        }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        states = new List <State>();
        //Patroll state
        List <Transition> patrolltrans = new List <Transition>();

        patrolltrans.Add(new SeeMonsterTrans(gameObject));
        patrolltrans.Add(new PushedTrans(gameObject));         //is being pushed
        patrolltrans.Add(new TimePassTrans(gameObject, 30f, "patrollonce"));
        PatrollState patroll = new PatrollState(gameObject, patrolltrans);

        states.Add(patroll);

        //Patroll once state
        List <Transition> patrolloncetrans = new List <Transition>();

        patrolloncetrans.Add(new SeeMonsterTrans(gameObject));
        patrolloncetrans.Add(new PushedTrans(gameObject));         //is being pushed
        patrolloncetrans.Add(new TimePassTrans(gameObject, 15f, "patroll"));
        PatrollOnceState patrollonce = new PatrollOnceState(gameObject, patrolloncetrans);

        states.Add(patrollonce);

        //Flee state
        List <Transition> fleetrans = new List <Transition>();

        fleetrans.Add(new SeeMonsterTrans(gameObject));
        fleetrans.Add(new PushedTrans(gameObject));         //is being pushed
        fleetrans.Add(new TimePassTrans(gameObject, 15f, "patroll"));
        FleeState flee = new FleeState(gameObject, fleetrans, 10f);

        states.Add(flee);

        //Waypoint decision state
        List <Transition> waypointtrans = new List <Transition>();

        waypointtrans.Add(new PushedTrans(gameObject));
        waypointtrans.Add(new StopAndTimePassTrans(gameObject, 7f, "flee"));
        WaypointState waypoint = new WaypointState(gameObject, waypointtrans, 12f);

        states.Add(waypoint);

        //Dizzy state
        List <Transition> dizzytrans = new List <Transition>();

        dizzytrans.Add(new StopAndTimePassTrans(gameObject, 1f, "waypoint"));
        DizzyState dizzy = new DizzyState(gameObject, dizzytrans, 3f);

        states.Add(dizzy);

        initialState        = patroll;
        currentState        = patroll;
        triggeredTransition = null;
        gameObject.GetComponent <GraphPathFollowing>().astar_target = null;      //Set to null just in case
        initialSpeed = gameObject.GetComponent <Agent>().maxSpeed;
    }
Esempio n. 4
0
        private void Start()
        {
            CurrentWaypoint = 0;
            Movement        = GetComponent <IMovement>();

            Movement.SetCanMove(true);
            State = WaypointState.Moving;

            WaypointPathType = PathType switch
            {
                PathType.Reverse => new WayypointReverse(),
                _ => new WayypointLoop(),
            };
        }
Esempio n. 5
0
        private void Moving()
        {
            if (Vector2.Distance(Waypoints[CurrentWaypoint], transform.position) <= 0.1f)
            {
                WaypointPathType.GetNextWaypoint(ref CurrentWaypoint, Waypoints.Count);

                Movement.SetMoveDirection(Vector2.zero);
                State = WaypointState.Waiting;

                StartCoroutine(GetNextState());
            }
            else
            {
                Vector2 direction = (Waypoints[CurrentWaypoint] - (Vector2)transform.position).normalized;
                Movement.SetMoveDirection(direction);

                DirectionDependentObject.right = direction;
            }
        }
Esempio n. 6
0
        public double p4;                               // param 4

        /// <summary>
        /// this constructor is used only for reading mission files
        /// </summary>
        /// <param name="lw"></param>
        internal LocationWp(Locationwp lw)
        {
            waypointState = WaypointState.None;

            number = lw.number;
            id     = (MAV_CMD)Enum.Parse(typeof(MAV_CMD), lw.id.ToString()); // command id

            isHome = lw.ishome != 0;

            coordinateFrameOption = lw.options == 1 ? CoordinateFrameOption.MAV_FRAME_GLOBAL_RELATIVE_ALT : CoordinateFrameOption.MAV_FRAME_GLOBAL;

            // alt is in meters, can be above the ground (AGL) or above mean sea level (MSL), depending on coordinateFrameOption
            geoPosition = new GeoPosition(lw.lng, lw.lat, lw.alt);

            // p1-p4 are just float point numbers that can be added to waypoints and be interpreted by behaviors. We pass them all directly.
            p1 = lw.p1;
            p2 = lw.p2;
            p3 = lw.p3;
            p4 = lw.p4;
        }
Esempio n. 7
0
        /// <summary>
        /// this constructor is used only for reading mission files
        /// </summary>
        /// <param name="lw"></param>
        internal LocationWp(Locationwp lw)
        {
            waypointState = WaypointState.None;

            number = lw.number;
            id = (MAV_CMD)Enum.Parse(typeof(MAV_CMD), lw.id.ToString());    // command id

            isHome = lw.ishome != 0;

            coordinateFrameOption = lw.options == 1 ? CoordinateFrameOption.MAV_FRAME_GLOBAL_RELATIVE_ALT : CoordinateFrameOption.MAV_FRAME_GLOBAL;

            // alt is in meters, can be above the ground (AGL) or above mean sea level (MSL), depending on coordinateFrameOption
            geoPosition = new GeoPosition(lw.lng, lw.lat, lw.alt);

            // p1-p4 are just float point numbers that can be added to waypoints and be interpreted by behaviors. We pass them all directly.
            p1 = lw.p1;
            p2 = lw.p2;
            p3 = lw.p3;
            p4 = lw.p4;
        }
Esempio n. 8
0
        private IEnumerator GetNextState()
        {
            yield return(new WaitForSeconds(SecondsAtWaypoint));

            State = WaypointState.Moving;
        }