private void ResetValuesOnBackup(PreviousData data) { this.FlowDataCache.Copy(data.FlowDataCache); BusinessBackupdata = this.FlowDataCache; ((Director)this.FlowActivity.Director).InternalFlowState = data.FlowState; }
/// <summary> /// Records the current value /// </summary> /// <param name="currentPosition"></param> /// <param name="relocatedPosition"></param> public virtual void RecordCurrentValue(double currentPosition, double relocatedPosition) { SpeedDistancePoint currentPoint = GetValue(relocatedPosition); if (currentPoint != null) { PreviousData.Add(new SpeedDistancePoint(currentPosition, currentPoint.Speed)); } }
public void Stop() { if (preData == null || !isPlaying) { return; } StopAllCoroutines(); ApplyAlpha(preData.alpha); transform.localScale = preData.scale; transform.position = preData.position; transform.rotation = preData.rotation; isPlaying = false; preData = null; }
/// <summary> /// 複製一份資料。 /// </summary> /// <returns></returns> internal ConfigurationRecord Clone() { ConfigurationRecord record = new ConfigurationRecord(Namespace); record.EditAction = EditAction; if (BaseData != null) { record.BaseData = BaseData.Clone(); } if (PreviousData != null) { record.PreviousData = PreviousData.CloneNode(true) as XmlElement; } return(record); }
public void Play(TweenElement element, int count, Action endAction) { if (isPlaying) { return; } if (count <= 0) { return; } if (element.duration <= 0f) { return; } playCount = 0; targetCount = count; preData = new PreviousData(GetAlpha(element), transform.localScale, transform.position, transform.rotation); StartCoroutine(CoPlayTween(element, endAction)); }
private IPlayerMove CreateNewMove(bool checkOpenings, int?overrideSearchDepth = null) { var isMaximizing = IsPlayerWhite; Diagnostics.StartMoveCalculations(); // Common start measures if (Settings.UseTranspositionTables) { // Delete old entries from tables var transpositions = Board.Shared.Transpositions.Tables; if (transpositions.Any()) { var toBeDeleted = new List <ulong>(); var currentTurnCount = Board.Shared.GameTurnCount; foreach (var transposition in transpositions) { // If transposition.turn 20 < current 25 - 4 if (transposition.Value.GameTurnCount < currentTurnCount - Settings.ClearSavedTranspositionsAfterTurnsPassed) { toBeDeleted.Add(transposition.Key); } } foreach (var hash in toBeDeleted) { transpositions.Remove(hash); } if (Settings.UseFullDiagnostics) { if (toBeDeleted.Any()) { Diagnostics.AddMessage($"Deleted {toBeDeleted.Count} old transposition entries."); } Diagnostics.AddMessage($"Total transpositions: {transpositions.Count}."); } } } // Opening if (GameHistory.Count < 10 && checkOpenings) { var previousMoves = GetPreviousMoves(); var openingMove = Openings.NextMove(previousMoves); if (openingMove != null) { var openingMoveWithData = Board.CollectMoveProperties(openingMove); Board.ExecuteMove(openingMoveWithData); Board.Shared.GameTurnCount++; PreviousData = Diagnostics.CollectAndClear(); var result = new PlayerMoveImplementation( openingMove.ToInterfaceMove(), PreviousData.ToString()); GameHistory.Add(result.Move); return(result); } } // Get all available moves and do necessary filtering List <SingleMove> allMoves = Board.Moves(isMaximizing, true, true).ToList(); if (allMoves.Count == 0) { // Game ended to stalemate throw new ArgumentException( $"No possible moves for player [isWhite={IsPlayerWhite}]. Game should have ended to draw (stalemate)."); } if (MoveHistory.IsLeaningToDraw(GameHistory)) { // Take 4th from the end of list var repetionMove = GameHistory[^ 4];
void InitialConditions() { Color[] _unit = new Color[w * h]; Color[] _data = new Color[w * h]; Color[] _extra = new Color[w * h]; Color[] _target = new Color[w * h]; Color[] _random = new Color[w * h]; Color[] _tiles = new Color[w * h]; Color[] _corpses = new Color[w * h]; CurrentData.GetData(_data); var rnd = new System.Random(); for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { _random[i * h + j] = new Color(rnd.IntRange(0, 256), rnd.IntRange(0, 256), rnd.IntRange(0, 256), rnd.IntRange(0, 256)); _corpses[i * h + j] = new Color(0, 0, 0, 0); _tiles[i * h + j] = new Color(2, rnd.Next(0, 11), 30, 0); // Random units //if (rnd.NextDouble() > 0.85f) //{ // int dir = rnd.Next(1, 5); // int action = (int)(255f * SimShader.UnitAction.Attacking); // int g = 0; // int b = 0; // int player = rnd.Next(1, 2); // int team = player; // int type = rnd.Next(1, 2); // _unit[i * h + j] = new Color(type, player, team, 0); // _data[i * h + j] = new Color(dir, g, b, action); // _extra[i * h + j] = new Color(0, 0, 0, 0); // _target[i * h + j] = new Color(rnd.Next(0, 4), rnd.Next(0, 256), rnd.Next(0, 4), rnd.Next(0, 256)); //} //else //{ // _unit[i * h + j] = new Color(0, 0, 0, 0); // _data[i * h + j] = new Color(0, 0, 0, 0); // _extra[i * h + j] = new Color(0, 0, 0, 0); // _target[i * h + j] = new Color(0, 0, 0, 0); //} } } // Gold mine gride //for (int i = 0; i < w; i += 50) //for (int j = 0; j < h; j += 50) //{ // Create.MakeBuilding(vec(i,j), SimShader.UnitType.GoldMine, Player.None, Team.None, i, j, w, h, _unit, _data, _target); //} CurrentUnits.SetData(_unit); PreviousUnits.SetData(_unit); CurrentData.SetData(_data); PreviousData.SetData(_data); Extra.SetData(_extra); TargetData.SetData(_target); RandomField.SetData(_random); Tiles.SetData(_tiles); Corpses.SetData(_corpses); }
/// <summary> /// Records the current value /// </summary> /// <param name="currentSpeed"></param> public void RecordCurrentValue(double currentSpeed) { PreviousData.Add(GetValue(currentSpeed)); }
IEnumerator CoPlayTween(TweenElement element, Action endAction) { isPlaying = true; float duration = element.duration; float t = 0f; while (true) { if (element.isAlpha) { AnimationCurve alphaCurve = element.alphaTween.curve; float alphaValue = Mathf.Clamp01(alphaCurve.Evaluate(t / duration)); ApplyAlpha(alphaValue); } if (element.isScale) { AnimationCurve scaleCurve = element.scaleTween.curve; float scaleValue = scaleCurve.Evaluate(t / duration); transform.localScale = element.scaleTween.unitScale * scaleValue; if (element.scaleTween.freezeX) { transform.localScale = transform.localScale.SetX(preData.scale.x); } if (element.scaleTween.freezeY) { transform.localScale = transform.localScale.SetY(preData.scale.y); } if (element.scaleTween.freezeZ) { transform.localScale = transform.localScale.SetZ(preData.scale.z); } } if (element.isPosition) { AnimationCurve posCurve = element.positionTween.curve; float posValue = posCurve.Evaluate(t / duration); transform.position = preData.position + (element.positionTween.uniPosition * posValue); if (element.positionTween.freezeX) { transform.position = transform.position.SetX(preData.position.x); } if (element.positionTween.freezeY) { transform.position = transform.position.SetY(preData.position.y); } if (element.positionTween.freezeZ) { transform.position = transform.position.SetZ(preData.position.z); } } if (element.isRotation) { AnimationCurve rotCurve = element.rotationTween.curve; float rotValue = rotCurve.Evaluate(t / duration); Vector3 sourceVector = element.rotationTween.unitRotation * rotValue; if (element.rotationTween.freezeX) { sourceVector = sourceVector.SetX(preData.rotation.eulerAngles.x); } if (element.rotationTween.freezeY) { sourceVector = sourceVector.SetY(preData.rotation.eulerAngles.y); } if (element.rotationTween.freezeZ) { sourceVector = sourceVector.SetZ(preData.rotation.eulerAngles.z); } transform.rotation = Quaternion.Euler(sourceVector); } t += Time.deltaTime; if (t > element.duration) { break; } yield return(null); } if (element.isAlpha && element.alphaTween.isReset) { ApplyAlpha(preData.alpha); } if (element.isScale && element.scaleTween.isReset) { transform.localScale = preData.scale; } if (element.isPosition && element.positionTween.isReset) { transform.position = preData.position; } if (element.isRotation && element.rotationTween.isReset) { transform.rotation = preData.rotation; } playCount += 1; if (isLoop || playCount < targetCount) { StartCoroutine(CoPlayTween(element, endAction)); yield break; } isPlaying = false; preData = null; endAction?.Invoke(); }