// Override: FSMState::onEnter() public override void onEnter() { // Local variables int startConvID = -1; // Call parent base.onEnter(); // Get instance of the dialog window m_window = GameObject.Find("Dialog").GetComponent <DialogueWindowScript>(); if (m_window == null) { Debug.LogError("Dialog window has not been found!"); return; } // Block player? if (m_blockPlayerMovement == true) { Game.Instance.Player.blockMovement(true); } // Get specified conversation startConvID = m_dialogue.GetOverrideStartConversationID; if (startConvID != -1) { m_conversation = m_dialogue.getConversationByID(startConvID); } else { if (m_conversationID == -1) { m_conversation = m_dialogue.getConversationByID(m_dialogue.getConversationIDs()[0]); } else { m_conversation = m_dialogue.getConversationByID(m_conversationID); } } if (m_conversation == null) { Debug.LogError("Invalid text FSM-state (" + gameObject.name + "). Specified conversation has not been found!"); return; } // Execute all scripts with a run-type: awake m_dialogue.executeScriptFromRunType(DynamicScript.RunType.RUN_AWAKE); // Set text setTextByID(m_conversation.StartTextID); }
// Override: FSMTransition::setTargetFSMState public override void setTargetFSMState() { // Local variables DialogueWindowScript window = null; // Close window? if (m_closeDialogWindowOnLeave == true) { // Get window handle window = GameObject.Find("Dialog").GetComponent <DialogueWindowScript>(); if (window == null) { Debug.LogError("Dialog window has not been found!"); return; } window.closeDialogWindow(); } // Call parent base.setTargetFSMState(); }
// Use this for initialization void Start() { // init m_iteration = 0; // no way point m_nextWayPoint = Vector3.zero; // dont move m_velocityX = 0; m_velocityY = 0; // ignore everything except the enviroment m_ignoreLayerMask = ~(1 << LayerMask.NameToLayer(Layer.LAYER_COLLECTABLE) | 1 << LayerMask.NameToLayer(Layer.LAYER_ENEMY) | 1 << LayerMask.NameToLayer(Layer.LAYER_PLAYER) | 1 << LayerMask.NameToLayer(Layer.LAYER_PROJECTILE_ENEMY) | 1 << LayerMask.NameToLayer(Layer.LAYER_PROJECTILE_PLAYER)); // seek player m_player = GameObject.FindGameObjectWithTag(Tags.TAG_PLAYER); if (m_player == null) { Debug.LogError("Antonio: Player not found!"); m_accelerationFactor = 1; m_brakeFactor = 1; } else { Player _player = m_player.GetComponent <Player>(); m_accelerationFactor = _player.m_accelerationFactor; m_brakeFactor = _player.m_brakeFactor; } // get player data m_playerData = Game.Instance.PlayerData; // throw values m_lastPlayerValues = new PlayerValues(); m_lastPlayerValues.m_lifePoints = m_playerData.LifePoints; m_lastPlayerValues.m_lifeNumbers = m_playerData.LifeNumber; m_lastPlayerValues.m_kiwanos = m_playerData.isPowerUpAvailable(PlayerData.PowerUpType.PUT_KIWANO); m_lastPlayerValues.m_raspberry = m_playerData.isPowerUpAvailable(PlayerData.PowerUpType.PUT_RASPBERRY); m_lastGiftTimeStamp = Time.time - GIFT_TIME_DIFFERENCE; // load prefabs if (Kiwano == null) { Kiwano = Resources.Load <GameObject>("Items/KiwanoPowerUp"); } if (Raspberry == null) { Raspberry = Resources.Load <GameObject>("Items/RaspberryPowerUp"); } if (Life == null) { Life = Resources.Load <GameObject>("Items/LifePowerUp"); } // Get character controller m_controller = GetComponent <CharacterController>(); // get or create the way m_way = getWay(); // Calculate world scale m_worldScale = HelperFunctions.getWorldScale(gameObject); // calculate the height of antonio m_realAntonioHeight = m_worldScale.y * m_controller.height * transform.localScale.y; // calculate the next target distance to the player and go in the waiting state m_waiting = false; m_targetDistance = 0; calculateNextTargetDistance(); // save last position m_oldPosition = transform.position; // The text for displaying the help text GameObject tempGO = GameObject.Find("Dialog"); if (tempGO == null) { Debug.LogWarning("Antonio: GameObject SimpleTextDisplay not found!"); } else { // get component text m_textDisplayScript = tempGO.GetComponent <DialogueWindowScript>(); if (m_textDisplayScript == null) { Debug.LogWarning("Antonio: Speaking Text Display not found!"); } } // init speaking queue m_speakingQueue = new Queue <string>(); m_currentSpokenText = null; // get camera tempGO = GameObject.FindGameObjectWithTag(Tags.TAG_MAIN_CAMERA); if (tempGO == null) { Debug.LogWarning("Antonio: Main camera dont found!"); } else { m_mainCamera = tempGO.GetComponent <Camera>(); } }