internal Consprite(int width, int height) { Width = width; Height = height; Textels = new Textel[Width * Height]; Z = 0; Position = new Pos2(0, 0); }
void Update() { if (Application.targetFrameRate != TargetFrame) { Application.targetFrameRate = TargetFrame; } if (target && GameUi.GameScr == GameUi.Scr.ShopScr) //&& UiManager.Screen == UiManager.GameScreen.CameraViewScr { if (Input.GetMouseButtonDown(0)) { Pos1 = Input.mousePosition; Pos1.z = Camera.main.farClipPlane; Pos1 = Camera.main.ScreenToWorldPoint(Pos1); Pos1.Normalize(); //Debug.Log (" GetMouseButtonDown "+Pos1); // velocityX += xSpeed * Input.GetAxis("Mouse X") * 0.02f; // velocityY += ySpeed * Input.GetAxis("Mouse Y") * 0.02f; } if (Input.GetMouseButton(0)) { Pos2 = Input.mousePosition; Pos2.z = Camera.main.farClipPlane; Pos2 = Camera.main.ScreenToWorldPoint(Pos2); Pos2.Normalize(); float dis = Vector2.Distance(Pos2, Pos1) * 3f * Time.deltaTime; velocityX += xSpeed * Input.GetAxis("Mouse X") * dis; velocityY += ySpeed * Input.GetAxis("Mouse Y") * dis; //Debug.Log(" GetMouseButton "+Pos2); } if (Input.GetMouseButtonUp(0)) { } // if (Input.touchCount>0 &&(Input.GetTouch(0).phase == TouchPhase.Began|| Input.GetTouch(0).phase == TouchPhase.Moved)) //Input.touchCount == 1 && // { // //One finger touch does orbit // touch = Input.GetTouch(0); // velocityX += xSpeed * touch.deltaPosition.x * 0.02f; // velocityY += ySpeed * touch.deltaPosition.y * 0.02f; // } rotationYAxis += velocityX; rotationXAxis -= velocityY; rotationXAxis = ClampAngle(rotationXAxis, yMinLimit, yMaxLimit); Quaternion toRotation = Quaternion.Euler(rotationXAxis, rotationYAxis, 0); Quaternion rotation = toRotation; distance = Mathf.Clamp(distance, distanceMin, distanceMax); Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance); Vector3 position = rotation * negDistance + target.position; transform.rotation = rotation; transform.position = position; //transform.position = Vector3.Lerp (transform.position,position, Time.deltaTime * smoothTime);// position; //transform.rotation = Quaternion.Lerp(transform.rotation,rotation,Time.deltaTime*smoothTime); //transform.rotation = Quaternion.Euler (0,transform.eulerAngles.y,transform.eulerAngles.z); velocityX = Mathf.Lerp(velocityX, 0, Time.deltaTime * smoothTime); velocityY = Mathf.Lerp(velocityY, 0, Time.deltaTime * smoothTime); } else { } }
public void ChangePos(Pos2 posData) { Vector3 pos = self.transform.position; pos = new Vector3(posData.x, pos.y, posData.y); //TODO需要限制不掉出桌面的条件 //if (pos.x > maxLeft) //{ // pos = new Vector3(maxLeft, pos.y, pos.z); //} //if (pos.x < maxRight) //{ // pos = new Vector3(maxRight, pos.y, pos.z); //} if (SetupController.Instance.sceneObject.goodLegs.Count > 0) { SetupController.Instance.sceneObject.goodLegs[0].parent.SetParent(self.transform); } self.transform.SetPositionAndRotation(pos, self.rotation); if (SetupController.Instance.sceneObject.goodLegs.Count > 0) { SetupController.Instance.sceneObject.goodLegs[0].parent.SetParent(null); } good.pos = pos.x; }
protected override void Write(NWriter wtr) { wtr.Write((byte)EffectType); wtr.Write(TargetObjectId); Pos1.Write(wtr); Pos2.Write(wtr); Color.Write(wtr); }
public bool Yequals(Pos2 pos) { if (Y == pos.Y) { return(true); } return(false); }
public bool Xequals(Pos2 pos) { if (X == pos.X) { return(true); } return(false); }
public GoodData() { goodSize = new Size(SceneSizeOptions.Good.length, SceneSizeOptions.Good.width, SceneSizeOptions.Good.heigth); legHeigth = SceneSizeOptions.GoodLegHeigth; COF = 1.0f; mass = 10.0f; goodPos = new Pos2(); }
public bool Equals(Pos2 pos) { if (X == pos.X) { if (Y == pos.Y) { return(true); } } return(false); }
public void RemoveEmptyPos(Pos2 pos) { int count = EmptyPos.Count; for (int i = 0; i < count; i++) { if (EmptyPos[i].Equals(pos)) { EmptyPos.RemoveAt(i); return; } } }
internal List <Consprite> AABBCull() { Pos2 topLeft = new Pos2(0, 0); Pos2 bottomRight = new Pos2(camera.width, camera.height); topLeft = camera.ScreenToWorld(topLeft); bottomRight = camera.ScreenToWorld(bottomRight); Rect worldSpace = new Rect(topLeft, bottomRight); var list = new List <Consprite>(); list.AddRange(sprites.Where(x => x.WithinRectangle(worldSpace))); return(list); }
public bool Equals(Quest q) { if (q is null) { return(false); } if (ReferenceEquals(this, q)) { return(true); } return(QuestType.Equals(q.QuestType) && Players.SequenceEqual(q.Players) && Pos1.Equals(q.Pos1) && Pos2.Equals(q.Pos2) && QuestTime.Equals(q.QuestTime) && QuestText.Equals(q.QuestText) && Stage.Equals(q.Stage)); }
public void AddEmptyPos(Pos2 pos) { bool ishave = false; int count = EmptyPos.Count; for (int i = 0; i < count; i++) { if (EmptyPos[i].Equals(pos)) { ishave = true; } } if (!ishave) { EmptyPos.Add(new Pos2(pos)); } }
private void moveToUP(UINumber forwardNum) { if (forwardNum == null || CurPos.X != forwardNum.CurPos.X) { GotoPos = new Pos2(CurPos.X, 0); return; } if (GameData.CanMerge(CurNumber, forwardNum.CurNumber) && forwardNum.MergeNumber == 0) { GotoPos = new Pos2(forwardNum.GotoPos); MergeNumber = GameData.GetMerge(CurNumber, forwardNum.CurNumber); return; } else { GotoPos = new Pos2(CurPos.X, forwardNum.GotoPos.Y + 1); return; } }
private void moveToRight(UINumber forwardNum) { if (forwardNum == null || CurPos.Y != forwardNum.CurPos.Y) { GotoPos = new Pos2(GameData.MapSize - 1, CurPos.Y); return; } if (GameData.CanMerge(CurNumber, forwardNum.CurNumber) && forwardNum.MergeNumber == 0) { GotoPos = new Pos2(forwardNum.GotoPos); MergeNumber = GameData.GetMerge(CurNumber, forwardNum.CurNumber); return; } else { GotoPos = new Pos2(forwardNum.GotoPos.X - 1, GotoPos.Y); return; } }
private IEnumerator Moving(UINumber forwardNumber) { if (GotoPos.Equals(CurPos)) { yield break; } //Debug.Log("GotoPos=" + GotoPos.ToString()); Vector3 positon = GameData.MapPos[GotoPos.X, GotoPos.Y]; float time = GameData.MoveTime; Vector3 normal = positon - SelfTF.localPosition; Vector3 Speed = normal / time; while (time > 0) { SelfTF.Translate(Speed * Time.deltaTime, Space.Self); yield return(new WaitForEndOfFrame()); time -= Time.deltaTime; if (time < Time.deltaTime) { break; } } SelfTF.localPosition = positon; if (MergeNumber > 0) { SetNumber(MergeNumber); Father.OnMapNumbers.Remove(forwardNumber); Father.InHandNumbers.Add(forwardNumber); forwardNumber.SetNumber(0); //Debug.Log("OnMapNumbers=" + Father.OnMapNumbers.Count + " InHandNumbers=" + Father.InHandNumbers.Count); Father.CurMergeScore += MergeNumber; if (Father.CurMergeMaxNumber < MergeNumber) { Father.CurMergeMaxNumber = MergeNumber; } } CurPos = new Pos2(GotoPos); }
public bool ShowNextNumber() { if (OnMapNumbers.Count < GameData.MapSize * GameData.MapSize) { UINumber nextNumber = InHandNumbers[0]; InHandNumbers.Remove(nextNumber); OnMapNumbers.Add(nextNumber); if (Random.Range(0f, 100f) < 90f) { nextNumber.SetNumber(GameData.MinNum, true); } else { nextNumber.SetNumber(GameData.SecondMinNum, true); } Pos2 pos = EmptyPos[Random.Range(0, EmptyPos.Count)]; nextNumber.SetPos(pos); RemoveEmptyPos(pos); return(true); } return(false); }
public void SetPos(Pos2 pos) { CurPos = new Pos2(pos); GotoPos = new Pos2(pos); SelfTF.localPosition = GameData.MapPos[pos.X, pos.Y]; }
public IDiagram MovedBy(int x, int y) { return(new Triangle(Pos0.MovedBy(x, y), Pos1.MovedBy(x, y), Pos2.MovedBy(x, y))); }
internal Pos2 ScreenToWorld(Pos2 screenLocation) => screenLocation / zoom + location;
public void generateMaze() { ArrayList walls = new ArrayList(); reset(); if (!startingSet) { startingCell = selectStartingCell(Height, Width); } maze [startingCell.x, startingCell.y].visited = true; maze [startingCell.x, startingCell.y].type = Cell.Types.Center; walls = addWalls(startingCell.x, startingCell.y, walls); while (walls.Count != 0) { Pos3 wall = (Pos3)walls[Mathf.FloorToInt(Random.Range(0, walls.Count))]; if ((wall.z == (int)Directions.Up && wall.x == 0) || (wall.z == (int)Directions.Down && wall.x == Height - 1) || (wall.z == (int)Directions.Left && wall.y == 0) || (wall.z == (int)Directions.Right && wall.y == Width - 1) || (wall.z == (int)Directions.Right && maze[wall.x, wall.y + 1].visited) || (wall.z == (int)Directions.Left && maze[wall.x, wall.y - 1].visited) || (wall.z == (int)Directions.Up && maze[wall.x - 1, wall.y].visited) || (wall.z == (int)Directions.Down && maze[wall.x + 1, wall.y].visited)) { walls.Remove(wall); } else { if (wall.z == (int)Directions.Right) { maze[wall.x, wall.y + 1].visited = true; maze[wall.x, wall.y + 1].left = true; maze[wall.x, wall.y].right = true; walls = addWalls(wall.x, wall.y + 1, walls); } else if (wall.z == (int)Directions.Left) { maze[wall.x, wall.y - 1].visited = true; maze[wall.x, wall.y - 1].right = true; maze[wall.x, wall.y].left = true; walls = addWalls(wall.x, wall.y - 1, walls); } else if (wall.z == (int)Directions.Up) { maze[wall.x - 1, wall.y].visited = true; maze[wall.x - 1, wall.y].down = true; maze[wall.x, wall.y].up = true; walls = addWalls(wall.x - 1, wall.y, walls); } else if (wall.z == (int)Directions.Down) { maze[wall.x + 1, wall.y].visited = true; maze[wall.x + 1, wall.y].up = true; maze[wall.x, wall.y].down = true; walls = addWalls(wall.x + 1, wall.y, walls); } walls.Remove(wall); } } }
/* -- Área para el método que utiliza los datos proporcionados por Kinect -- */ /// <summary> /// Método que realiza las manipulaciones necesarias sobre el Skeleton trazado /// </summary> private void usarSkeleton(Skeleton skeleton) { Joint joint1 = skeleton.Joints[JointType.HandRight]; ///////////// Joint joint2 = skeleton.Joints[JointType.HandLeft]; //////////// //////////// Joint joint3 = skeleton.Joints[JointType.Head]; //////////// //////////// Joint joint4 = skeleton.Joints[JointType.KneeRight]; //////////// //////////// Joint joint5 = skeleton.Joints[JointType.KneeLeft]; //////////// //////////// Joint joint6 = skeleton.Joints[JointType.FootRight]; //////////// //////////// Joint joint7 = skeleton.Joints[JointType.FootLeft]; //////////// // Si el Joint está listo obtener las coordenadas if (joint1.TrackingState == JointTrackingState.Tracked) { // Obtiene las coordenadas (x, y) del Joint joint_Point = this.SkeletonPointToScreen(joint1.Position); dMano_X = joint_Point.X; dMano_Y = joint_Point.Y; //Emplea las coordenadas del Joint para mover la elipse Puntero.SetValue(Canvas.TopProperty, dMano_Y + 35); Puntero.SetValue(Canvas.LeftProperty, dMano_X + 30); // Obtiene el Id de la persona mapeada LID.Content = skeleton.TrackingId; } //////////////// if (joint2.TrackingState == JointTrackingState.Tracked) { // Obtiene las coordenadas (x, y) del Joint joint_Point = this.SkeletonPointToScreen(joint2.Position); iMano_X = joint_Point.X; iMano_Y = joint_Point.Y; //Emplea las coordenadas del Joint para mover la elipse Puntero1.SetValue(Canvas.TopProperty, iMano_Y + 35); Puntero1.SetValue(Canvas.LeftProperty, iMano_X + 30); // Obtiene el Id de la persona mapeada LID.Content = skeleton.TrackingId; } //////////////////////////// if (joint3.TrackingState == JointTrackingState.Tracked) { // Obtiene las coordenadas (x, y) del Joint joint_Point = this.SkeletonPointToScreen(joint3.Position); Cabeza_X = joint_Point.X; Cabeza_Y = joint_Point.Y; //Emplea las coordenadas del Joint para mover la elipse Puntero3.SetValue(Canvas.TopProperty, Cabeza_Y + 35); Puntero3.SetValue(Canvas.LeftProperty, Cabeza_X + 30); // Obtiene el Id de la persona mapeada LID.Content = skeleton.TrackingId; } //////////////////////////// // Si el Joint está listo obtener las coordenadas if (joint4.TrackingState == JointTrackingState.Tracked) { // Obtiene las coordenadas (x, y) del Joint joint_Point = this.SkeletonPointToScreen(joint4.Position); dRodilla_X = joint_Point.X; dRodilla_Y = joint_Point.Y; //Emplea las coordenadas del Joint para mover la elipse Puntero4.SetValue(Canvas.TopProperty, dRodilla_Y + 35); Puntero4.SetValue(Canvas.LeftProperty, dRodilla_X + 30); // Obtiene el Id de la persona mapeada LID.Content = skeleton.TrackingId; } //////////////// // Si el Joint está listo obtener las coordenadas if (joint5.TrackingState == JointTrackingState.Tracked) { // Obtiene las coordenadas (x, y) del Joint joint_Point = this.SkeletonPointToScreen(joint5.Position); iRodilla_X = joint_Point.X; iRodilla_Y = joint_Point.Y; //Emplea las coordenadas del Joint para mover la elipse Puntero5.SetValue(Canvas.TopProperty, iRodilla_Y + 35); Puntero5.SetValue(Canvas.LeftProperty, iRodilla_X + 30); // Obtiene el Id de la persona mapeada LID.Content = skeleton.TrackingId; } //////////////// // Si el Joint está listo obtener las coordenadas if (joint6.TrackingState == JointTrackingState.Tracked) { // Obtiene las coordenadas (x, y) del Joint joint_Point = this.SkeletonPointToScreen(joint6.Position); dPie_X = joint_Point.X; dPie_Y = joint_Point.Y; //Emplea las coordenadas del Joint para mover la elipse Puntero6.SetValue(Canvas.TopProperty, dPie_Y + 35); Puntero6.SetValue(Canvas.LeftProperty, dPie_X + 30); // Obtiene el Id de la persona mapeada LID.Content = skeleton.TrackingId; } //////////////// // Si el Joint está listo obtener las coordenadas if (joint7.TrackingState == JointTrackingState.Tracked) { // Obtiene las coordenadas (x, y) del Joint joint_Point = this.SkeletonPointToScreen(joint7.Position); iPie_X = joint_Point.X; iPie_Y = joint_Point.Y; //Emplea las coordenadas del Joint para mover la elipse Puntero7.SetValue(Canvas.TopProperty, iPie_Y + 35); Puntero7.SetValue(Canvas.LeftProperty, iPie_X + 30); // Obtiene el Id de la persona mapeada LID.Content = skeleton.TrackingId; } //////////////// if (Posicion() && Pase) { EscPunte(true); Bandera.Fill = Brushes.Green; MainCanvas.Background = Brushes.Transparent; Pos1.Height = 200; Pos1.SetValue(Canvas.TopProperty, 325.0); Pos1.SetValue(Canvas.LeftProperty, 600.0); timer.IsEnabled = true; puntos++; } else if (Pase) { Bandera.Fill = Brushes.Red; } else if (Pase1) { EscPunte(false); Bandera.Fill = Brushes.Red; MainCanvas.Background = Brushes.White; Pos1.Visibility = Visibility.Hidden; Pos2.Visibility = Visibility.Visible; Progreso.Value = 0.0; Progreso.Visibility = Visibility.Hidden; Pase1 = false; } else if (Posicion1() && Pase2) { EscPunte(true); Bandera.Fill = Brushes.Green; MainCanvas.Background = Brushes.Transparent; Pos2.Height = 200; Pos2.SetValue(Canvas.TopProperty, 325.0); Pos2.SetValue(Canvas.LeftProperty, 425.0); timer2.IsEnabled = true; puntos++; } else if (Pase2) { Bandera.Fill = Brushes.Red; } else { EscPunte(false); Bandera.Fill = Brushes.Black; MainCanvas.Background = Brushes.Black; Pos2.Visibility = Visibility.Hidden; Progreso1.Visibility = Visibility.Hidden; Puntuacion.Content = "Tu puntuacion es: " + puntos.ToString(); } }
public static FarmLocation GetBestLaserFarmLocation(bool jungle) { var bestEndPos = new Vector2(); var bestStartPos = new Vector2(); var mMinionCount = 0; List <Obj_AI_Base> AllMinions; if (!jungle) { AllMinions = MinionManager.GetMinions(EMaxRange); } else { AllMinions = MinionManager.GetMinions(EMaxRange, MinionTypes.All, MinionTeam.Neutral); } var mMinionsList = (from minions in AllMinions select minions.Position.To2D()).ToList <Vector2>(); var possiblePosition = new List <Vector2>(); possiblePosition.AddRange(mMinionsList); var Max = possiblePosition.Count; for (var i = 0; i < Max; i++) { for (var j = 0; j < Max; j++) { if (possiblePosition[j] != possiblePosition[i]) { possiblePosition.Add((possiblePosition[j] + possiblePosition[i]) / 2); } } } foreach (var StartPositionMinion in AllMinions.Where(m => Utilities.Player.Distance(m) < ERange)) { var StartPos = StartPositionMinion.Position.To2D(); foreach (var Pos in possiblePosition) { if (Pos.Distance(StartPos, true) <= LenghtE * LenghtE) { var EndPos = StartPos + LenghtE * (Pos - StartPos).Normalized(); var count = mMinionsList.Count(Pos2 => Pos2.Distance(StartPos, EndPos, true, true) <= 140 * 140); if (count >= mMinionCount) { bestEndPos = EndPos; mMinionCount = count; bestStartPos = StartPos; } } } } if ((!jungle && Utilities.SliderValue("e.clear.minhit") < mMinionCount) || (jungle && mMinionCount > 0)) { return(new FarmLocation(bestStartPos, bestEndPos, mMinionCount)); } else { return(new FarmLocation(bestStartPos, bestEndPos, 0)); } } // Algorithm by Trus. Congratz bro
internal Camera(Pos2 position) : this() { location = position; }
internal Camera(Pos2 position, int zoom) : this(position) { this.zoom = zoom; }
// constructor public Move(Pos2 _src, Pos2 _dst) { src = new Pos2(_src); dst = new Pos2(_dst); }
internal Pos2 WorldToScreen(Pos2 worldLocation) => (worldLocation - location) * zoom;
public void setStartingCell(Pos2 pos) { startingCell = pos; startingSet = true; }
public void MoveBy(int x, int y) { Pos0 = Pos0.MovedBy(x, y); Pos1 = Pos1.MovedBy(x, y); Pos2 = Pos2.MovedBy(x, y); }
public void ChangeGoodPos(Pos2 pos) { goodView.ChangePos(pos); }
internal Camera(Pos2 position, int width, int height, int zoom) : this(position, zoom) { this.width = width; this.height = height; }