public bool ContainsPointPercentageWithin(Box srcBox, Point p, int perc) { if (!ContainsPoint(p)) { return(false); } //Figure out which sides on the current box (destination) are closest to the srcBox SIDE sideX = GetClosestSideToSrcBoxX(srcBox); SIDE sideY = GetClosestSideToSrcBoxY(srcBox); //Calculate the distance the current gaze point p is from the closest side //diff is the distance from the closest side to the gazepoint. int xdiff, ydiff; xdiff = (sideX == SIDE.LEFT) ? p.X - this.left : 0; xdiff = (sideX == SIDE.RIGHT) ? this.right - p.X: xdiff; ydiff = (sideY == SIDE.TOP) ? p.Y - this.top : 0; ydiff = (sideY == SIDE.BOTTOM) ? this.bottom - p.Y : ydiff; int xdiffperc = xdiff * 100 / (width() / 2); int ydiffperc = ydiff * 100 / (height() / 2); return(xdiffperc > perc || ydiff > perc); }
//function that specifies which mode to activate or deactivate (move mode and scale mode) private void SetGrip(bool gripped, SIDE side) { if (gripped) { //Other hand is already moving. switch to scale if (m_MoveModeActive) { InitScaleMode(); } //This shouldn't happen... else if (m_ScaleModeActive) { print("Gripped while scaling..."); } // Else must be first hand to grip. begin moving else { InitMoveMode(side); } } else { //hand released. Now rotating with other hand. if (m_ScaleModeActive) { InitMoveMode((SIDE)Math.Abs((int)side - 1)); } // Stop rotating else if (m_MoveModeActive && m_rotatingHand == side) { m_MoveModeActive = false; } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) { if (side == SIDE.Right) { newPos = new Vector3(-3.5f, 0, 0); side = SIDE.Left; animationComp.Play(moveLeft.name); } } else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) { if (side == SIDE.Left) { newPos = new Vector3(3.5f, 0, 0); side = SIDE.Right; animationComp.Play(moveRight.name); } } transform.position = Vector3.Lerp(transform.position, newPos, Time.deltaTime * 10); }
private void Execute(SIDE dir) { current_side = dir; Flip(dir); //this.transform.localScale.x = dir == 1 ? -1 : 1; m_isExecuted = true; }
void Update() { if (Input.GetKeyDown(moveLeftKey)) { if (side == SIDE.Right) { newPos = initialPosition + new Vector3(0, 0, translateOffset); side = SIDE.Left; animationComp.Play(moveLeftAnimation.name); } } else if (Input.GetKeyDown(moveRightKey)) { if (side == SIDE.Left) { newPos = initialPosition + new Vector3(0, 0, -translateOffset); side = SIDE.Right; animationComp.Play(moveRightAnimation.name); } } transform.localPosition = Vector3.Lerp(transform.localPosition, newPos, Time.deltaTime * 10); }
private void ParentPlatformRootToImageTarget(GameObject imgTarget, GameObject platformRoot, SIDE drawSide) { platformRoot.transform.parent = imgTarget.transform; Vector3 targetBounds = imgTarget.GetComponent <BoxCollider>().size; float distBtwnPlatforms = 0.1f;//TODO FIX THIS magic number platformRoot.transform.rotation = imgTarget.transform.rotation; switch (drawSide) { case SIDE.LEFT: platformRoot.transform.localPosition = new Vector3((-targetBounds.z) / 4 - distBtwnPlatforms, 0, -(targetBounds.x) / 2); break; case SIDE.RIGHT: platformRoot.transform.localPosition = new Vector3((targetBounds.z) / 4 + distBtwnPlatforms, 0, -(targetBounds.x) / 2); break; default: Debug.LogError("Unknown side: " + drawSide + " When placing platform root on target"); break; } }
void Start() { this.side = SIDE.NONE; this.generalcontrol = GetComponent<GeneralBehaviour>(); this.generalcontrol.init(); this.getComponentsControl(); }
void Start() { this.side = SIDE.NONE; this.generalcontrol = GetComponent <GeneralBehaviour>(); this.generalcontrol.init(); this.getComponentsControl(); }
public void TurnRight() { GetComponent <InGamePosition>().x += 0.01f; WhereTurn = SIDE.RIGHT; PlaySingleSound.SpawnSound(Sounds.TurnCar, transform.position); GetComponent <Car> ().StartedTurning(); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) { if (side == SIDE.Center) { newPos = new Vector3(0, 0, -5); side = SIDE.Left; } else if (side == SIDE.Right) { newPos = Vector3.zero; side = SIDE.Center; } } else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) { if (side == SIDE.Left) { newPos = new Vector3(0, 0, 0); side = SIDE.Center; } else if (side == SIDE.Center) { newPos = new Vector3(0, 0, 4); side = SIDE.Right; } } transform.position = Vector3.Lerp(transform.position, newPos, Time.deltaTime * 10); }
public void displayWin(SIDE type) { String str = "Dwarves win!"; String img = "Images\\dwarfbig.png"; if (type == SIDE.TROLL) { str = "Trolls win!"; img = "Images\\trollbig.png"; } GuiText text = new GuiText(300, 300); text.setText(str); text.setFontColor(Color.Black); text.setFontSize(75); text.receivesInput(false); this.addActor(text); GuiButton image = new GuiButton(400, 500); image.setImage(img); image.receivesInput(false); this.addActor(image); }
/// <summary> /// Create or retrieve a texture of type Image (from Camera::retrieveImage() of the C++ ZED SDK) /// </summary> /// <param name="mode"></param> /// <returns></returns> public Texture2D CreateTextureImageType(SIDE mode) { if (IsTextureExist((int)TYPE_VIEW.RETRIEVE_IMAGE, (int)mode)) { return textures[(int)TYPE_VIEW.RETRIEVE_IMAGE][(int)mode]; } if (!cameraIsReady) return null; Texture2D m_Texture; if (mode == ZEDCamera.SIDE.LEFT_GREY || mode == ZEDCamera.SIDE.RIGHT_GREY || mode == ZEDCamera.SIDE.LEFT_UNRECTIFIED_GREY || mode == ZEDCamera.SIDE.RIGHT_UNRECTIFIED_GREY) { m_Texture = new Texture2D(WidthImage, HeightImage, TextureFormat.Alpha8, false); } else { m_Texture = new Texture2D(WidthImage, HeightImage, TextureFormat.RGBA32, false); } m_Texture.Apply(); IntPtr idTexture = m_Texture.GetNativeTexturePtr(); int error = dllz_register_texture_image_type((int)mode, idTexture); if (error != 0) { Debug.Log("Error Cuda " + error); //DestroyCamera(); } if (!textures.ContainsKey((int)TYPE_VIEW.RETRIEVE_IMAGE)) { textures.Add((int)TYPE_VIEW.RETRIEVE_IMAGE, new Dictionary<int, Texture2D>()); } RegisterTexture(m_Texture, (int)TYPE_VIEW.RETRIEVE_IMAGE, (int)mode); return m_Texture; }
public Move(int row, int col, SIDE s) { switch (s) { case SIDE.UP: this.row = row; this.column = col; this.direction = DIRECTION.HORIZONTAL; break; case SIDE.DOWN: this.row = row + 1; this.column = col; this.direction = DIRECTION.HORIZONTAL; break; case SIDE.LEFT: this.row = row; this.column = col; this.direction = DIRECTION.VERTICAL; break; case SIDE.RIGHT: this.row = row; this.column = col + 1; this.direction = DIRECTION.VERTICAL; break; } }
public IHttpActionResult PutSIDE(int id, SIDE sIDE) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != sIDE.SIDE_ID) { return(BadRequest()); } db.Entry(sIDE).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SIDEExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public static void convertToSides(Mesh inMesh, Vector3[] baseVerts, ref Dictionary <SIDE, HashSet <int> > dict) { dict.Clear(); Color[] colorsB = inMesh.colors; for (int i = 0; i < colorMap.Length + 1; i++) { dict.Add((SIDE)(int)i, new HashSet <int>()); } for (int i = 0; i < colorsB.Length; i++) { if (!colorsB[i].Equals(Color.white)) { SIDE index = (SIDE)Array.IndexOf(colorMap, colorsB[i]); if (index < 0) { index = SIDE.NW; } dict.TryGetValue(index, out HashSet <int> setVal); setVal.Add(i); for (int z = 0; z < baseVerts.Length; z++) { if (i != z) { if (baseVerts[z].Equals(baseVerts[i])) { setVal.Add(z); } } } dict[index] = setVal; } } }
//draws or hides a platform in either left or right side of an image target public void DrawHidePlatform(bool draw, PLATFORM platformType, SIDE drawSide) { GameObject targetToDrawPlatform = ImageTargetManager.Instance.GetCurrentMainTarget(); if (cachedPlatforms.ContainsKey(platformType)) { cachedPlatforms[platformType].SetActive(draw); if (draw) { ParentPlatformRootToImageTarget(targetToDrawPlatform, cachedPlatforms[platformType], drawSide); } return; } if (!draw) { return; } for (int i = 0; i < platforms.Count; i++) { if (platformType == platforms[i].PlatformType) { cachedPlatforms.Add(platformType, platforms[i].DrawGames(15)); ParentPlatformRootToImageTarget(targetToDrawPlatform, cachedPlatforms[platformType], drawSide); return; } } Debug.LogError("Console " + consoleName + " Doesnt have platform: " + platformType.ToString()); }
void arrowDown() { if(this.isRunning) { this.playerSide = SIDE.DOWN; this.movementBehaviour.move(new Vector2(this.movementBehaviour.rigidbody2d.velocity.x, -this.speedMove)); } }
// Use this for initialization void Start() { transform.position = Vector3.zero; newPos = transform.position; side = SIDE.Center; }
void arrowRight() { if(this.isRunning) { Flip(SIDE.RIGHT); this.playerSide = SIDE.RIGHT; this.movementBehaviour.move(new Vector2(this.speedMove, this.movementBehaviour.rigidbody2d.velocity.y)); } }
void Start() { initialPosition = transform.position; side = SIDE.Left; newPos = transform.localPosition + new Vector3(0, 0, translateOffset); animationComp = GetComponent <Animation>(); }
void arrowUp() { if(this.isRunning) { this.playerSide = SIDE.UP; this.movementBehaviour.move(new Vector2(this.movementBehaviour.rigidbody2d.velocity.x, this.speedMove)); } //this.myTransform.Translate(Vector3.right * this.speedMove * Time.deltaTime); }
public LinkedList <PawnPiece> getPieces(SIDE argType) { if (argType == SIDE.DWARF) { return(dwarfPieces); } return(trollPieces); }
void Flip(SIDE side) { if (side.Equals(SIDE.LEFT)) this.transform.localScale = new Vector3(this.transform.localScale.x > 0 ? this.transform.localScale.x : -this.transform.localScale.x, this.transform.localScale.y, this.transform.localScale.z); else this.transform.localScale = new Vector3(this.transform.localScale.x < 0 ? this.transform.localScale.x : -this.transform.localScale.x, this.transform.localScale.y, this.transform.localScale.z); }
public IHttpActionResult GetSIDE(int id) { SIDE sIDE = db.SIDEs.Find(id); if (sIDE == null) { return(NotFound()); } return(Ok(sIDE)); }
public void updateScore(SIDE argTurn, int argScore) { if (argTurn == SIDE.DWARF) { dwarfScore.setText("" + argScore); } else { trollScore.setText("" + argScore); } }
public characterStatus() { name = ""; HP = 1; curHP = HP; MP = 1; curMP = MP; ATK = 1; curATK = ATK; side = SIDE.NONE_SIDE; motion = 1; }
void Start() { spawnerPos = transform.position.z; p_Side = SIDE.Mid; c_Controller = GetComponent <CharacterController>(); c_Controller.detectCollisions = true; animator = GetComponent <Animator>(); EventService.Instance.OnPlayerSpawn(); colCenterY = c_Controller.center.y; colHeight = c_Controller.height; colRadius = c_Controller.radius; }
public IHttpActionResult PostSIDE(SIDE sIDE) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SIDEs.Add(sIDE); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = sIDE.SIDE_ID }, sIDE)); }
// Use this for initialization void Start() { side = SIDE.Left; transform.position = new Vector3(-3.5f, 0, 0); newPos = transform.position; animationComp = GetComponent <Animation>(); Physics.gravity = new Vector3(0, -50, 0); }
/// <summary> /// Place a basic market order trade /// </summary> /// <param name="side">Buy or sell</param> /// <param name="pair">Trading pair</param> /// <param name="size">Size of trade</param> /// <returns>OrderResponse object</returns> public async Task <OrderResponse> PlaceMarketOrder(SIDE side, string pair, decimal size) { var tradingPair = _helper.CreateDashedPair(pair); var tradeParams = new Dictionary <string, object>(); tradeParams.Add("product_id", tradingPair); tradeParams.Add("side", side.ToString().ToLower()); tradeParams.Add("size", size); tradeParams.Add("type", TradeType.MARKET.ToString().ToLower()); return(await OnPlaceTrade(tradeParams)); }
protected void Flip(SIDE side) { if (side == SIDE.RIGHT) { transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f); current_side = SIDE.RIGHT; } else { transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); current_side = SIDE.LEFT; } }
public characterStatus(string argName, int argHP, int argMP, int argATK, SIDE argSide, int argIndex) { name = argName; HP = argHP; curHP = HP; MP = argMP; curMP = 0; ATK = argATK; curATK = ATK; side = argSide; motion = 1; index = argIndex; }
//更换回合 public void changeTurn() { Vector3 posEndTurnButton = endTurnButtonObj.transform.position; if (gameStage == GAME_STAGE.FIGHT) { for (int i = 0; i < 7; i++) { if (i != 2 && characterList[i].curMP < characterList[i].MP && characterList[i].curHP > 0) { characterList[i].curMP++; } } if (characterList[5].curHP < 9 && characterList[5].side == isWhoTurn && characterList[5].curHP > 0) { characterList[5].curHP++; } } if (isWhoTurn == SIDE.P1_SIDE) { isWhoTurn = SIDE.P2_SIDE; posEndTurnButton.x = -8; endTurnButtonObj.transform.position = posEndTurnButton; fireObject.transform.position = posEndTurnButton; if (gameStage == GAME_STAGE.FIGHT) { text.text = "Player2's Turn"; } } else { isWhoTurn = SIDE.P1_SIDE; posEndTurnButton.x = 8; endTurnButtonObj.transform.position = posEndTurnButton; fireObject.transform.position = posEndTurnButton; if (gameStage == GAME_STAGE.FIGHT) { text.text = "Player1's Turn"; } } updateCardValue(); //技能按键恢复大小 Vector3 v2 = new Vector3(1f, 1f, 1f); skillButton1.transform.localScale = v2; skillButton2.transform.localScale = v2; skillButton3.transform.localScale = v2; hideSkillButtons(); }
public IHttpActionResult DeleteSIDE(int id) { SIDE sIDE = db.SIDEs.Find(id); if (sIDE == null) { return(NotFound()); } db.SIDEs.Remove(sIDE); db.SaveChanges(); return(Ok(sIDE)); }
// Update is called once per frame void Update() { float thisY = GetComponent <InGamePosition> ().y; if (LastY == 0) { LastY = thisY; } float deltaY = thisY - LastY; float howUpdate = 0; float oldX = GetComponent <InGamePosition>().x; switch (WhereTurn) { case SIDE.LEFT: { int stopPoint = Mathf.FloorToInt(oldX); howUpdate += -1 * TurnSpeed * deltaY; if (oldX + howUpdate < stopPoint) { howUpdate = -1 * oldX + stopPoint; WhereTurn = SIDE.NOWHERE; } break; } case SIDE.RIGHT: { howUpdate += TurnSpeed * deltaY; int stopPoint = (int)(oldX + 1); if (oldX + howUpdate > stopPoint) { howUpdate = stopPoint - oldX; WhereTurn = SIDE.NOWHERE; } break; } } if (howUpdate != 0) { GetComponent <InGamePosition>().x += howUpdate; } if (Input.touchCount == 0) { pressed = false; } LastY = thisY; }
//Face to the oppsite side protected virtual void Flip() { SIDE side = this.current_side; if (side == SIDE.RIGHT) { transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f); current_side = SIDE.LEFT; } else { transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); current_side = SIDE.RIGHT; } }
private void Update(SIDE _side) { if (_side == SIDE.LEFT) { RestoreButtons(leftPanel, leftItems); } else if (_side == SIDE.RIGHT) { RestoreButtons(rightPanel, rightItems); } else if (_side == SIDE.BOTH) { RestoreButtons(leftPanel, leftItems); RestoreButtons(rightPanel, rightItems); } }
void Update() { if(Input.GetKeyDown(KeyCode.P)) { generalcontrol.chargeClothes(); } if (Input.GetKeyDown(KeyCode.Tab)) { this.getComponentsControl(); } else { if (Input.GetKeyDown(KeyCode.Space)) { GetComponent<PlayerBehaviour>().character.level.addExperience(Random.Range(100, 10500)); } if (Input.GetKey(KeyCode.W)) { this.side = SIDE.UP; this.movementsManager.move(new Vector2(0F, velocity)); } else if (Input.GetKey(KeyCode.S)) { this.side = SIDE.DOWN; this.movementsManager.move(new Vector2(0F, -velocity)); } else if (Input.GetKey(KeyCode.D)) { this.side = SIDE.RIGHT; this.movementsManager.move(new Vector2(velocity, 0F)); } else if (Input.GetKey(KeyCode.A)) { this.side = SIDE.LEFT; this.movementsManager.move(new Vector2(-velocity, 0F)); } else if (movementsManager.rigibody.velocity != Vector2.zero) { this.side = SIDE.NONE; this.movementsManager.stop(); } } }
/// <summary> /// Create a map square of the requested type with walls. /// </summary> /// <param name="type">The square type.</param> /// <param name="walls">The map walls.</param> public MapSquare(TYPE type, SIDE walls) { Type = type; Walls = walls; Conveyor = null; Laser = null; Flag = 0; BuildSpriteBitmap(); }
/// <summary> /// Create a map square with a laser and wall. /// </summary> /// <param name="laser">The laser for the square.</param> /// <param name="walls">The wall(s) for the laser.</param> public MapSquare(Laser laser, SIDE walls) { Type = TYPE.NORMAL; Walls = walls; Conveyor = null; Laser = laser; Flag = 0; BuildSpriteBitmap(); }
/********************************************************** * FUNÇÕES **********************************************************/ protected virtual void FlipX(Transform transform) { _currentSide = _currentSide == SIDE.RIGHT ? SIDE.LEFT : SIDE.RIGHT; transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); }
private void CalcSide(SIDE side) { int k = 0; if (side == SIDE.SECOND) k = 1; if (side == SIDE.THIRD) k = 2; int[, ,] sideModel = new int[3, 3, 6]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { int oi, oj; CalcBox(i, j, out oi, out oj); for (int f = 0; f < 6; f++) { switch (MoveAxis) { case AXIS.X: sideModel[i, j, f] = model[k, oi, oj, CalcFace(f)]; break; case AXIS.Y: sideModel[i, j, f] = model[oi, k, oj, CalcFace(f)]; break; case AXIS.Z: sideModel[i, j, f] = model[oi, oj, k, CalcFace(f)]; break; } } } for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { for (int f = 0; f < 6; f++) { switch (MoveAxis) { case AXIS.X: model[k, i, j, f] = sideModel[i, j, f]; break; case AXIS.Y: model[i, k, j, f] = sideModel[i, j, f]; break; case AXIS.Z: model[i, j, k, f] = sideModel[i, j, f]; break; } } } }