/// <summary> /// Add Current hit point but first needs to move it away from buiding /// </summary> void AddCurrentHit() { Dir[] dirsSimpleMap = new Dir[] { Dir.N, Dir.E, Dir.S, Dir.W }; float moveBy = _person.PersonDim * 2; Vector3[] moveAway = new Vector3[] { new Vector3(0, 0, moveBy), new Vector3(moveBy, 0, 0), new Vector3(0, 0, -moveBy), new Vector3(-moveBy, 0, 0) }; Dir buildWasHitOn = UDir.TellMeWhenHitLanded(currBuilding.Anchors, vectorHit.HitPoint); //is needed here so it moves foward along the side and not to the cloeset that coluld be accross the biuilding Vector3 otherAnchorOnSide = UPoly.FindOtherCornerOnSide(currBuilding.Anchors, buildWasHitOn, closestAnchorToOrigin); var sideAnchors = ReturnFirstAndLast(_fin, otherAnchorOnSide, closestAnchorToOrigin); anchorOnSideClosestToFin = sideAnchors[0];//the anchor on the side is closer to _fin for (int i = 0; i < dirsSimpleMap.Length; i++) { if (dirsSimpleMap[i] == buildWasHitOn) { //is moving the vector hit away given the direction Vector3 t = vectorHit.HitPoint + moveAway[i]; t.y = m.IniTerr.MathCenter.y;//so is on same Y value t = Sanitize(t); //_person.DebugList.Add(UVisHelp.CreateText(t, hitCurrentAdded.ToString())); _checkPoints.Add(new CheckPoint(t)); return; } } }
/// <summary> /// Defined a 3d rectangle with current selection: onScreenPoly. Defines firstCorner and secondCorner too, /// _dir too /// </summary> /// <returns></returns> public void CreateWay() { //print("1st way p." + _firstWayPoint); //print("2st way p corn." + _secondWayPoint); if (firstCorner == new Vector2()) { firstCorner = new Vector2(UInput.TransformedMPos.x, UInput.TransformedMPos.y); _firstWayPoint = ClosestSubMeshVert; } else if (firstCorner != new Vector2()) { secondCorner = new Vector2(UInput.TransformedMPos.x, UInput.TransformedMPos.y); _secondWayPoint = UPoly.RayCastTerrain(secondCorner).point; _secondWayPoint = m.Vertex.FindClosestVertex(_secondWayPoint, m.CurrentHoverVertices.ToArray()); //direction was dragged on terrain _dir = UDir.ReturnDragDir(_firstWayPoint, _secondWayPoint); onScreenPoly = UPoly.RetTerrainPoly(_firstWayPoint, _secondWayPoint, _dir); } }
/// <summary> /// Define current vector3 list . that is the one we try to eat on terrain /// </summary> private void DefineCurrentVector3s() { //will find te sign where to go base on direction Vector3 sign = UDir.FromDirToVector3(_direction); var xSign = sign.x; var zSign = sign.z; for (int i = 0; i < _currRow.Count; i++) { var rowIniDot = _currRow[i]; for (int j = 0; j < _stepFurther; j++) { //will move the initial row point towards the sign and times the size of the tile rowIniDot += new Vector3((_xTile * xSign), 0, (_zTile * zSign)); _currVector3s.Add(rowIniDot); } } var t = this; //DebugHere(); }
/// <summary> /// this is the cutter action will fill up the toMineSelectList depending if we adding or removing items to cut/mine /// </summary> private void Cutter() { if (BuildingPot.InputMode == Mode.Cutting) { print("Ready to Mine Stuff"); if (Input.GetMouseButtonDown(0) && firstCorner == new Vector2()) { ToMineSelectList.Clear(); firstCorner = new Vector2(UInput.TransformedMPos.x, UInput.TransformedMPos.y); } else if (Input.GetMouseButton(0) && firstCorner != new Vector2()) { secondCorner = new Vector2(UInput.TransformedMPos.x, UInput.TransformedMPos.y); selectionDimRect = UDir.ReturnDragRect(firstCorner, secondCorner); } else if (Input.GetMouseButtonUp(0) && firstCorner != new Vector2()) { ToMineSelectList = ReturnListOfSpecificObj(BuildingPot.DoingNow); firstCorner = new Vector2(); secondCorner = new Vector2(); selectionDimRect = new Rect(); } } }