public static CachedTx MapTx(TxResp tx) { CachedTx lightTx = new CachedTx(); lightTx.height = tx.blockIndex; if (tx.extra != null) { lightTx.publicKey = tx.extra.publicKey; } lightTx.hash = tx.hash; lightTx.timestamp = tx.timestamp; lightTx.paymentId = tx.paymentId == "0000000000000000000000000000000000000000000000000000000000000000" ? "" : tx.paymentId; lightTx.fee = tx.fee; lightTx.unlock_time = tx.unlockTime; //map inputs lightTx.vin = new List <CachedInput>(); if (tx.inputs != null) { foreach (var inp in tx.inputs) { var cachedInput = new CachedInput(); cachedInput.amount = inp.data.amount; if (inp.data != null) { if (inp.data.input != null) { cachedInput.k_image = inp.data.input.k_image; if (inp.data.input.amount > 0 && cachedInput.amount == 0) { cachedInput.amount = inp.data.input.amount; } } } lightTx.vin.Add(cachedInput); } } //map outputs lightTx.vout = new List <CachedOutput>(); if (tx.outputs != null) { foreach (var outp in tx.outputs) { var cachedOutput = new CachedOutput(); cachedOutput.amount = outp.output.amount; cachedOutput.globalIndex = outp.globalIndex; if (outp.output != null) { if (outp.output.target != null) { if (outp.output.target.data != null) { cachedOutput.key = outp.output.target.data.key; } } } lightTx.vout.Add(cachedOutput); } } return(lightTx); }
void Start() { this.GetComponent <BoxCollider>().enabled = true; lastKnownPosition = this.transform.position; cachedInput = CachedInput.none; direction = Direction.up; orientation = Vector3.right; scaleBodyParts(); }
private void cacheInput() { if (Input.touchCount > 0) { foreach (Touch touch in Input.touches) { switch (touch.phase) { case TouchPhase.Began: /* this is a new touch */ isSwipe = true; fingerStartTime = Time.time; fingerStartPos = touch.position; break; case TouchPhase.Canceled: /* The touch is being canceled */ isSwipe = false; break; case TouchPhase.Ended: float gestureTime = Time.time - fingerStartTime; float gestureDist = (touch.position - fingerStartPos).magnitude; if (isSwipe && gestureTime < maxSwipeTime && gestureDist > minSwipeDist) { Vector2 direction = touch.position - fingerStartPos; Vector2 swipeType = Vector2.zero; if (Mathf.Abs(direction.x) > Mathf.Abs(direction.y)) { // the swipe is horizontal: swipeType = Vector2.right * Mathf.Sign(direction.x); } else { // the swipe is vertical: swipeType = Vector2.up * Mathf.Sign(direction.y); } if (swipeType.x != 0.0f) { if (swipeType.x > 0.0f) { //MOVE RIGHT cachedInput = CachedInput.right; } else { // MOVE LEFT cachedInput = CachedInput.left; } } if (swipeType.y != 0.0f) { if (swipeType.y > 0.0f) { // MOVE UP cachedInput = CachedInput.up; } else { // MOVE DOWN cachedInput = CachedInput.down; } } } break; } } } if (Input.GetKeyDown(KeyCode.UpArrow)) { cachedInput = CachedInput.up; } if (Input.GetKeyDown(KeyCode.DownArrow)) { cachedInput = CachedInput.down; } if (Input.GetKeyDown(KeyCode.LeftArrow)) { cachedInput = CachedInput.left; } if (Input.GetKeyDown(KeyCode.RightArrow)) { cachedInput = CachedInput.right; } }
public static CachedTx MapTx(TxResp tx) { CachedTx lightTx = new CachedTx(); lightTx.height = tx.blockIndex + 1; if (tx.extra != null) { lightTx.publicKey = tx.extra.publicKey; } lightTx.hash = tx.hash; lightTx.timestamp = tx.timestamp; lightTx.paymentId = tx.paymentId == "0000000000000000000000000000000000000000000000000000000000000000" ? "" : tx.paymentId; lightTx.fee = tx.fee; lightTx.unlock_time = tx.unlockTime; //lightTx.global_index_start = tx.blockIndex; - handled in the cache calling process //map signatures lightTx.signatures = new List <CachedSignature>(); if (tx.signatures != null) { foreach (var sig in tx.signatures) { lightTx.signatures.Add(new CachedSignature() { first = sig.first, second = sig.second }); } } //map inputs lightTx.vin = new List <CachedInput>(); if (tx.inputs != null) { foreach (var inp in tx.inputs) { var cachedInput = new CachedInput(); cachedInput.amount = inp.data.amount; if (inp.data != null) { cachedInput.mixin = inp.data.mixin; if (inp.data.input != null) { cachedInput.k_image = inp.data.input.k_image; cachedInput.key_offsets = inp.data.input.key_offsets; } if (inp.data.output != null) { cachedInput.outhash = inp.data.output.transactionHash; cachedInput.outnumber = inp.data.output.number; } } cachedInput.type = inp.type; lightTx.vin.Add(cachedInput); } } //map outputs //TODO: remove fusion Tx's from this cache & result lightTx.vout = new List <CachedOutput>(); if (tx.outputs != null) { foreach (var outp in tx.outputs) { var cachedOutput = new CachedOutput(); cachedOutput.amount = outp.output.amount; cachedOutput.globalIndex = outp.globalIndex; if (outp.output != null) { if (outp.output.target != null) { cachedOutput.type = outp.output.target.type; if (outp.output.target.data != null) { cachedOutput.key = outp.output.target.data.key; } } } lightTx.vout.Add(cachedOutput); } } return(lightTx); }