public void Init(SceneConfig sceneConfig, MagicWallManager manager, Action onSceneCompleted) { _manager = manager; _onSceneCompleted = onSceneCompleted; _cutEffect = CutEffectFactory.GetCutEffect(sceneConfig.sceneType); // 设置过场效果 _cutEffect.Init(_manager, sceneConfig , OnCutEffectCreateAgentCompleted, () => { // on effect completed _runEntrance = false; }, () => { // on display Start _runDisplay = true; _displayStartTime = Time.time; } ); _dataType = sceneConfig.dataType; // 设置类型 // 显示 _displayBehavior = DisplayBehaviorFactory.GetBehavior(sceneConfig.displayBehavior); // 销毁 _destoryBehavior = DestoryBehaviorFactory.GetBehavior(sceneConfig.destoryBehavior); _destoryBehavior.Init(_manager, this, OnDestoryCompleted, sceneConfig); _sceneConfig = sceneConfig; _magicSceneEnumStatus = MagicSceneEnum.Running; _runEntrance = true; }
public void OnRunCompleted() { if (!_isEnding) { _isEnding = true; //_magicSceneEnumStatus = MagicSceneEnum.RunningEnd; _manager.starEffectContent.GetComponent <CanvasGroup>() .DOFade(0, 2f) .OnComplete(() => { _manager.starEffectContainer.gameObject.SetActive(false); _onSceneCompleted.Invoke(); _starSceneStatusEnum = StarSceneStatusEnum.Init; _magicSceneEnumStatus = MagicSceneEnum.Running; _isPreparing = false; _isEnding = false; //_starSceneStatusEnum = StarSceneStatusEnum.EndCompleted; }); } }
/// <summary> /// 持续运行,主流程处理块 /// </summary> /// <returns></returns> public bool Run() { //Debug.Log("_starSceneStatusEnum : " + _starSceneStatusEnum); _magicSceneEnumStatus = MagicSceneEnum.Running; if (_starSceneStatusEnum == StarSceneStatusEnum.Init) { if (!_isPreparing) { _isPreparing = true; _activeAgents = new List <FlockAgent>(); _startTime = Time.time; DoPrepare(); } } if (_starSceneStatusEnum == StarSceneStatusEnum.InitCompleted) { _starSceneStatusEnum = StarSceneStatusEnum.Run; } if (_starSceneStatusEnum == StarSceneStatusEnum.Run) { //Debug.Log("[Star] Running"); DoAnimation(); } if ((_starSceneStatusEnum == StarSceneStatusEnum.Run) && ((Time.time - _startTime) > _durtime)) { //_starSceneStatusEnum = StarSceneStatusEnum.RunCompleted; OnRunCompleted(); } return(true); }