Ejemplo n.º 1
0
    void SortTargets()
    {
        interation += Time.deltaTime;
        if (interation > updateTargetInteration)
        {
            interation -= updateTargetInteration;
            if (targetsInArea == null || targetsInArea.Count < 2)
            {
                if (targetsInArea != null && targetsInArea.Count > 0)
                {
                    lookTarget = targetsInArea[0];
                }
                return;
            }

            for (int i = targetsInArea.Count - 1; i >= 0; i--)
            {
                if (targetsInArea[i] == null)
                {
                    targetsInArea.RemoveAt(i);
                }
            }
            targetsInArea.Sort(delegate(LookTarget c1, LookTarget c2)
            {
                return(Vector3.Distance(this.transform.position, c1 != null ? c1.transform.position : Vector3.one *Mathf.Infinity).CompareTo
                           ((Vector3.Distance(this.transform.position, c2 != null ? c2.transform.position : Vector3.one * Mathf.Infinity))));
            });
            if (targetsInArea.Count > 0)
            {
                lookTarget = targetsInArea[0];
            }
        }
    }
Ejemplo n.º 2
0
    static LookPoints GetLookPoints(LookTarget lookTarget)
    {
        LookPoints points        = new LookPoints();
        var        centerArea    = lookTarget.centerArea;
        var        sizeArea      = lookTarget.sizeArea;
        var        lookTransform = lookTarget.transform;

        points.frontTopLeft     = new Vector3(centerArea.x - sizeArea.x, centerArea.y + sizeArea.y, centerArea.z - sizeArea.z);
        points.frontTopRight    = new Vector3(centerArea.x + sizeArea.x, centerArea.y + sizeArea.y, centerArea.z - sizeArea.z);
        points.frontBottomLeft  = new Vector3(centerArea.x - sizeArea.x, centerArea.y - sizeArea.y, centerArea.z - sizeArea.z);
        points.frontBottomRight = new Vector3(centerArea.x + sizeArea.x, centerArea.y - sizeArea.y, centerArea.z - sizeArea.z);
        points.backTopLeft      = new Vector3(centerArea.x - sizeArea.x, centerArea.y + sizeArea.y, centerArea.z + sizeArea.z);
        points.backTopRight     = new Vector3(centerArea.x + sizeArea.x, centerArea.y + sizeArea.y, centerArea.z + sizeArea.z);
        points.backBottomLeft   = new Vector3(centerArea.x - sizeArea.x, centerArea.y - sizeArea.y, centerArea.z + sizeArea.z);
        points.backBottomRight  = new Vector3(centerArea.x + sizeArea.x, centerArea.y - sizeArea.y, centerArea.z + sizeArea.z);

        points.frontTopLeft     = lookTransform.TransformPoint(points.frontTopLeft);
        points.frontTopRight    = lookTransform.TransformPoint(points.frontTopRight);
        points.frontBottomLeft  = lookTransform.TransformPoint(points.frontBottomLeft);
        points.frontBottomRight = lookTransform.TransformPoint(points.frontBottomRight);
        points.backTopLeft      = lookTransform.TransformPoint(points.backTopLeft);
        points.backTopRight     = lookTransform.TransformPoint(points.backTopRight);
        points.backBottomLeft   = lookTransform.TransformPoint(points.backBottomLeft);
        points.backBottomRight  = lookTransform.TransformPoint(points.backBottomRight);
        return(points);
    }
Ejemplo n.º 3
0
    private void HandleInteract(Vector3 mousePosition)
    {
        // Mouseover and Click
        Ray ray = _camera.ScreenPointToRay(mousePosition);

        if (Physics.Raycast(ray, out RaycastHit hit, 20.0F))
        {
            LookTarget target = hit.collider.gameObject.GetComponent <LookTarget>();
            if (!(target is null))
            {
                uiComponent.sprite = (target.interactOverride == null) ? interactSprite : target.interactOverride;
                FadeTo(fadeSpeed);
                if (Input.GetMouseButtonDown(0) && !_isInteracting)
                {
                    // When Clicked, set move target
                    SetLookTarget(target.cameraMoveTarget);
                    if (!target.ignoreFocus)
                    {
                        if (CurrentTarget != null)
                        {
                            CurrentTarget.isCurrentTarget = false;
                        }
                        CurrentTarget          = target;
                        target.isCurrentTarget = true;
                    }
                    target.onLookAt?.Invoke();
                }
                if (_currentTarget.Equals(target.cameraMoveTarget))
                {
                    // If mouseover and looking
                    uiComponent.sprite = exitSprite;
                    FadeTo(fadeSpeed);
                }
            }
        }
Ejemplo n.º 4
0
 private void Awake()
 {
     if (this._head == null)
     {
         this._head = this.transform;
     }
     this._headLookController = this.GetComponent <HeadLookController>();
     this._lookTarget         = this.GetComponent <LookTarget>();
 }
Ejemplo n.º 5
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         Debug.Log("firing is true");
         animator.SetBool("Firing", true);
         GetComponent <AIShoot>().enabled = true;       //turn on AIShoot script
         LookTarget look = GetComponent <LookTarget>(); //get lookTarget script
         look.enabled = true;                           //turn on LookTarget script
         look.target  = other.gameObject.transform;     //set lookTarget target
     }
 }
Ejemplo n.º 6
0
    public void RemoveLookTarget(LookTarget target)
    {
        if (targetsInArea.Contains(target))
        {
            targetsInArea.Remove(target);
        }

        if (lookTarget == target)
        {
            lookTarget = null;
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Set vLookTarget
    /// </summary>
    /// <param name="target"></param>
    public void SetLookTarget(LookTarget target, bool priority = false)
    {
        if (!targetsInArea.Contains(target))
        {
            targetsInArea.Add(target);
        }

        if (priority)
        {
            lookTarget = target;
        }
    }
Ejemplo n.º 8
0
 public void OnDetect(Collider other)
 {
     if (tagsToDetect.Contains(other.gameObject.tag) && other.GetComponent <LookTarget>() != null)
     {
         lookTarget = other.GetComponent <LookTarget>();
         var headTrack = other.GetComponentInParent <HeadTrack>();
         if (!targetsInArea.Contains(lookTarget) && (headTrack == null || headTrack != this))
         {
             targetsInArea.Add(lookTarget);
             SortTargets();
             lookTarget = targetsInArea[0];
         }
     }
 }
Ejemplo n.º 9
0
    public override void InSightRange() //시야 범위 안 레이쏘기
    {
        rayPosition.x = transform.position.x;
        rayPosition.y = transform.position.y + 1.35f;
        rayPosition.z = transform.position.z;

        Vector3 survivorPosition = SightRange.getSurvivors().transform.position - transform.position;

        if (Physics.Raycast(rayPosition, survivorPosition, out rayHit, MAX_RAY_DISTANCE))
        {
            if (rayHit.collider.tag == "Player")
            {
                LookTarget = SightRange.getSurvivors().transform.gameObject;
                state      = State.Look;
                LookTarget.GetComponent <SurvivorStatus>().SetBW(gameObject);
            }
        }
    }
Ejemplo n.º 10
0
 public void OnLost(Collider other)
 {
     if (tagsToDetect.Contains(other.gameObject.tag) && other.GetComponentInParent <LookTarget>() != null)
     {
         lookTarget = other.GetComponentInParent <LookTarget>();
         if (targetsInArea.Contains(lookTarget))
         {
             targetsInArea.Remove(lookTarget);
         }
         SortTargets();
         if (targetsInArea.Count > 0)
         {
             lookTarget = targetsInArea[0];
         }
         else
         {
             lookTarget = null;
         }
     }
 }
Ejemplo n.º 11
0
        public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            payload.VisualData.Bound.transform.LookAt(
                AbsolutePosition.GetFirstValue(payload.Data)?
                LookTarget.GetFirstValue(payload.Data):
                payload.VisualData.Bound.transform.position +
                payload.VisualData.Bound.transform.PiecewiseMultiply(LookTarget.GetFirstValue(payload.Data)),

                AbsolutePosition.GetFirstValue(payload.Data)?
                UpVector.GetFirstValue(payload.Data):
                payload.VisualData.Bound.transform.position +
                payload.VisualData.Bound.transform.PiecewiseMultiply(UpVector.GetFirstValue(payload.Data))
                );

            var iterator = Router.TransmitAll(payload);

            while (iterator.MoveNext())
            {
                yield return(null);
            }
        }
Ejemplo n.º 12
0
    /// <summary>
    /// Check if anny corner points of LookTarget area is visible from observer
    /// </summary>
    /// <param name="lookTarget">principal transform of lookTarget</param>
    /// <param name="from">observer point</param>
    /// <param name="layerMask">Layer to check</param>
    /// <param name="debug">Draw lines </param>
    /// <returns></returns>
    public static bool IsVisible(this LookTarget lookTarget, Vector3 from, LayerMask layerMask, bool debug = false)
    {
        if (lookTarget.HideObject)
        {
            return(false);
        }

        if (lookTarget.visibleCheckType == LookTarget.VisibleCheckType.None)
        {
            if (lookTarget.useLimitToDetect && Vector3.Distance(from, lookTarget.transform.position) > lookTarget.minDistanceToDetect)
            {
                return(false);
            }

            return(true);
        }
        else if (lookTarget.visibleCheckType == LookTarget.VisibleCheckType.SingleCast)
        {
            if (lookTarget.useLimitToDetect && Vector3.Distance(from, lookTarget.centerArea) > lookTarget.minDistanceToDetect)
            {
                return(false);
            }
            if (CastPoint(from, lookTarget.transform.TransformPoint(lookTarget.centerArea), lookTarget.transform, layerMask, debug))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else if (lookTarget.visibleCheckType == LookTarget.VisibleCheckType.BoxCast)
        {
            if (lookTarget.useLimitToDetect && Vector3.Distance(from, lookTarget.transform.position) > lookTarget.minDistanceToDetect)
            {
                return(false);
            }
            LookPoints points = GetLookPoints(lookTarget);

            if (CastPoint(from, points.frontTopLeft, lookTarget.transform, layerMask, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.frontTopRight, lookTarget.transform, layerMask, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.frontBottomLeft, lookTarget.transform, layerMask, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.frontBottomRight, lookTarget.transform, layerMask, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.backTopLeft, lookTarget.transform, layerMask, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.backTopRight, lookTarget.transform, layerMask, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.backBottomLeft, lookTarget.transform, layerMask, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.backBottomRight, lookTarget.transform, layerMask, debug))
            {
                return(true);
            }
        }
        return(false);
    }
Ejemplo n.º 13
0
		void UpdateEyeMovement()
		{
			if ( lookTarget == LookTarget.ClearingTargetPhase2 )
			{
				if ( Time.time - timeOfEnteringClearingPhase >= 1 )
					lookTarget = LookTarget.StraightAhead;
				else
				{
					leftEyeAnchor.localRotation = lastLeftEyeLocalRotation = Quaternion.Slerp(lastLeftEyeLocalRotation, originalLeftEyeLocalQ, Time.deltaTime);
					rightEyeAnchor.localRotation = lastRightEyeLocalQ = Quaternion.Slerp(lastRightEyeLocalQ, originalRightEyeLocalQ, Time.deltaTime);
				}

				return;
			}

			if ( lookTarget == LookTarget.ClearingTargetPhase1 )
			{
				if ( Time.time - timeOfEnteringClearingPhase >= 2 )
				{
					lookTarget = LookTarget.ClearingTargetPhase2;
					timeOfEnteringClearingPhase = Time.time;
				}
			}
		
			bool isLookingAtFace = lookTarget == LookTarget.Face;
			bool shouldDoSocialTriangle =		isLookingAtFace &&
															faceLookTarget != FaceLookTarget.EyesCenter;
			Transform trans = (currentEyeTargetPOI != null) ? currentEyeTargetPOI : currentTargetLeftEyeXform;
			Vector3 eyeTargetGlobal = shouldDoSocialTriangle	? GetLookTargetPosForSocialTriangle( faceLookTarget )
																						: trans.TransformPoint(microSaccadeTargetLocal);

			//*** Prevent cross-eyes
			{
				Vector3 ownEyeCenter = GetOwnEyeCenter();
				Vector3 eyeCenterToTarget = eyeTargetGlobal - ownEyeCenter;
				float distance = eyeCenterToTarget.magnitude / eyeDistanceScale;
				float corrDistMax = isLookingAtFace ? 2f : 0.6f;
				float corrDistMin = isLookingAtFace ? 1.5f : 0.2f;
						
				if ( distance < corrDistMax )
				{
					float modifiedDistance = corrDistMin + distance * (corrDistMax-corrDistMin)/corrDistMax;
					modifiedDistance = crossEyeCorrection * (modifiedDistance-distance) + distance;
					eyeTargetGlobal = ownEyeCenter + eyeDistanceScale * modifiedDistance * (eyeCenterToTarget/distance);
				}
			}

					
			//*** After the eyes saccaded to the new POI, adjust eye duration and speed so they keep tracking the target quickly enough.
			{
				const float kEyeDurationForTracking = 0.005f;
				const float kEyeMaxSpeedForTracking = 600;

				float timeSinceLeftEyeHorizInitiatedMovementStop = Time.time-(timeOfEyeMovementStart + 1.5f * startLeftEyeHorizDuration);
				if ( timeSinceLeftEyeHorizInitiatedMovementStop > 0 )
				{
					leftHorizDuration = kEyeDurationForTracking + startLeftEyeHorizDuration/(1 + timeSinceLeftEyeHorizInitiatedMovementStop);
					leftMaxSpeedHoriz = kEyeMaxSpeedForTracking - startLeftEyeMaxSpeedHoriz/(1 + timeSinceLeftEyeHorizInitiatedMovementStop);
				}

				float timeSinceLeftEyeVertInitiatedMovementStop = Time.time-(timeOfEyeMovementStart + 1.5f * startLeftEyeVertDuration);
				if ( timeSinceLeftEyeVertInitiatedMovementStop > 0 )
				{
					leftVertDuration = kEyeDurationForTracking + startLeftEyeVertDuration/(1 + timeSinceLeftEyeVertInitiatedMovementStop);
					leftMaxSpeedVert = kEyeMaxSpeedForTracking - startLeftEyeMaxSpeedVert/(1 + timeSinceLeftEyeVertInitiatedMovementStop);
				}

				float timeSinceRightEyeHorizInitiatedMovementStop = Time.time-(timeOfEyeMovementStart + 1.5f * startRightEyeHorizDuration);
				if ( timeSinceRightEyeHorizInitiatedMovementStop > 0 )
				{
					rightHorizDuration = kEyeDurationForTracking + startRightEyeHorizDuration/(1 + timeSinceRightEyeHorizInitiatedMovementStop);
					rightMaxSpeedHoriz = kEyeMaxSpeedForTracking - startRightEyeMaxSpeedHoriz/(1 + timeSinceRightEyeHorizInitiatedMovementStop);
				}

				float timeSinceRightEyeVertInitiatedMovementStop = Time.time-(timeOfEyeMovementStart + 1.5f * startRightEyeVertDuration);
				if ( timeSinceRightEyeVertInitiatedMovementStop > 0 )
				{
					rightVertDuration = kEyeDurationForTracking + startRightEyeVertDuration/(1 + timeSinceRightEyeVertInitiatedMovementStop);
					rightMaxSpeedVert = kEyeMaxSpeedForTracking - startRightEyeMaxSpeedVert/(1 + timeSinceRightEyeVertInitiatedMovementStop);
				}
			}

					Vector3 leftEyeTargetAngles = Quaternion.LookRotation(eyesRootXform.InverseTransformDirection( eyeTargetGlobal - leftEyeAnchor.position )).eulerAngles;
					leftEyeTargetAngles = new Vector3(controlData.ClampLeftVertEyeAngle(leftEyeTargetAngles.x),
																		ClampLeftHorizEyeAngle(leftEyeTargetAngles.y),
																		0);
					float deltaTime = Mathf.Max(0.0001f, Time.deltaTime);
					float headMaxSpeedHoriz = 4*maxHeadHorizSpeedSinceSaccadeStart * Mathf.Sign(headEulerSpeed.y);
					float headMaxSpeedVert = 4*maxHeadVertSpeedSinceSaccadeStart * Mathf.Sign(headEulerSpeed.x);

			currentLeftEyeLocalEuler = new Vector3(	controlData.ClampLeftVertEyeAngle(Mathf.SmoothDampAngle(	currentLeftEyeLocalEuler.x,
																																			leftEyeTargetAngles.x,
																																			ref leftCurrentSpeedX,
																																			leftVertDuration,
																																			Mathf.Max(headMaxSpeedVert, leftMaxSpeedVert),
																																			deltaTime)),
																		ClampLeftHorizEyeAngle(Mathf.SmoothDampAngle(	currentLeftEyeLocalEuler.y,
																																					leftEyeTargetAngles.y,
																																					ref leftCurrentSpeedY,
																																					leftHorizDuration,
																																					Mathf.Max(headMaxSpeedHoriz, leftMaxSpeedHoriz),
																																					deltaTime)),
																		leftEyeTargetAngles.z);

			leftEyeAnchor.localRotation = Quaternion.Inverse(leftEyeAnchor.parent.rotation) * eyesRootXform.rotation * Quaternion.Euler( currentLeftEyeLocalEuler ) * leftEyeRootFromAnchorQ;

					Vector3 rightEyeTargetAngles = Quaternion.LookRotation(eyesRootXform.InverseTransformDirection( eyeTargetGlobal - rightEyeAnchor.position)).eulerAngles;
					rightEyeTargetAngles = new Vector3(	controlData.ClampRightVertEyeAngle(rightEyeTargetAngles.x),
																			ClampRightHorizEyeAngle(rightEyeTargetAngles.y),
																			0);
			currentRightEyeLocalEuler= new Vector3( controlData.ClampRightVertEyeAngle(Mathf.SmoothDampAngle(	currentRightEyeLocalEuler.x,
																																			rightEyeTargetAngles.x,
																																			ref rightCurrentSpeedX,
																																			rightVertDuration,
																																			Mathf.Max(headMaxSpeedVert, rightMaxSpeedVert),
																																			deltaTime)),
																		ClampRightHorizEyeAngle(Mathf.SmoothDampAngle(currentRightEyeLocalEuler.y,
																																					rightEyeTargetAngles.y,
																																					ref rightCurrentSpeedY,
																																					rightHorizDuration,
																																					Mathf.Max(headMaxSpeedHoriz, rightMaxSpeedHoriz),
																																					deltaTime)),
																		rightEyeTargetAngles.z);

			rightEyeAnchor.localRotation = Quaternion.Inverse(rightEyeAnchor.parent.rotation) * eyesRootXform.rotation * Quaternion.Euler( currentRightEyeLocalEuler ) * rightEyeRootFromAnchorQ;

			lastLeftEyeLocalRotation = leftEyeAnchor.localRotation;
			lastRightEyeLocalQ = rightEyeAnchor.localRotation;
		}
Ejemplo n.º 14
0
    /// <summary>
    /// Check if anny corner points of LookTarget area is visible from observer
    /// </summary>
    /// <param name="lookTarget">principal transform of lookTarget</param>
    /// <param name="from">observer point</param>
    /// <param name="debug">Draw lines </param>
    /// <returns></returns>
    public static bool IsVisible(this LookTarget lookTarget, Vector3 from, bool debug = false)
    {
        if (lookTarget.HideObject)
        {
            return(false);
        }
        LookPoints points = GetLookPoints(lookTarget);

        if (lookTarget.visibleCheckType == LookTarget.VisibleCheckType.None)
        {
            return(true);
        }
        else if (lookTarget.visibleCheckType == LookTarget.VisibleCheckType.SingleCast)
        {
            if (CastPoint(from, lookTarget.transform.TransformPoint(lookTarget.centerArea), lookTarget.transform, debug))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else if (lookTarget.visibleCheckType == LookTarget.VisibleCheckType.BoxCast)
        {
            if (CastPoint(from, points.frontTopLeft, lookTarget.transform, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.frontTopRight, lookTarget.transform, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.frontBottomLeft, lookTarget.transform, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.frontBottomRight, lookTarget.transform, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.backTopLeft, lookTarget.transform, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.backTopRight, lookTarget.transform, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.backBottomLeft, lookTarget.transform, debug))
            {
                return(true);
            }

            if (CastPoint(from, points.backBottomRight, lookTarget.transform, debug))
            {
                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 15
0
    IEnumerator Look()
    {
        //들어갈때
        if (Audio != null)
        {
            Audio.Play("Look", LookTarget);
            Audio.Play("Walk");
        }
        if (backMoveFlag)
        {
            state      = State.Idle;
            LookTarget = null;
        }
        aiPath.speed         = walkSpeed - 1f;
        aiPath.rotationSpeed = rotationDamping;
        animator.SetFloat("Speed_f", aiPath.speed / runSpeed);
        while (state == State.Look)
        {
            //업데이트할때
            if (LookTarget != null)
            {
                aiPath.target = LookTarget.transform;
                float dist = GetDistance(LookTarget);
                currentPosition = LookTarget.transform.position;                                      //타겟의 현재 위치
                currentSpeed    = LookTarget.GetComponent <CharacterController>().velocity.magnitude; //타겟의 현재 속도
                //일정거리에 가까워질때 몇초후에도 가만히있다면 공격
                if (dist < 2f)
                {
                    aiPath.speed         = 0f;                             //이동속도 0
                    aiPath.rotationSpeed = 0f;                             //회전속도 0
                    animator.SetFloat("Speed_f", aiPath.speed / runSpeed); //애니메이션 속도조절
                    StartCoroutine(StopLook(stopLookTimer, currentPosition));
                }
                else if (dist > 35.0f)
                {
                    GameController.GetInstance().ActionMessage("Right", "곰의 시야에서 벗어났습니다.", LookTarget);
                    state = State.Idle;
                    LookTarget.GetComponent <SurvivorStatus>().SetBW(null);
                    LookTarget = null;
                }
                else
                {
                    aiPath.speed = walkSpeed - 1f;
                }

                //공격범위 안에 들어온 타겟이 LookTarget하고 다르다면 LookTarget을 들어온 타겟으로 바꿈
                if (AttackRange.InTarget != null)
                {
                    if (LookTarget != AttackRange.InTarget)
                    {
                        LookTarget = AttackRange.InTarget;
                    }
                }

                //타겟이 뛰거나 뒤로 돌면 쫒아감
                if (LookTarget != null)
                {
                    if (!backMoveFlag)   //회피때는 인식X
                    {
                        StartCoroutine(LookToChase(lookToChaseTimer, currentSpeed, LookTarget));
                    }
                    else
                    {
                        StopCoroutine(LookToChase(lookToChaseTimer, currentSpeed, LookTarget));
                    }
                }
            }
            else if (LookTarget == null)
            {
                state = State.Idle;
            }
            yield return(0);
        }
        //벗어날때
        if (Audio != null)
        {
            Audio.Stop("Walk");
        }
        GoToNextState();
    }
Ejemplo n.º 16
0
    IEnumerator Look()
    {
        if (Audio != null)
        {
            Audio.Play("Look");
            Audio.Play("Walk");
        }
        aiPath.speed         = walkSpeed - 1.5f;
        aiPath.rotationSpeed = rotationDamping;
        while (state == State.Look)
        {
            //업데이트할때
            animator.SetFloat("Speed_f", aiPath.speed / runSpeed); //추가
            if (LookTarget != null)
            {
                float dist = GetDistance(LookTarget);
                aiPath.target = LookTarget.transform;
                if (LookTarget.GetComponent <SurvivorStatus>().UmbrellaState)
                {
                    if (dist < 5.0f)
                    {
                        aiPath.speed = 0f;
                        animator.SetFloat("Speed_f", 0); //추가
                        StartCoroutine(ObstacleDistinction(obstacleDistinctionTimer, LookTarget));
                    }
                }
                else if (dist < 2f)
                {
                    state       = State.Chase;
                    ChaseTarget = LookTarget;
                    GameController.GetInstance().ActionMessage("Wrong", "멧돼지와 가깝습니다.", ChaseTarget);
                }
                else if (dist > sightDistance)
                {
                    GameController.GetInstance().ActionMessage("Right", "멧돼지의 시야에서 벗어났습니다.", LookTarget);
                    state = State.Idle;
                    LookTarget.GetComponent <SurvivorStatus>().SetBW(null);
                    LookTarget = null;
                }
                else
                {
                    aiPath.speed = walkSpeed - 1.5f;
                }


                //시야범위 안에 또 다른 타겟이 왔을때 더 가까우면 교환
                if (SightRange.getSurvivors() != null)
                {
                    if (LookTarget != SightRange.getSurvivors())
                    {
                        if (GetDistance(SightRange.getSurvivors()) < GetDistance(LookTarget))
                        {
                            GameController.GetInstance().ActionMessage("Right", "다른 상대보다 멧돼지와 더 멀어져 시야에서 벗어났습니다.", LookTarget);
                            LookTarget = SightRange.getSurvivors();
                            GameController.GetInstance().ActionMessage("Wrong", "다른 상대보다 멧돼지와 더 가까워 대상이 되었습니다.", LookTarget);
                        }
                    }
                }
                //타겟이 뛰거나 뒤로 돌면 쫒아감
                if (!umbrellaMoveFlag)
                {
                    StartCoroutine(LookToChase(lookToChaseTimer, currentSpeed, LookTarget));
                }
            }
            yield return(0);
        }
        //벗어날때
        if (Audio != null)
        {
            Audio.Stop("Walk");
            Audio.Stop("Look");
        }
        GoToNextState();
    }
Ejemplo n.º 17
0
 private void Awake()
 {
     this._headLookController = this.GetComponent <HeadLookController>();
     this._lookTarget         = this.GetComponent <LookTarget>();
 }
Ejemplo n.º 18
0
		public void LookAtAreaAround( Transform poi )
		{
			lookTarget = LookTarget.GeneralDirection;
			headSpeed = HeadSpeed.Slow;
			eyeLatency = Random.Range(0.05f, 0.1f);

			nextEyeTargetPOI = poi;
			currentTargetLeftEyeXform = currentTargetRightEyeXform = null;
			nextTargetLeftEyeXform = nextTargetRightEyeXform = null;

			StartHeadMovement( poi );
		}
Ejemplo n.º 19
0
		public void LookAtSpecificThing( Transform poi, float headLatency=0.075f )
		{
			lookTarget = LookTarget.SpecificThing;
			headSpeed = HeadSpeed.Fast;
			this.headLatency = headLatency;
			nextHeadTargetPOI = poi;
			currentTargetLeftEyeXform = currentTargetRightEyeXform = null;
			nextTargetLeftEyeXform = nextTargetRightEyeXform = null;

			StartEyeMovement( poi );
		}
Ejemplo n.º 20
0
		public void LookAtFace(	Transform leftEyeXform,
											Transform rightEyeXform,
											float headLatency=0.075f )
		{
			lookTarget = LookTarget.Face;
			headSpeed = HeadSpeed.Fast;
			faceLookTarget = FaceLookTarget.EyesCenter;
			this.headLatency = headLatency;
			currentTargetLeftEyeXform = leftEyeXform;
			currentTargetRightEyeXform = rightEyeXform;
			nextTargetLeftEyeXform = nextTargetRightEyeXform = null;
			nextHeadTargetPOI = null;

			StartEyeMovement( );
		}
Ejemplo n.º 21
0
		//float ClampLeftVertEyeAngle( float angle )
		//{
		//	//if ( controlData.eyeControl == ControlData.EyeControl.MecanimEyeBones )
		//	//	return controlData.leftBoneEyeRotationLimiter.ClampAngle( angle );
		//	//else if ( controlData
		//	//return Mathf.Clamp(Utils.NormalizedDegAngle(angle), -controlData.maxEyeUpAngle, controlData.maxEyeDownAngle);
		//}



		public void ClearLookTarget()
		{
			LookAtAreaAround( GetOwnEyeCenter() + transform.forward * 1000 * eyeDistance );
			lookTarget = LookTarget.ClearingTargetPhase1;
			timeOfEnteringClearingPhase = Time.time;
		}
Ejemplo n.º 22
0
 void Start()
 {
     lt = new LookTarget();
 }