Ejemplo n.º 1
0
    private void ChangeToState_Traveling(RARC_RoomTab roomToWorkIn)
    {
        //Reset Timer
        currentTimeInState = 0;

        //Set Working Room
        currentWorkingRoom = roomToWorkIn;

        //Set Goal Spot
        if (currentWorkingRoom.currentFloorLevel == crewCurrentShipFloor)
        {
            crewPositionalGoal_GO = RARC_CrewBotsController.Instance.GetTravelingPosition(currentWorkingRoom, gameObject.transform.position);
            Utility_SetFacingDirection();
            isGoingInElevator = false;
        }
        else
        {
            crewPositionalGoal_GO = RARC_CrewBotsController.Instance.GetClosestElevatorPosition(crewCurrentShipFloor);
            Utility_SetFacingDirection();
            //Utlity_CalculateDirectionOfElevator();
            isGoingInElevator = true;
        }

        //Set Animator
        Utility_SetAnimation_Walk();

        //Change To Wandering
        crewCurrent_State = CrewState.Traveling;
    }
Ejemplo n.º 2
0
    private void ChangeToState_Working()
    {
        //Set Animator
        Utility_SetAnimation_Work();

        //Change To Wandering
        crewCurrent_State = CrewState.Working;
    }
Ejemplo n.º 3
0
        public void Unselect()
        {
            // ? Only do this if the crew mate is selected.
            if (state != CrewState.SELECTED)
            {
                return;
            }

            jobMenu.gameObject.SetActive(false);
            state = prevState;
        }
Ejemplo n.º 4
0
        void Update()
        {
            if (state == CrewState.CREATED)
            {
                return;
            }

            if (state == CrewState.SELECTED)
            {
                UpdateSelected();
                return;
            }

            if (state == CrewState.IDLE || state == CrewState.WORK)
            {
                CrewState nextState = state;
                nextState = stateHandler.Update();

                if (job == JobType.WANDERER)
                {
                    // ? A wanderer does not have a job.
                    return;
                }

                if (state == CrewState.IDLE && job == JobType.WARRIOR)
                {
                    if (GameManager.instance.FindWolfs().Length > 0)
                    {
                        nextState = CrewState.WORK;
                    }
                }

                if (nextState != state)
                {
                    prevState = state;
                    state     = nextState;
                    stateHandler.End();

                    if (nextState == CrewState.IDLE)
                    {
                        Idle(lastTargetAround);
                    }
                    else if (nextState == CrewState.WORK)
                    {
                        Work(lastTargetAround);
                    }

                    stateHandler.Begin();
                }
            }
        }
Ejemplo n.º 5
0
    /////////////////////////////////////////////////////////////////

    private void ChangeToState_Idling()
    {
        //Reset Timer
        currentTimeInState = 0;

        //Set Goal Spot on same level
        crewPositionalGoal_GO = null;

        //Set Animator
        Utility_SetAnimation_Idle();

        //Change To Wandering
        crewCurrent_State = CrewState.Idling;
    }
Ejemplo n.º 6
0
        public void Idle(Transform around)
        {
            if (stateHandler != null)
            {
                stateHandler.End();
            }

            // ? We want to force the Idle state here.
            prevState = CrewState.IDLE;
            state     = CrewState.IDLE;

            stateHandler     = new IdleState(transform, around);
            lastTargetAround = around;
        }
Ejemplo n.º 7
0
        StateParamaters GetParams(CrewState state)
        {
            bool isWalking = prevPosition != transform.position;

            prevPosition = transform.position;

            return(state == CrewState.IDLE
                            ? (isWalking
                                ? walkState
                                : idleState)
                            : (state == CrewState.WORK
                                ? workState
                                : defaultState));
        }
Ejemplo n.º 8
0
    private void ChangeToState_Wandering()
    {
        //Reset Timer
        currentTimeInState = 0;

        //Set Goal Spot on same level
        crewPositionalGoal_GO = RARC_CrewBotsController.Instance.GetWanderingNodePosition(crewCurrentShipFloor, gameObject.transform.position);
        Utility_SetFacingDirection();

        //Set Animator
        Utility_SetAnimation_Walk();

        //Change To Wandering
        crewCurrent_State = CrewState.Wandering;
    }
Ejemplo n.º 9
0
        public void Work(Transform around)
        {
            if (stateHandler != null)
            {
                stateHandler.End();
            }

            // ? We want to force the Idle state here.
            state        = CrewState.WORK;
            stateHandler = new WorkState(transform, job, UpdateSprite, (origin, destination) =>
            {
                GameObject arrowGameObject = Instantiate(arrowPrefab.gameObject, origin, Quaternion.identity);
                arrowGameObject.GetComponent <Arrow>().SetTarget(destination, 25);
                Destroy(arrowGameObject, 10);
            });
            lastTargetAround = around;
        }
Ejemplo n.º 10
0
        public void Select()
        {
            Player p = FindObjectOfType <Player>();

            if (Vector2.Distance(p.transform.position, transform.position) > 10)
            {
                return;
            }

            // ? We selecting a crew mate, unselect everything else.
            GameManager.instance.onClickOutside.Invoke();

            prevState = state;
            state     = CrewState.SELECTED;

            jobMenu.gameObject.SetActive(true);

            Speak(onClickAudio, false);
        }
Ejemplo n.º 11
0
        /*This method handles the different states a crew member can be in. More to be added over time.
         * A seperate method for emotional states and other things will be used. This is their physical state.
         */
        private bool StateChange(CrewState newState)
        {
            _current_state = newState;
            _current_exertion_rate = GetExertionRate(newState);

            if (newState == CrewState.Idle)
            {
                Console.WriteLine(Name + ": ' I am now idle. '");
                _activity = "Idle.";
            }
            else if (newState == CrewState.Walking)
            {
                Console.WriteLine(Name + ": ' I am now walking! '");
                _activity = "Walking.";
                //_activity = "Walking from (" + _startTile.X + "," + _startTile.Y + ") to (" + _endTile.X + "," + _endTile.Y + ")";
            }
            else if (newState == CrewState.Running)
            {
                Console.WriteLine(Name + ": ' I am now running! '");
                //_activity = "Running from (" + _startTile.X + "," + _startTile.Y + ") to (" + _endTile.X + "," + _endTile.Y + ")";
            }
            else if (newState == CrewState.Sleeping)
            {
                Console.WriteLine(Name + ": ' Time for bed! Zz. '");
                _activity = "Sleeping.";
            }
            else if (newState == CrewState.Building)
            {
                Console.WriteLine(Name + ": ' Building the structure sir! '");
                _activity = "Constructing...";
            }

            return true;
        }
Ejemplo n.º 12
0
        /*Assigns the exertion rate for each different state. That is the rate at which the crew member get's tired.
         * Perhaps we could read these values in from a database eventually.
         */
        private float GetExertionRate(CrewState newState)
        {
            switch (newState)
            {
                case CrewState.Idle:
                    return -0.1f;
                case CrewState.Walking:
                    return -0.3f;
                case CrewState.Running:
                    return -0.8f;
                case CrewState.Sleeping:
                    return 1.0f;
                case CrewState.Building:
                    return -0.5f;
            }

            Console.WriteLine(Name + ": ' ERROR! I'm not sure what my exertion rate is... Have you added a new state but not set an exertion rate? '");

            return 0;
        }
Ejemplo n.º 13
0
        public CrewMember(string name, int age, float posX, float posY, string sprite)
            : base(new Vector2(posX, posY), 64, 64, 32, true, name)
        {
            _name = name;
            _age = age;
            _country = new Country();
            _country.Name = "England";
            _country.Demonym = "English";
            _country.Flag = "England_Flag";

            _needs.Health = 100;
            _needs.Energy = 100;
            _needs.Hunger = 100;
            _needs.Thirst = 100;
            _needs.Stress = 100;

            _skills.Fitness = 0;
            _skills.Engineering = 0;
            _skills.Agriculture = 0;
            _skills.Medicine = 0;

            _walk_speed = 4;
            _run_speed = 10;

            this.MaxVelocity = _walk_speed;

            _traits = new List<Trait>();

            _sprite = sprite;

            this.Position = new Vector2(posX, posY);

            _current_state = 0;
            _current_exertion_rate = GetExertionRate(CrewState.Idle);
            _current_damage_rate = -1;
            _current_hunger_rate = -0.2f;
            _current_thirst_rate = -0.25f;
            _current_stress_rate = -0.001f;

            this.Width = 64;
            this.Height = 64;

            _activity = "Idle";
        }