// Use this for initialization
        void Start()
        {
            m_WorldSettings  = GetComponent <BaseEnemy_WorldSettings>();
            m_CombatSettings = GetComponent <BaseEnemy_CombatSettings>();

            m_Runner = new FSMRunner(gameObject);
            m_Runner.RegisterState <BaseEnemy_State_Birth>();
            m_Runner.RegisterState <BaseEnemy_State_Life>();
            m_Runner.RegisterState <BaseEnemy_State_Death>();
            m_Runner.RegisterState <BaseEnemy_State_EndOfDeath>();

            m_Runner.RegisterState <BaseEnemy_State_Idle>();

            if (m_WorldSettings.m_BirthEffect != null)
            {
                Transform instance = (Transform)Instantiate(m_WorldSettings.m_BirthEffect, transform.position, Quaternion.identity);
                instance.parent       = transform;
                m_BirthEffectInstance = instance.gameObject;
                m_BirthEffectInstance.SetActive(false);
            }

            if (m_WorldSettings.m_DeathEffect)
            {
                Transform instance = (Transform)Instantiate(m_WorldSettings.m_DeathEffect, transform.position, Quaternion.identity);
                instance.parent       = transform;
                m_DeathEffectInstance = instance.gameObject;
                m_DeathEffectInstance.SetActive(false);
            }

            switch (m_AIMode)
            {
            case AIMode.DrivenBySpawner:
                m_Runner.StartState((int)EnemyState.Birth);
                break;

            case AIMode.Idle:
                m_Runner.StartState((int)EnemyState.Idle);
                break;

            default:
                Debug.LogError(string.Format("The AI mode {0} is not supported.", m_AIMode));
                break;
            }
            //m_Runner.StartState((int)EnemyState.Birth);

            EnabledWorldMeshRenderer(false);

            m_CanEnterInCombat = true;
        }
Exemplo n.º 2
0
        void Start()
        {
            m_Runner = new FSMRunner(gameObject);
            m_Runner.RegisterState <LevelMaster_StateNothing>();
            m_Runner.RegisterState <LevelMaster_StateLoadBattleScene>();
            m_Runner.RegisterState <LevelMaster_StateUnfreezeGameobjects>();

            LevelMaster_StateFadeInFromBattle stateFadeIn = m_Runner.RegisterState <LevelMaster_StateFadeInFromBattle>();

            stateFadeIn.m_Widget     = m_FadeInWidget;
            stateFadeIn.m_StartColor = m_FadeInStartColor;
            stateFadeIn.m_EndColor   = m_FadeInEndColor;
            stateFadeIn.m_Duration   = m_FadeInDuration;

            LevelMaster_StateActivateBattleUI stateBattleUI = m_Runner.RegisterState <LevelMaster_StateActivateBattleUI>();

            stateBattleUI.m_Widget     = m_Widget;
            stateBattleUI.m_TurnCount  = m_AnimationTurnCount;
            stateBattleUI.m_Duration   = m_AnimationDuration;
            stateBattleUI.m_ScaleStart = m_AnimationScaleStartValue;
            stateBattleUI.m_ScaleStop  = m_AnimationScaleStopValue;
            m_Widget.gameObject.SetActive(false);

            LevelMaster_StateFadeToBlack stateFadeOff = m_Runner.RegisterState <LevelMaster_StateFadeToBlack>();

            stateFadeOff.m_Widget       = m_FadeOffWidget;
            stateFadeOff.m_StartColor   = m_FadeOffStartColor;
            stateFadeOff.m_EndColor     = m_FadeOffEndColor;
            stateFadeOff.m_Duration     = m_FadeOffDuration;
            stateFadeOff.m_BattleWidget = m_Widget;

            m_FadeOffWidget.gameObject.SetActive(false);

            m_Runner.StartState((int)LevelMasterState.Nothing);
        }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        m_Runner = new FSMRunner(gameObject);

        m_Runner.RegisterState <GameMaster_State_RunSingleTurn>();
        m_Runner.RegisterState <GameMaster_State_CheckGoal>();
        m_Runner.RegisterState <GameMaster_State_GameOver>();
        m_Runner.RegisterState <GameMaster_State_Victory>();
        m_Runner.RegisterState <GameMaster_State_Terminate>();
        m_Runner.RegisterState <GameMaster_State_DummyLoop>();

        GameMaster_State_Init stateInit = m_Runner.RegisterState <GameMaster_State_Init>();

        stateInit.m_FadeWidget = m_InitFadeWidget;
        stateInit.m_InitColor  = m_InitColor;

        GameMaster_State_PlayIntro statePlayIntro = m_Runner.RegisterState <GameMaster_State_PlayIntro>();

        statePlayIntro.m_IntroCutscene = m_IntroCutscene;

        m_Runner.StartState((int)GameMasterState.Init);

        m_Pawns          = new List <GameObject>();
        m_SceneParameter = GameSceneManager.GetInstance().GetParameter <CombatSceneParameter>();
        m_Settings       = GetComponent <Combat_Settings>();

        for (int prefabId = 0; prefabId < m_SceneParameter.m_EnemiesPawns.Count; prefabId++)
        {
            Transform prefab = m_SceneParameter.m_EnemiesPawns[prefabId];

            Vector3    position    = m_Settings.ComputePawnEnemyGlobalPosition(prefabId);
            Quaternion orientation = m_Settings.ComputePawnEnemyGlobalOrientation(prefabId);
            Transform  pawn        = (Transform)Instantiate(prefab, position, orientation);
            pawn.parent = gameObject.transform.root;
            m_Pawns.Add(pawn.gameObject);

            StickToGround.Apply(pawn.gameObject);
        }

        for (int prefabId = 0; prefabId < m_SceneParameter.m_PlayerPawns.Count; prefabId++)
        {
            Transform prefab = m_SceneParameter.m_PlayerPawns[prefabId];

            Vector3    position    = m_Settings.ComputePawnPlayerGlobalPosition(prefabId);
            Quaternion orientation = m_Settings.ComputePawnPlayerGlobalOrientation(prefabId);
            Transform  pawn        = (Transform)Instantiate(prefab, position, orientation);
            pawn.parent = gameObject.transform.root;
            m_Pawns.Add(pawn.gameObject);

            StickToGround.Apply(pawn.gameObject);
        }

        m_UIEffects.HideDamageEffect();
        m_UIEffects.HideGameOverEffect();
        m_UIEffects.HideVictoryEffect();
    }
        public void OnSpawn()
        {
            m_CanEnterInCombat = true;
            if (m_Runner != null)
            {
                m_Runner.StartState((int)EnemyState.Birth);
            }

            EnabledWorldMeshRenderer(false);
        }
 public override void OnEnter()
 {
     m_InnerRunner.StartState((int)RunSingleTurnState.Prepare);
 }