Exemplo n.º 1
0
    private IEnumerator Routine_Main()
    {
        //while (!CalcNextPoint())
        //{
        //    yield return new WaitForSeconds(0.5f);
        //}

        while (true)
        {
            if (!_AutoMove)
            {
                _MoveState = eMoveState.inIntarval;
            }

            if (_MoveState == eMoveState.inIntarval)
            {
                yield return(StartCoroutine(Routine_Intarval()));
            }
            else if (_MoveState == eMoveState.isMoving)
            {
                yield return(StartCoroutine(Routine_Move()));
            }

            yield return(null);
        }
    }
Exemplo n.º 2
0
 private void UpdateMoveState(float rateHitpoint)
 {
     if (m_eMove != eMoveState.eDie)
     {
         m_vecCharacter = GameManager.instance.character.transform.position;
         float fDistance = Mathf.Abs(transform.position.x - m_vecCharacter.x);
         if (fDistance <= 3f)
         {
             if (rateHitpoint >= 0.3f)
             {
                 // 체력이 30%이상이면 공격.
                 m_eMove = eMoveState.eTracking;
             }
             else
             {
                 // 아니면 도망
                 m_eMove = eMoveState.eEscape;
             }
         }
         else
         {
             // 사거리 밖이면 걍 노멀
             m_eMove = eMoveState.eNormal;
         }
     }
 }
Exemplo n.º 3
0
    void OnEnable()
    {
        m_bDirection = Random.Range(0, 100) % 2 == 0;
        this.GetComponent <Animator> ().ResetTrigger("die");
        this.GetComponent <Animator> ().ResetTrigger("damage");
        this.GetComponent <Animator> ().ResetTrigger("idle");
        this.GetComponent <Animator> ().SetTrigger("idle");

        this.GetComponent <BoxCollider2D>().enabled = true;

        m_eMove = eMoveState.eNormal;
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        renderer = gameObject.GetComponent <SpriteRenderer>(); //Get the renderer via GetComponent or have it cached previously
        // Unity Color Code : https://docs.unity3d.com/ScriptReference/Color.html

        totalWayPointCnt = myWayPointsRoom1.Length;

        //iHP = (int)Random.Range(MinSpawnRangeHP, MaxSpawnRangeHP);

        timeSpan     = 0.0f;
        wayPointPos  = myWayPointRoom1SE[0].transform.position;
        currentState = eMoveState.Move;
    }
Exemplo n.º 5
0
    override public void Start()
    {
        base.Start();
        _eMoveState = eMoveState.START;
        TileCell pathTileCell = _character.GetTargetTileCell();

        while (null != pathTileCell.GetPrevTileCell(_character))
        {
            _pathfindingStack.Push(pathTileCell);

            pathTileCell = pathTileCell.GetPrevTileCell(_character);
        }
        _characterVector = _character.GetPosition();
        Debug.Log(_character + " : move");
    }
Exemplo n.º 6
0
    void UpdateMove()
    {
        if (_character.IsMovePossible())
        {
            _eMoveState = eMoveState.END;
        }
        switch (_eMoveState)
        {
        case eMoveState.START:
            if (0 != _pathfindingStack.Count)
            {
                _nextTileCell = _pathfindingStack.Pop();
                sPosition curPosition;
                curPosition.x = _character.GetTileX();
                curPosition.y = _character.GetTileY();

                sPosition toPosition;
                toPosition.x = _nextTileCell.GetTileX();
                toPosition.y = _nextTileCell.GetTileY();

                _direction = _character.GetDirection(curPosition, toPosition);
                _character.SetAnimation(_direction.ToString().ToLower());
            }
            else
            {
                //상태 변경
                MoveFinish();
                return;
            }
            _eMoveState = eMoveState.MOVE;
            break;

        case eMoveState.MOVE:
            MoveInterpolation();      //보간
            break;

        case eMoveState.END:
            _character.MoveTileCell(_nextTileCell);
            _characterVector = _character.GetPosition();
            _eMoveState      = eMoveState.START;
            break;

        default:
            break;
        }
    }
Exemplo n.º 7
0
    public void Die()
    {
        m_eMove = eMoveState.eDie;

        GameManager.instance.character.SendMessage("Exp", m_nLevel);
        //this.gameObject.SetActive (false);

        // 몬스터 죽음 연출.
        this.GetComponent <BoxCollider2D>().enabled = false;
        this.GetComponent <Animator>().ResetTrigger("die");
        this.GetComponent <Animator>().SetTrigger("die");

        // 경험치 획득 텍스트
        int getExp = UtillFunc.Instance.GetMonsterExp(m_nLevel);

        GameManager.instance.SetExpText(headUpPosition, string.Format("exp\n{0}", getExp), new Color(0.5f, 0.5f, 0.5f, 0.5f));
    }
Exemplo n.º 8
0
        void SyncAnimationToState()
        {
            MAnimatedModel ma = (MAnimatedModel)Target;

            if (CurrentSpeed == 0)
            {
                MoveState = eMoveState.Idle;
            }
            //CurrentSpeed = 1;
            switch (MoveState)
            {
            case eMoveState.Idle:
                ma._animationController.PlayAnimation("idle", CurrentSpeed);
                break;

            case eMoveState.Walk:
                ma._animationController.PlayAnimation("walk", CurrentSpeed);
                break;

            case eMoveState.Run:
                ma._animationController.PlayAnimation("run", CurrentSpeed * 0.5f);
                break;
            }
        }
Exemplo n.º 9
0
    private IEnumerator Routine_Move()
    {
        if (_Agent.pathStatus == NavMeshPathStatus.PathInvalid)
        {
            yield return(new WaitForSeconds(1.0f));

            yield break;
        }
        //次の地点が見つかるまで待機
        while (_Agent.pathStatus != NavMeshPathStatus.PathInvalid && _MoveTargetPoint == null && !CalcNextPoint())
        {
            yield return(new WaitForSeconds(0.5f));

            Debug.Log("Serching");
        }

        if (Random.Range(0.0f, 100.0f) <= _RunPossibility)
        {
            //走り
            _CharaState = eCharaState.isRunning;
            _Animator.SetTrigger(_ID_Run);
            _Agent.speed = _RunSpeed;
        }
        else
        {
            //歩き
            _CharaState = eCharaState.isWalking;
            _Animator.SetTrigger(_ID_Walk);
            _Agent.speed = _WalkSpeed;
        }

        _Agent.isStopped = false;

        while (true)
        {
            _Agent.Move(transform.forward * _Agent.speed * 0.75f * Time.deltaTime);

            //到着まで移動
            if (_MoveTargetPoint != null && _MoveTargetPoint.gameObject.activeInHierarchy)
            {
                if (Vector3.SqrMagnitude(Vector3.Scale(_MoveTargetPosition, new Vector3(1, 0, 1)) - Vector3.Scale(transform.position, new Vector3(1, 0, 1))) < 0.01f)
                {
                    _LastMoveTargetPoint = _MoveTargetPoint;
                    _MoveTargetPoint     = null;
                    break;
                }
            }
            else
            {
                if (Vector3.SqrMagnitude(Vector3.Scale(_MoveTargetPosition, new Vector3(1, 0, 1)) - Vector3.Scale(transform.position, new Vector3(1, 0, 1))) < 0.1f)
                {
                    _LastMoveTargetPoint = _MoveTargetPoint;
                    _MoveTargetPoint     = null;
                    break;
                }
            }

            _DestinationElapsedTime += Time.deltaTime;
            if (_DestinationElapsedTime >= _GiveUpAribalSeconds)
            {
                break;
            }

            yield return(null);
        }

        if (Random.Range(0.0f, 100.0f) <= _IntervalPossibility)
        {
            _MoveState = eMoveState.inIntarval;
        }
        else
        {
            _MoveState = eMoveState.isMoving;
        }
    }
Exemplo n.º 10
0
    private IEnumerator Routine_Intarval()
    {
        if (_Agent.pathStatus == NavMeshPathStatus.PathInvalid)
        {
            yield return(new WaitForSeconds(1.0f));

            yield break;
        }
        _Agent.isStopped = true;

        //ランダムに次のモーションを設定
        {
            List <eCharaState> table = new List <eCharaState>();
            for (int i = 0; i < _Rate_Idle; ++i)
            {
                table.Add(eCharaState.isWaiting);
            }
            for (int i = 0; i < _Rate_Unique; ++i)
            {
                table.Add(eCharaState.inUnique);
            }
            for (int i = 0; i < _Rate_Happy; ++i)
            {
                table.Add(eCharaState.inHappy);
            }
            for (int i = 0; i < _Rate_Angry; ++i)
            {
                table.Add(eCharaState.inAngry);
            }
            for (int i = 0; i < _Rate_Sad; ++i)
            {
                table.Add(eCharaState.inSad);
            }
            for (int i = 0; i < _Rate_Funny; ++i)
            {
                table.Add(eCharaState.inFunny);
            }

            if (table.Count > 0)
            {
                _CharaState = table[Random.Range(0, table.Count)];
            }
            else
            {
                _CharaState = eCharaState.isWaiting;
            }
        }

        if (_CharaState == eCharaState.isWaiting)
        {
            //待機中
            _Animator.SetTrigger(_ID_Idle);

            float ElapsedSeconds = Random.Range(_MinMoveInterval, _MaxMoveInterval);
            while (ElapsedSeconds > 0.0f)
            {
                ElapsedSeconds -= Time.deltaTime;
                yield return(null);
            }
        }
        else if (_CharaState == eCharaState.inUnique)
        {
            //特殊モーション
            _Animator.SetTrigger(_ID_Unique);

            //変わるまで待機
            while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash != _ID_UniqueState)
            {
                yield return(null);
            }

            if (_CharaAudio)
            {
                _CharaAudio.Play(CharacterAudio.eAudioType.Unique);
            }

            //終わるまで待機
            while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash == _ID_UniqueState)
            {
                yield return(null);
            }
        }
        else if (_CharaState == eCharaState.inHappy)
        {
            //喜モーション
            _Animator.SetTrigger(_ID_Happy);

            //変わるまで待機
            while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash != _ID_HappyState)
            {
                yield return(null);
            }

            if (_CharaAudio)
            {
                _CharaAudio.Play(CharacterAudio.eAudioType.Happy);
            }

            //終わるまで待機
            while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash == _ID_HappyState)
            {
                yield return(null);
            }
        }
        else if (_CharaState == eCharaState.inAngry)
        {
            //怒モーション
            _Animator.SetTrigger(_ID_Angry);

            //変わるまで待機
            while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash != _ID_AngryState)
            {
                yield return(null);
            }

            if (_CharaAudio)
            {
                _CharaAudio.Play(CharacterAudio.eAudioType.Angry);
            }

            //終わるまで待機
            while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash == _ID_AngryState)
            {
                yield return(null);
            }
        }
        else if (_CharaState == eCharaState.inSad)
        {
            //哀モーション
            _Animator.SetTrigger(_ID_Sad);

            //変わるまで待機
            while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash != _ID_SadState)
            {
                yield return(null);
            }

            if (_CharaAudio)
            {
                _CharaAudio.Play(CharacterAudio.eAudioType.Sad);
            }

            //終わるまで待機
            while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash == _ID_SadState)
            {
                yield return(null);
            }
        }
        else if (_CharaState == eCharaState.inHappy)
        {
            //楽モーション
            _Animator.SetTrigger(_ID_Funny);

            //変わるまで待機
            while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash != _ID_FunnyState)
            {
                yield return(null);
            }

            if (_CharaAudio)
            {
                _CharaAudio.Play(CharacterAudio.eAudioType.Happy);
            }

            //終わるまで待機
            while (_Animator.GetCurrentAnimatorStateInfo(0).fullPathHash == _ID_FunnyState)
            {
                yield return(null);
            }
        }


        _MoveState = eMoveState.isMoving;
    }
Exemplo n.º 11
0
 public void RunTurn(double v)
 {
     MoveState = eMoveState.Run;
     InputYawH(v);
 }
Exemplo n.º 12
0
 public void Turn(double v)
 {
     MoveState = eMoveState.Walk;
     InputYawH(v);
 }
Exemplo n.º 13
0
 public void Run(double v)
 {
     MoveState = eMoveState.Run;
     InputV(v);
 }
Exemplo n.º 14
0
 public void Walk(double v)
 {
     MoveState = eMoveState.Walk;
     InputV(v);
 }
Exemplo n.º 15
0
    // Update is called once per frame
    void Update()
    {
        if (fHP > 80.0f)
        {
            //renderer.color = new Color(0, 0, 0, 1f); // black
            renderer.color = new Color(0, 1f, 0, 1f); // green
        }
        else if (fHP > 50.0f)
        {
            renderer.color = new Color(120 / 255, 1f, 120 / 255, 1f);
        }
        else if (fHP > 30.0f)
        {
            renderer.color = new Color(1f, 0.92f, 0.016f, 1f); // yellow
        }
        else if (fHP > 15.0f)
        {
            renderer.color = new Color(0.2f, 0.3f, 0.4F);   // orange
        }
        else
        {
            renderer.color = new Color(1f, 0f, 0f, 1f); // red
        }

        if (currentState == eMoveState.Idle)
        {
            timeSpan += Time.deltaTime;
            if (timeSpan > checkTime)
            {
                currentState = eMoveState.Move;
                timeSpan     = 0;

                // TEMP
                checkTime = Random.Range(2.0f, 6.0f);
            }

            // TEMP
            if (phase == ePhase.eRoom2)
            {
                fHP += 0.1f;

                if (fHP >= 100.0f)
                {
                    phase       = ePhase.eExit;
                    wayPointPos = myWayPointRoom2SE[1].transform.position;
                    GameObject findManager = GameObject.Find("SimulationManager");
                    findManager.GetComponent <SimulationManager>().SetEmptyBedStatus(iMyBedNumber, false);
                }
            }
        }

        if (currentState == eMoveState.Move)
        {
            currentPos = transform.position;
            float step = speed * Time.deltaTime;
            transform.position = Vector3.MoveTowards(currentPos, wayPointPos, step);

            if (Vector3.Distance(wayPointPos, currentPos) == 0f)
            {
                currentState = eMoveState.Idle;
                if (phase == ePhase.eNone)
                {
                    phase       = ePhase.eRoom1;
                    wayPointPos = myWayPointsRoom1[0].transform.position;
                }
                else if (phase == ePhase.eRoom1)
                {
                    wayPointPos = myWayPointsRoom1[nowWayPointIdx].transform.position;
                    //nowWayPointIdx++;
                    nowWayPointIdx = Random.Range(0, totalWayPointCnt);
                    nowWayPointIdx = (totalWayPointCnt > nowWayPointIdx) ? nowWayPointIdx : 0;
                }
                else if (phase == ePhase.eRoom2Pre)
                {
                    if (iMyBedNumber != -1)
                    {
                        phase       = ePhase.eRoom2;
                        wayPointPos = myWayPointsRoom2[iMyBedNumber].transform.position;
                    }
                }
                else if (phase == ePhase.eRoom2)
                {
                    //wayPointPos = myWayPointsRoom1[iMyBedNumber].transform.position;
                    //nowWayPointIdx++;
                    //nowWayPointIdx = (totalWayPointCnt > nowWayPointIdx) ? nowWayPointIdx : 0;

                    if (fHP >= 100.0f)
                    {
                        phase       = ePhase.eExit;
                        wayPointPos = myWayPointRoom2SE[1].transform.position;
                        GameObject findManager = GameObject.Find("SimulationManager");
                        findManager.GetComponent <SimulationManager>().SetEmptyBedStatus(iMyBedNumber, false);
                    }
                }
                else if (phase == ePhase.eExit)
                {
                    GameObject findManager = GameObject.Find("SpawnManager");
                    findManager.GetComponent <SpawnManager>().PatientGoingOut();
                    Object.Destroy(this.gameObject);
                }
            }
        }
    }
Exemplo n.º 16
0
 public void ReSetState()
 {
     MoveState = eMoveState.eNone;
 }