示例#1
0
    IEnumerator fsmWaveRun(eSTATE state)
    {
        m_BGMFightDestVol   = 1.0f;
        m_BGMAmbientDestVol = 0.0f;

        GameManager.m_GoldReward = 0;
        GameManager.m_Happiness  = 0.0f;

        m_Grid.LaunchExploreRoom(m_Waves[m_WaveDone]);

        yield return(null);

        while (state == m_State)
        {
            if (!GameManager.IsGroupExploring())
            {
                m_State = eSTATE.fsmWaveFinished;
            }

            yield return(null);
        }

        m_BGMFightDestVol   = 0.0f;
        m_BGMAmbientDestVol = m_MessageVolume;
    }
示例#2
0
 public void ChangeState(eSTATE nextState)
 {
     if (null != _currentState)
     {
         _currentState.Stop();
     }
     _currentState = _stateDic[nextState];
     _currentState.Start();
 }
示例#3
0
 void setState(eSTATE eState)
 {
     switch (eState)
     {
     case eSTATE.INGAME:
         //change to ingame scene
         break;
     }
 }
示例#4
0
    IEnumerator fsmWaveReady(eSTATE state)
    {
        m_BGMFightDestVol   = 0f;
        m_BGMAmbientDestVol = m_MessageVolume;

        yield return(waitMessage("The wave " + (m_WaveDone + 1) + " is ready"));

        m_State = eSTATE.fsmWaveRun;
    }
示例#5
0
    IEnumerator fsmPhaseEnd(eSTATE state)
    {
        yield return(waitMessage("The day is Over"));

        yield return(new WaitForSeconds(1.0f));

        m_State = eSTATE.fsmExit;

        SceneManager.LoadScene(0);
    }
示例#6
0
    //************************************************
    // fsmWaiting
    //------------------------------------------------
    //************************************************
    IEnumerator FSM(eSTATE state)
    {
        m_State = state;
        // Execute the current coroutine (state)
        while (m_State != eSTATE.fsmExit)
        {
            GameManager.SetGameFlowState(m_State);
            yield return(StartCoroutine(m_State.ToString(), m_State));
        }

        GameManager.SetGameFlowState(m_State);
    }
示例#7
0
    IEnumerator fsmIsNextWave(eSTATE state)
    {
        m_WaveDone++;
        if (m_WaveDone < m_GameConfig.m_WaveCount)
        {
            m_State = eSTATE.fsmWaitNextWave;
        }
        else
        {
            m_State = eSTATE.fsmPhaseEnd;
        }

        yield return(null);
    }
示例#8
0
    IEnumerator fsmWaveFinished(eSTATE state)
    {
        int percent = (int)Mathf.Clamp(Mathf.Ceil(GameManager.m_Happiness * 100), 0, 100);

        yield return(waitMessage("The wave " + (m_WaveDone + 1) + " have finished\n\n"
                                 + "They are " + percent + " % happy \n\n"
                                 + "You win \n" + GameManager.m_GoldReward + "golds\n\n"));

        GameManager.AddGold(GameManager.m_GoldReward);
        GameManager.m_GoldReward = 0;
        GameManager.m_Happiness  = 0.0f;

        m_State = eSTATE.fsmIsNextWave;
    }
示例#9
0
    IEnumerator fsmWaitNextWave(eSTATE state)
    {
        yield return(waitMessage("You have \n\n" + m_GameConfig.m_InterWaveDuration + " seconds\n\n before the next wave\n\nRepair Now"));

        m_Timer.SetTimer(m_GameConfig.m_InterWaveDuration);

        m_BGMFightDestVol   = 0f;
        m_BGMAmbientDestVol = 1.0f;


        yield return(new WaitForSeconds(m_GameConfig.m_InterWaveDuration));


        m_State = eSTATE.fsmWaveReady;
    }
示例#10
0
    //************************************************
    // fsmMENU
    //------------------------------------------------
    //************************************************
    IEnumerator fsmConstruct(eSTATE state)
    {
        m_WaveDone = 0;



        yield return(waitMessage("You have \n\n" + m_GameConfig.m_ConstructDuration + " seconds\n\n to prepare the room"));

        m_BGMFightDestVol   = 0f;
        m_BGMAmbientDestVol = 1.0f;

        m_Timer.SetTimer(m_GameConfig.m_ConstructDuration);

        yield return(new WaitForSeconds(m_GameConfig.m_ConstructDuration));


        m_State = eSTATE.fsmWaveReady;
    }
示例#11
0
    //************************************************
    // fsmMENU
    //------------------------------------------------
    //************************************************
    IEnumerator fsmStartPhase(eSTATE state)
    {
        m_WaveDone          = 0;
        m_BGMFightDestVol   = 0f;
        m_BGMAmbientDestVol = m_MessageVolume;

        m_Waves = new WaveConfig[3];

        for (int i = 0; i < 3; i++)
        {
            m_Waves[i] = new WaveConfig();
            m_Waves[i].InitRandom();
        }

        WaveUI1.waveConfig = m_Waves[0];
        WaveUI2.waveConfig = m_Waves[1];
        WaveUI3.waveConfig = m_Waves[2];

        yield return(waitMessage("Schedule of the day\n\n" + m_GameConfig.m_WaveCount + "waves \n\nwill pass through the dungeon"));


        m_State = eSTATE.fsmConstruct;
    }
示例#12
0
    // Update is called once per frame
    void Update()
    {
        //Debug.DrawLine(transform.position, transform.position + (transform.forward * 10.0f), Color.blue);


        //Debug.DrawLine(transform.position, transform.position + (target.transform.position - transform.position).normalized * 10.0f, Color.green);

        System.Random rnd   = new System.Random();
        int           check = 0;

        switch (state)
        {
        case eSTATE.IDLE:
            anim.SetBool("flashed", false);
            agent.velocity = Vector3.zero;
            anim.SetBool("moving", false);
            check = rnd.Next(1, 100);
            if (lookForPlayer())
            {
                agent.SetDestination(target.position);
                FaceTarget();
                state = eSTATE.FOLLOW;
            }
            else if (lightFlashed)
            {
                state = eSTATE.IDLE_SCARED;
            }
            else
            {
                //Debug.Log(check);
                if (check <= 2)
                {
                    state = eSTATE.WANDER;
                }
            }
            break;

        case eSTATE.WANDER:
            anim.SetBool("moving", false);
            anim.SetBool("flashed", false);
            rnd   = new System.Random();
            check = rnd.Next(1, 100);
            if (lookForPlayer())
            {
                agent.SetDestination(target.position);
                FaceTarget();
                state = eSTATE.FOLLOW;
            }
            else
            {
                if (check <= 5)
                {
                    state = eSTATE.IDLE;
                }
                else
                {
                    Vector3 randomDirection = UnityEngine.Random.insideUnitSphere * 5.0f;
                    randomDirection += transform.position;
                    NavMeshHit hit;
                    NavMesh.SamplePosition(randomDirection, out hit, 5.0f, 1);
                    agent.SetDestination(hit.position);
                    state = eSTATE.WALK_TO_POINT;
                }
            }
            break;

        case eSTATE.WALK_TO_POINT:
            anim.SetBool("moving", true);
            anim.SetBool("flashed", false);
            //Debug.Log(Vector3.Distance(transform.position, agent.destination));
            if (lookForPlayer())
            {
                agent.SetDestination(target.position);
                FaceTarget();
                state = eSTATE.FOLLOW;
            }
            else if (lightFlashed)
            {
                state = eSTATE.SCARED;
            }
            else if (Vector3.Distance(transform.position, agent.destination) <= 2f)
            {
                state = eSTATE.IDLE;
            }
            break;

        case eSTATE.FOLLOW:
        {
            anim.SetBool("flashed", false);
            agent.SetDestination(target.position);
            FaceTarget();
            anim.SetBool("moving", true);
            float distance = Vector3.Distance(target.position, transform.position);
            if (!lookForPlayer())
            {
                state = eSTATE.IDLE;
            }
            else if (lightFlashed)
            {
                state = eSTATE.SCARED;
            }
            else if (distance <= attackRadius)
            {
                state = eSTATE.ATTACK;
            }
        }
        break;

        case eSTATE.ATTACK:
            agent.velocity = Vector3.zero;
            FaceTarget();
            if (attackTimer <= 0.0f)
            {
                attackTimer = attackCooldown;
                OnAttack();
            }

            if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Attack"))
            {
                state = eSTATE.FOLLOW;
            }
            else if (lightFlashed)
            {
                state = eSTATE.SCARED;
            }
            break;

        case eSTATE.IDLE_SCARED:
            anim.SetBool("flashed", true);
            agent.velocity = Vector3.zero;
            if (!lookForPlayer())
            {
                lightFlashed = false;
            }
            if (!lightFlashed)
            {
                state = eSTATE.IDLE;
            }
            break;

        case eSTATE.SCARED:
            anim.SetBool("flashed", true);
            agent.velocity = Vector3.zero;
            if (!lookForPlayer())
            {
                lightFlashed = false;
            }
            if (!lightFlashed)
            {
                state = eSTATE.FOLLOW;
            }
            break;
        }

        /*float distance = Vector3.Distance(target.position, transform.position);
         *
         * if (distance <= lookRadius)
         * {
         *  agent.SetDestination(target.position);
         *
         *  anim.SetBool("moving", (agent.velocity.magnitude / agent.speed) > 0.0);
         *
         *  if (distance <= agent.stoppingDistance)
         *  {
         *      FaceTarget();
         *  }
         * }*/

        attackTimer -= Time.deltaTime;

        /*if (distance <= attackRadius)
         * {
         *  if (attackTimer <= 0.0f)
         *  {
         *      attackTimer = attackCooldown;
         *      OnAttack();
         *  }
         * }*/
    }