예제 #1
0
 private void Update()
 {
     policeTimer -= Time.deltaTime;
     if (policeTimer <= 0)
     {
         if (currentPoliceState == PoliceState.Normal)
         {
             SetPoliceAnimator(PoliceState.Speed);
             currentPoliceState = PoliceState.Speed;
         }
         else
         {
             SetPoliceAnimator(PoliceState.Normal);
             currentPoliceState = PoliceState.Normal;
         }
     }
     thievTimer -= Time.deltaTime;
     if (thievTimer <= 0)
     {
         if (currentThievState == ThiefState.Normal)
         {
             currentThievState = ThiefState.Speed;
             SetThiefAnimator(ThiefState.Speed);
         }
         else
         {
             currentThievState = ThiefState.Normal;
             SetThiefAnimator(ThiefState.Normal);
         }
     }
 }
예제 #2
0
파일: Police.cs 프로젝트: predominant/ld41
        private IEnumerator CheckPatrolStatus()
        {
            while (true)
            {
                yield return(new WaitForSecondsRealtime(0.5f));

                if (this.CurrentState != PoliceState.Patrolling)
                {
                    break;
                }

                if (this._myCamera.IsVisibleFrom(this._player.transform.GetChild(0).GetComponent <Renderer>()))
                {
                    //Debug.Log(string.Format("{0}: I can see the player", this.gameObject.name));
                    this._lastSeenPlayer          = Time.time;
                    this._renderer.material.color = this.ChaseColor;
                    this._sirenSound.Play();
                    this.CurrentState = PoliceState.Chasing;
                    continue;
                }

                if (this._navAgent.remainingDistance <= 1f)
                {
                    //Debug.Log("Patrol Complete - Setting state to Resting");
                    this.CurrentState = PoliceState.Resting;
                    continue;
                }
            }
        }
예제 #3
0
    void DoStepOutside()
    {
        m_CurrentForward = Vector3.back;

        m_DelayBeforeStepOut -= Time.deltaTime;

        if ((m_CollisionFlags & CollisionFlags.Below) == 0)
        {
            m_CurrentSpeed.y -= m_Gravity * Time.deltaTime;
        }

        if (m_DelayBeforeStepOut <= 0.0f)
        {
            m_CurrentSpeed = m_CurrentForward * m_StepOutSpeed;

            if (transform.position.z <= 0.0f)
            {
                m_CurrentState = PoliceState.e_Patrolling;

                EnterPatrol();

                Vector3 newPosition = transform.position;
                newPosition.z      = 0.0f;
                transform.position = newPosition;

                m_CurrentSpeed.z = 0.0f;
            }
        }
    }
예제 #4
0
파일: Police.cs 프로젝트: predominant/ld41
        private IEnumerator CheckChaseStatus()
        {
            while (true)
            {
                yield return(new WaitForSecondsRealtime(0.1f));

                if (this.CurrentState != PoliceState.Chasing)
                {
                    break;
                }

                while (true)
                {
                    if (this._myCamera.IsVisibleFrom(this._player.transform.GetChild(0).GetComponent <Renderer>()))
                    {
                        //Debug.Log(string.Format("{0}: I can see the player", this.gameObject.name));
                        this._lastSeenPlayer = Time.time;
                    }

                    if (Time.time - this._lastSeenPlayer > this.LosePlayerTime)
                    {
                        //Debug.Log("Lost the suspect - Taking a break");
                        this._sirenSound.Stop();
                        this.CurrentState = PoliceState.Resting;
                        break;
                    }

                    this.Chase();
                    yield return(new WaitForSecondsRealtime(this.LosePlayerTime / 10f));
                }
            }
        }
예제 #5
0
파일: Police.cs 프로젝트: predominant/ld41
        private void CheckStateChange()
        {
            if (this._lastState == this.CurrentState)
            {
                return;
            }

            this._lastState = this.CurrentState;

            this.StopAllCoroutines();

            switch (this.CurrentState)
            {
            case PoliceState.Patrolling:
                this.Patrol();
                this.StartCoroutine("CheckPatrolStatus");
                break;

            case PoliceState.Resting:
                this.StartCoroutine("CheckRestStatus");
                this.Rest();
                break;

            case PoliceState.None:
                this.CurrentState = PoliceState.Patrolling;
                break;

            case PoliceState.Chasing:
                this.StartCoroutine("CheckChaseStatus");
                this.Chase();
                break;
            }
        }
    private void Update()
    {
        alcoholAdmited = alcoholMeter.AlcoholLevel;
        float distance = Vector3.Distance(_player.position, transform.position);
        if (distance <= lookRadius)
        {
            currentState = PoliceState.Track;

        }
        if(distance <= lookRadius  && alcoholMeter.AlcoholLevel > 90)
        {
            currentState = PoliceState.Follow;
        }
        else
        {
            currentState = PoliceState.Wait;
        }
        //if(distance <= lookRadius)
        if (currentState == PoliceState.Follow)
        {
            transform.position += transform.forward * moveSpeed * Time.deltaTime;
            lookAt();
        }
        if (currentState == PoliceState.Track)
        {
            lookAt();
        }
        if (currentState == PoliceState.Wait)
        {

        }

        
    }
예제 #7
0
파일: Policeman.cs 프로젝트: Qawery/SGJ2015
	IEnumerator UpdateTarget ()
	{
		while (true)
		{
			if(target == null)
			state = PoliceState.Returning;
			if (state == PoliceState.Following)
			{
				if(!InPatrolArea())
					state = PoliceState.Returning;
				else if(Vector3.Distance (target.position, transform.position) > attackDistance)
					nav.SetDestination (ObstacleDetection () ? 
			            target.position : target.position + new Vector3 (Random.Range(1f, 2f), 0.5f, Random.Range(1f, 2f)));
				else
					transform.forward = Vector3.Normalize(target.transform.position);//nav.SetDestination(target.position);
			}
			else if (state == PoliceState.Returning)
			{
				if(transform.position == home)
					state = PoliceState.Waiting;
				else
					nav.SetDestination (home);
			}
			else
			{
				nav.destination = transform.position;
			}
			yield return new WaitForSeconds (0.5f);
		}
	}
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Police"/> class.
 /// </summary>
 /// <param name="drawing">The drawing.</param>
 /// <param name="position">The position.</param>
 /// <param name="actualTile">The actual tile.</param>
 /// <param name="player">The player.</param>
 public Police(Texture2D drawing, Vector2 position, Tile actualTile, PlayableCharacter player)
     : base(drawing, position, actualTile)
 {
     this.drawing = drawing;
     this.position = position;
     this.actualTile = actualTile;
     this.state = new NormalState(this);
     this.player = player;
 }
예제 #9
0
    public IEnumerator TakeStatement()
    {
        dialogueText.SetActive(true);
        source.clip = talkingSounds[Random.Range(0, talkingSounds.Length - 1)];
        source.Play();
        yield return(new WaitForSeconds(statementDurationSeconds));

        state = new PoliceLeaveHouse(this, state.chaseState);
        FindObjectOfType <PlayerController>().setInteracting(false);
        Destroy(dialogueText);
    }
예제 #10
0
파일: Policeman.cs 프로젝트: Qawery/SGJ2015
	void Start ()
	{
		state = PoliceState.Waiting;
		nav = GetComponent <NavMeshAgent> ();
		healthScript = GetComponent<HealthScript_00> ();
		moraleManager = GameObject.FindGameObjectWithTag ("MoraleManager").GetComponent<MoraleManager_00>();

		nav.speed = Random.Range (MIN_SPEED, MAX_SPEED);
		nav.angularSpeed = Random.Range (MIN_ANGULAR_SPEED, MAX_ANGULAR_SPEED);
		nav.acceleration = Random.Range (MIN_ACCELERATION, MAX_ACCELERATION);

		StartCoroutine (UpdateTarget ());
	}
예제 #11
0
    void DoMantle()
    {
        m_MantleTimer -= Time.deltaTime;

        m_CurrentSpeed.y = 0.0f;

        if (m_MantleTimer <= 0.0f)
        {
            m_CurrentState = PoliceState.e_Patrolling;

            transform.position += transform.up * m_MantleOffset.y + m_CurrentForward * m_MantleOffset.x;
        }
    }
예제 #12
0
    public IEnumerator DealWithDoor()
    {
        yield return(new WaitForSeconds(waitSecondsBetweenDoorThumpAttempts));

        if (currentDoorThumps < numDoorThumpsToAttempt)
        {
            state = new PoliceThumpingDoor(this, state.chaseState);
        }
        else
        {
            state = new PoliceSmashingState(this, state.chaseState);
        }
    }
예제 #13
0
파일: Police.cs 프로젝트: predominant/ld41
        private IEnumerator CheckRestStatus()
        {
            while (true)
            {
                yield return(new WaitForSecondsRealtime(this._restScheduleTime / 3f));

                if (this.CurrentState != PoliceState.Resting)
                {
                    break;
                }

                if (Time.time - this._restStartTime > this._restScheduleTime)
                {
                    //Debug.Log("Rest Complete - Starting a new patrol");
                    this.CurrentState = PoliceState.Patrolling;
                    continue;
                }
            }
        }
예제 #14
0
    void DoTackle()
    {
        if (m_DiveChargeTimer > 0.0f)
        {
            m_DiveChargeTimer -= Time.deltaTime;

            if (m_DiveChargeTimer <= 0.0f)
            {
                m_CurrentSpeed.x = m_CurrentForward.x * m_DiveSpeed;

                m_DiveTimer = m_DiveTime;

                m_HitBox.gameObject.SetActive(true);
                m_Source.PlayOneShot(AttackClips[Random.Range(0, AttackClips.Length)]);
            }
        }
        else if (m_DiveTimer > 0.0f)
        {
            m_DiveTimer -= Time.deltaTime;

            if (m_DiveTimer <= 0.0f)
            {
                m_HitBox.gameObject.SetActive(false);

                m_GetUpTimer = m_GetUpTime;

                m_CurrentSpeed.x = 0.0f;
            }
        }
        else if (m_GetUpTimer > 0.0f)
        {
            m_GetUpTimer -= Time.deltaTime;

            if (m_GetUpTimer <= 0.0f)
            {
                m_CurrentState = PoliceState.e_Patrolling;

                EnterPatrol();
            }
        }
    }
예제 #15
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();
        FindObjectOfType <Instruction>().Police();
        state = new PoliceArriving(this, new ChaseRoom1(state));

        roomOfPlayer   = FindObjectOfType <PlayerRoom>();
        goToPostitions = new Transform[roomOfPlayer.Rooms.Length];
        for (int i = 0; i < roomOfPlayer.Rooms.Length; i++)
        {
            //Child of 1 and 3 has more accurate position, bit hacky
            if (i != 1 && i != 3)
            {
                goToPostitions[i] = roomOfPlayer.Rooms[i].transform;
            }
            else
            {
                goToPostitions[i] = roomOfPlayer.Rooms[i].transform.GetChild(0);
            }
        }
    }
예제 #16
0
    public void SetPoliceAnimator(PoliceState _state)
    {
        policeRenderer.SetActive(true);
        police.SetBool("Speed", false);
        police.SetBool("Normal", false);
        switch (_state)
        {
        case PoliceState.None:
            policeRenderer.SetActive(false);
            break;

        case PoliceState.Speed:
            police.SetBool("Speed", true);
            break;

        case PoliceState.Normal:
            police.SetBool("Normal", true);
            break;

        default:
            break;
        }
        policeTimer += waitToChangeAnim;
    }
예제 #17
0
 public MoveState(PoliceState p)
 {
     policeState = p;
 }
예제 #18
0
        /// <summary>
        /// Checks the state change.
        /// </summary>
        private void CheckStateChange()
        {
            if (Player.StarPower) state = new ScaredState(this);
            else if (Player.Armed) state = new UrgeToArrestState(this);
            //check if Gru is on the same X or Y and if there is a wall in the way
            else if (player.actualTile.GetPosition().X == this.actualTile.GetPosition().X)
            {
                Tile tempTile = this.actualTile;

                if (player.actualTile.GetPosition().Y < this.actualTile.GetPosition().Y)
                {
                    //Checks if there is a wall between the police and Gru
                    while (player.actualTile != tempTile)
                    {
                        if (tempTile.TopTile == null)
                        {
                            return;
                        }
                        tempTile = tempTile.TopTile;
                    }
                }
                else
                {
                    //Checks if there is a wall between the police and Gru
                    while (player.actualTile != tempTile)
                    {
                        if (tempTile.BotomTile == null)
                        {
                            return;
                        }
                        tempTile = tempTile.BotomTile;
                    }
                }
                state = new ChasingState(this);
            }
            else if (player.actualTile.GetPosition().Y == this.actualTile.GetPosition().Y)
            {
                Tile tempTile = this.actualTile;
                if (player.actualTile.GetPosition().X < this.actualTile.GetPosition().X)
                {
                    //Checks if there is a wall between the police and Gru
                    while (tempTile != null && player.actualTile != tempTile)
                    {
                        if (tempTile != null && tempTile.LeftTile == null)
                        {
                            return;
                        }
                        tempTile = tempTile.LeftTile;
                    }
                }
                else
                {
                    //Checks if there is a wall between the police and Gru
                    while (player.actualTile != tempTile)
                    {
                        if (tempTile.RightTile == null)
                        {
                            return;
                        }
                        tempTile = tempTile.RightTile;
                    }
                }
                state = new ChasingState(this);
            }
            else
            {
                state = new NormalState(this);
            }
        }
예제 #19
0
파일: Policeman.cs 프로젝트: Qawery/SGJ2015
	public void SetTarget(Transform t)
	{
		target = t;
		state = PoliceState.Following;
	}
예제 #20
0
 public ChaseRoom5(PoliceState p) : base(p)
 {
 }