public void Starting() { float time = Time.time - _startTime; // 当前已运行的时间; for (int i = 0; i < _manager.agentManager.Agents.Count; i++) { FlockAgent agent = _manager.agentManager.Agents[i]; Vector2 agent_vector2 = agent.GenVector2; Vector2 ori_vector2 = agent.OriVector2; // 获取此 agent 需要的动画时间 float aniTime = time; // 如果总动画时间超出 agent 需要的动画时间,则不进行处理 if (aniTime > _entranceDisplayTime) { // 此时可能未走完动画 if (!agent.isCreateSuccess) { agent.SetChangedPosition(ori_vector2); agent.isCreateSuccess = true; } } else { float t = aniTime / _entranceDisplayTime; Func <float, float> ef = EasingFunction.Get(_manager.cutEffectConfig.UpDownDisplayEaseEnum); t = ef(t); Vector2 to = Vector2.Lerp(agent_vector2, ori_vector2, t); float a = Mathf.Lerp(0f, 1f, t); agent.GetComponent <Image>().color = new Color(1, 1, 1, a); agent.SetChangedPosition(to); } } if ((time - _entranceDisplayTime * 0.5f) > 0) { if (!_hasCallDisplay) { _hasCallDisplay = true; _onDisplayStart.Invoke(); } } if ((time - _entranceDisplayTime) > 0) { Reset(); _onEffectCompleted.Invoke(); } }
public void Starting() { float time = Time.time - _startTime; // 当前已运行的时间; for (int i = 0; i < _manager.agentManager.Agents.Count; i++) { FlockAgent agent = _manager.agentManager.Agents[i]; //Vector2 agent_vector2 = agent.GetComponent<RectTransform> ().anchoredPosition; Vector2 agent_vector2 = agent.GenVector2; Vector2 ori_vector2 = agent.OriVector2; float aniTime = (_startingTimeWithOutDelay - agent.DelayX + agent.DelayY); // 动画运行的总时间 // 此时有两种特殊状态,还未移动的与已移动完成的 if (time > aniTime) { // 此时可能未走完动画 if (!agent.isCreateSuccess) { agent.SetChangedPosition(ori_vector2); agent.isCreateSuccess = true; } } else { float t = time / aniTime; Func <float, float> defaultEasingFunction = EasingFunction.Get(_manager.cutEffectConfig.CurveStaggerDisplayEaseEnum); t = defaultEasingFunction(t); Vector2 to = Vector2.Lerp(agent_vector2, ori_vector2, t); agent.SetChangedPosition(to); } } if ((time - _entranceDisplayTime * 0.8f) > 0) { if (!_hasCallDisplay) { _hasCallDisplay = true; _onDisplayStart.Invoke(); } } if ((time - _entranceDisplayTime) > 0) { Reset(); _onEffectCompleted.Invoke(); } }
public void Starting() { float time = Time.time - _startTime; // 当前已运行的时间; for (int i = 0; i < _manager.agentManager.Agents.Count; i++) { FlockAgent agent = _manager.agentManager.Agents[i]; Vector2 agent_vector2 = agent.GenVector2; Vector2 ori_vector2 = agent.OriVector2; float run_time = (_startingTimeWithOutDelay - agent.DelayX + agent.DelayY) - _timeBetweenStartAndDisplay; // 动画运行的总时间 //Ease.InOutQuad if (time > run_time) { continue; } float t = time / run_time; Func <float, float> defaultEasingFunction = EasingFunction.Get(_manager.cutEffectConfig.CurveStaggerDisplayEaseEnum); t = defaultEasingFunction(t); Vector2 to = Vector2.Lerp(agent_vector2, ori_vector2, t); agent.SetChangedPosition(to); } if ((time - _entranceDisplayTime * 0.8f) > 0) { if (!_hasCallDisplay) { _hasCallDisplay = true; _onDisplayStart.Invoke(); } } if ((time - _entranceDisplayTime) > 0) { Reset(); _onEffectCompleted.Invoke(); } }
public void Starting() { float time = Time.time - _startTime; // 当前已运行的时间; for (int i = 0; i < _manager.agentManager.Agents.Count; i++) { FlockAgent agent = _manager.agentManager.Agents[i]; Vector2 agent_vector2 = agent.GenVector2; Vector2 ori_vector2 = agent.OriVector2; // 延时的时间 float delay_time = agent.DelayTime; // 获取此 agent 需要的动画时间 float run_time = _startingTimeWithOutDelay - delay_time; float aniTime = Time.time - _startTime - delay_time; if (aniTime < 0) { continue; } else if (aniTime > _startingTimeWithOutDelay) { // 此时可能未走完动画 if (!agent.isCreateSuccess) { agent.SetChangedPosition(ori_vector2); agent.isCreateSuccess = true; } continue; } else { float t = aniTime / _startingTimeWithOutDelay; Func <float, float> defaultEasingFunction = EasingFunction.Get(_manager.cutEffectConfig.LeftRightDisplayEaseEnum); t = defaultEasingFunction(t); Vector2 to = Vector2.Lerp(agent_vector2, ori_vector2, t); agent.SetChangedPosition(to); } } if ((time - _entranceDisplayTime * 0.8f) > 0) { if (!_hasCallDisplay) { _hasCallDisplay = true; _onDisplayStart.Invoke(); } } if ((time - _entranceDisplayTime) > 0) { Reset(); _onEffectCompleted.Invoke(); } }
public void Starting() { float time = Time.time - _startTime; // 当前已运行的时间; for (int i = 0; i < _manager.agentManager.Agents.Count; i++) { FlockAgent agent = _manager.agentManager.Agents[i]; Vector2 agent_vector2 = agent.GenVector2; Vector2 ori_vector2 = agent.OriVector2; // 获取总运行时间 float run_time = _startingTimeWithOutDelay + agent.Delay; if (time > run_time) { // 此时可能未走完动画 if (!agent.isCreateSuccess) { agent.SetChangedPosition(ori_vector2); agent.flockStatus = FlockStatusEnum.NORMAL; agent.isCreateSuccess = true; } continue; } float t = time / run_time; Func <float, float> moveEase = EasingFunction.Get(_manager.cutEffectConfig.MidDisperseMoveEaseEnum); t = moveEase(t); Vector2 to = Vector2.Lerp(agent_vector2, ori_vector2, t); agent.SetChangedPosition(to); // 透明度动画 var distance = Vector2.Distance(ori_vector2, to); var agentHeight = agent.GetComponent <RectTransform>().rect.height; var maxDistance = agentHeight * _manager.cutEffectConfig.MidDisperseAlphaMinDistanceFactor; if (distance < maxDistance) { float min_alpha = 0.1f; float max_alpha = 1f; float k = distance / maxDistance; Func <float, float> easeFunction = EasingFunction.Get(_manager.cutEffectConfig.MidDisperseAlphaEaseEnum); k = easeFunction(k); float newAlpha = Mathf.Lerp(max_alpha, min_alpha, k); agent.UpdateImageAlpha(newAlpha); } } if ((time - _entranceDisplayTime * 0.5f) > 0) { if (!_hasCallDisplay) { _hasCallDisplay = true; _onDisplayStart.Invoke(); } } if ((time - _entranceDisplayTime) > 0) { Reset(); _onEffectCompleted.Invoke(); } }