void PickChunk() { List <Breakaway> activePieces = manager.activePieces; float maxDist = 0f; if (activePieces.Count < 1) { Debug.LogError("ERROR: Trying to pick a chunk from any empty list"); } Breakaway currentActive = activePieces[0]; foreach (Breakaway chunk in activePieces) { float hereDistance = Vector2.Distance(manager.originalLocations[chunk.index], chunk.transform.position); if (hereDistance > maxDist) { maxDist = hereDistance; currentActive = chunk; } activePiece = currentActive; } if (activePiece == null) { Debug.LogError("ERROR: Chosen active piece is null"); } }
/// <summary> /// Creates a new <see cref="Indicators.CandlestickPatterns.Breakaway"/> pattern indicator. /// The indicator will be automatically updated on the given resolution. /// </summary> /// <param name="symbol">The symbol whose pattern we seek</param> /// <param name="resolution">The resolution.</param> /// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param> /// <returns>The pattern indicator for the requested symbol.</returns> public Breakaway Breakaway(Symbol symbol, Resolution?resolution = null, Func <BaseData, TradeBar> selector = null) { var name = _algorithm.CreateIndicatorName(symbol, "BREAKAWAY", resolution); var pattern = new Breakaway(name); _algorithm.RegisterIndicator(symbol, pattern, resolution, selector); return(pattern); }
public void ChunkReset(Breakaway chunk) { if (activePieces.Contains(chunk)) { activePieces.Remove(chunk); } else { Debug.LogError("ERROR: Chunk reset but not marked as active"); } }
public void ChunkCaught(Breakaway chunk) { if (activePieces.Contains(chunk)) { piecesDropped--; } else { Debug.LogError("ERROR: Chunk caught but not marked as active"); } }
public void RegisterBreakaway(Breakaway obj) { if (!pieces.Contains(obj)) { pieces.Add(obj); originalLocations[obj.index] = obj.transform.position; Debug.Log(obj.name + " -Chunk added to breakaway manager."); } if (pieces.Count == 16) { StartCoroutine(ChunkBreak()); } }
void FinalCleanup() { StopAllCoroutines(); grabBod.velocity = Vector2.zero; currentStage = Stage.INACTIVE; SpriteRenderer rend = activePiece.GetComponentInChildren <SpriteRenderer>(); rend.sortingOrder = 1; Transform activeTransform = activePiece.transform; activeTransform.SetPositionAndRotation(manager.originalLocations[activePiece.index], Quaternion.identity); manager.ChunkReset(activePiece); activePiece.LockInPlace(); activePiece = null; StartCoroutine(ChunkRecovery()); }