public static bool UpdateLine(char objType, int i, int j, int k) { GameObject drawnLine = null; if (objType == 'X') { drawnLine = MainGameScript.Grid_LinesX[i, j, k]; } else if (objType == 'Y') { drawnLine = MainGameScript.Grid_LinesY[i, j, k]; } else if (objType == 'Z') { drawnLine = MainGameScript.Grid_LinesZ[i, j, k]; } if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false) { LineScript.Draw(objType, i, j, k); return(true); } else { return(false); } }
void Start() { spriteRenderer = gameObject.GetComponent <SpriteRenderer>(); Line = GameObject.Find("LineHolder"); lineScript = Line.GetComponent <LineScript>(); squares = GameObject.Find("Squares"); squareScript = squares.GetComponent <Game>(); circle = Resources.Load <Sprite>("Sprites/Circle2"); deadCircle = Resources.Load <Sprite>("Sprites/Deadcircle"); setColor = lineScript.setColor; if (loadColors) { colorNum = Manager.circleList[num]; lineScript.AddToCircleList(num, colorNum); spriteRenderer.color = setColor[colorNum]; Color color = spriteRenderer.color; color.a = 0.5f; spriteRenderer.color = color; } else { NewColor(); } SetSprite(); }
private float timeLastTurnEnded; //what time did the last turn end? // Use this for initialization void Start() { //get the GameRules and the LineScript gameRules = gameObject.GetComponent <GameRulesScript> (); line = gameObject.GetComponent <LineScript> (); //link the scripts ballScriptR1 = ballR1.GetComponent <BallScript> (); ballScriptR2 = ballR2.GetComponent <BallScript> (); ballScriptB1 = ballB1.GetComponent <BallScript> (); ballScriptB2 = ballB2.GetComponent <BallScript> (); //set default values for LastRed and LastBlue ball gameRules.LastRedBall = ballR1; gameRules.LastBlueBall = ballB1; //get a starting position for the mouse cursor Vector3 posInScreen = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10); posInWorld = Camera.main.ScreenToWorldPoint(posInScreen); //set up some other things ballsMoving = false; hitBuilding = true; }
static public void Redo(GameObject _gO) { m_undoPos++; UndoItem uItem = m_undoObjects[m_undoPos - 1]; _gO = uItem.GetObj(); if (_gO.GetComponent <Rigidbody>() == null) { if (_gO.activeSelf) { _gO.SetActive(false); } else { _gO.SetActive(true); } return; } Vector2 temp = _gO.transform.position; _gO.transform.SetPositionAndRotation(new Vector3(uItem.GetPos().x, uItem.GetPos().y, 0), Quaternion.identity); uItem.SetPos(temp); if (_gO.layer == LayerMask.NameToLayer("Path")) { LineScript.ModifyLine(_gO); } }
private IEnumerator DragObject() { while (Input.GetMouseButton(0)) { // Position on the near clipping plane of the camera in world space Vector3 newMousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0)); // Position relative to the eye-point of the camera newMousePos -= Camera.main.transform.position; if (Input.GetKey(KeyCode.LeftShift) && m_object.layer != LayerMask.NameToLayer("Path")) { float cellWidth = m_grid.transform.GetComponent <SpriteRenderer>().bounds.size.x / 20.2f; float cellHeight = m_grid.transform.GetComponent <SpriteRenderer>().bounds.size.y / 20.2f; float newX = Mathf.Round((Mathf.Abs(m_grid.GetComponent <SpriteRenderer>().bounds.min.x) + newMousePos.x) / cellWidth); newX = m_grid.GetComponent <SpriteRenderer>().bounds.min.x + 0.05f + (newX * cellWidth); float newY = Mathf.Round((Mathf.Abs(m_grid.GetComponent <SpriteRenderer>().bounds.min.y) + newMousePos.y) / cellHeight); newY = m_grid.GetComponent <SpriteRenderer>().bounds.min.y + (newY * cellHeight); m_object.transform.position = new Vector3(newX, newY, 0); m_curMousePos = new Vector2(newX, newY); } else { if (m_object.name == "Arrow Collider") { m_object = LineScript.GetCurrentLine().GetComponentsInChildren <SphereCollider>()[0].gameObject; } else if (m_object.name == "Line") { m_object = LineScript.GetCurrentLine(); } float diffX = m_lastMouse.x - m_curMousePos.x; float diffY = m_lastMouse.y - m_curMousePos.y; Debug.Log(diffX + "\n" + diffY); //Vector3 oldPos = m_object.transform.position; //m_object.transform.position = new Vector3(m_curMousePos.x, m_curMousePos.y, 0); m_object.transform.SetPositionAndRotation(new Vector3(m_object.transform.position.x - diffX, m_object.transform.position.y - diffY, m_object.transform.position.z), Quaternion.identity); //Transform g = GameObject.Find("Guard L").transform; //float xAdded = oldPos.x - m_object.transform.position.x; //g.SetPositionAndRotation(new Vector3(g.position.x - xAdded, g.position.y - (oldPos.y - m_object.transform.position.y)), Quaternion.identity); m_curMousePos = newMousePos; if (m_object.layer == LayerMask.NameToLayer("Path")) { LineScript.ModifyLine(m_object); } else { LineScript.SetCurrentLine(null); } } yield return(0); } m_object = null; }
private void DeleteObject() { GameObject curLine = LineScript.GetCurrentLine(); curLine.SetActive(false); UndoScript.AddToUndo(curLine); }
public void BringUpMenu(LineScript _ls) { lineScript = _ls; if (isUp) StartCoroutine (MenuClose()); else StartCoroutine (MenuOpen()); }
public void ReadLine(LineScript ls) { if (ls) { if (reader != null) { StopCoroutine(reader); } reader = StartCoroutine(read(ls)); } }
public void refresh() { hook = GameManager.instance.hook; player = GameManager.instance.player; lineLengthBar = UIGameManager.instance.lineLengthBar.GetComponent <Slider>(); lineLengthBar.value = lineLengthBar.maxValue / 2; FishData fishData = GameManager.instance.GetFishDataById(GameManager.instance.currentSpawnedFish.id); UIGameManager.instance.lineLengthBar.gameObject.SetActive(true); fillBarSpeed = ((lineLengthBar.maxValue / 10) * fillBarSpeedModifier) * fishData.fillBarModifier; unfillBarSpeed = ((lineLengthBar.maxValue / 10) * unfillBarSpeedModifier) * fishData.unfillBarModifier; }
// Use this for initialization void Start() { timer = 0f; EventManager.StartListening("ENEMY_STUNNED", OnStun); EventManager.StartListening("ENEMY_UNSTUNNED", EndStun); EventManager.StartListening("SILENT_ACTIVATED", KeepThemSecrets); EventManager.StartListening("SILENT_DEACTIVATED", StartTalking); GameStatusScript = GameObject.Find("GameStatus").GetComponent <GameStatusScript>(); lineScript = GameObject.Find("PlayerSoundWave").GetComponent <LineScript>(); }
private void OnTriggerEnter(Collider other) { if (isErasing) { if (other.gameObject.tag == "Line") { LineScript line = other.GetComponent <LineScript>(); DataLogger.Instance.LogActionData(this, line.OriginalOwner, line.photonView.Owner, "Line erased", line.ID); PhotonNetwork.Destroy(other.gameObject); VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(interactableObject.GetGrabbingObject()), 0.3f); } } }
public void Draw(Vector3 drawPosition) { if (TraceLines.Keys.Count == 0) { LineScript line = new LineScript(TraceLineSettings); TraceLines.Add(lineIndex, line); line.AddNewLineRenderer(this.transform, drawPosition, anchor); } else { //DebugManager.Instance.LogInfo($"{drawPosition}"); TraceLines[0].AddPoint(drawPosition); } OnDraw?.Invoke(); }
public void BringUpMenu(LineScript _ls) { lineScript = _ls; if (isUp) { // lineScript.gameObject.GetComponent<Collider> ().enabled = true; // lineScript.enabled = true; StartCoroutine (MenuClose()); } else { // lineScript.enabled = false; // lineScript.gameObject.GetComponent<Collider> ().enabled = false; StartCoroutine (MenuOpen()); } }
static public void AddToUndo(GameObject _gO, Vector2 _mousePos) { for (int i = 0; i < m_undoObjects.Count - m_undoPos; i++) { GameObject gO = m_undoObjects[m_undoObjects.Count - 1].GetObj(); if (gO.layer == LayerMask.NameToLayer("Path")) { LineScript.AddToPathPool(gO); } m_undoObjects.RemoveAt(m_undoObjects.Count - 1); } m_undoPos++; UndoItem uItem = new UndoItem(_gO, _gO.transform.position); m_undoObjects.Add(uItem); }
//public bool DeleteTie(NailScript connectedTo) //{ // LineScript temp = null; // if (extremeOfLine == LineScript.Extremes.B) // temp = tiedLine.Find(x => x.pointA == connectedTo); // else if (extremeOfLine == LineScript.Extremes.A) // temp = tiedLine.Find(x => x.pointB == connectedTo); // if (temp != null) // { // if (thisNailRole == Role.Father) // { // FamilyManager.instance.RemoveOffspringFromID(connectedTo.parentWindow.assignedMemberID, this.parentWindow.assignedMemberID); // } // else if (thisNailRole == Role.Mother) // { // FamilyManager.instance.RemoveOffspringFromID(connectedTo.parentWindow.assignedMemberID, this.parentWindow.assignedMemberID); // } // else if (thisNailRole == Role.Offspring) // { // if (this.parentWindow.assignedMember.sex == Gender.Female) // { // connectedTo.parentWindow.assignedMember.motherID = -1; // } // else // { // connectedTo.parentWindow.assignedMember.fatherID = -1; // } // } // if (tiedLine.Contains(temp)) // tiedLine.Remove(temp); // temp.DeleteLine(); // return true; // } // else // { // return false; // } //} public void DeleteConnection(int toID, LineScript andLine) { tiedLine.Remove(andLine); if (thisNailRole == Role.Father) { FamilyManager.instance.RemoveFatherFromID(parentWindow.assignedMemberID); } else if (thisNailRole == Role.Mother) { FamilyManager.instance.RemoveMotherFromID(parentWindow.assignedMemberID); } else if (thisNailRole == Role.Offspring) { FamilyManager.instance.RemoveOffspringFromID(parentWindow.assignedMemberID, toID); } }
public override void HandleOnCollisionEnter2D(Collision2D other) { Ball otherBall = other.gameObject.GetComponent <Ball>(); LineScript line = other.gameObject.GetComponent <LineScript>(); AudioSource = GameObject.Find("VirusNormal"); source = AudioSource.GetComponent <AudioSource>(); if (otherBall != null) { bool isCureBallHit = otherBall.ballType == BallType.CURE; if (isCureBallHit && !ball.isOriginalVirus) { TransformsToNormalBall(); source.Play(); } } }
// Update is called once per frame public void InitiateCut(LineScript lineScript) // Called From LineScript on LineComplete { if (!cutComplete) // Checking if Already cut in this session { Transform cutplane; Vector3 pointA, pointB, pointC; Plane myplane; pointA = lineScript.lineRenderer.GetPosition(0); pointB = lineScript.lineRenderer.GetPosition(1); pointC = pointA + (Camera.main.transform.forward * -10); // Third point to get plane from line drawn myplane = new Plane(pointA, pointB, pointC); // Creating plane from lin points plus 3rd point Vector3 dir = (pointB - pointA).normalized; Vector3 point = pointA + (0.5f * dir); cutComplete = MeshCut.Cut(gameObject, point, myplane.normal); // Calling MeshCut , will return true if line/plane intersects mesh } }
public void SetTiedLine(LineScript to, NailScript otherExtreme) { if (otherExtreme != null) { UpdateConnection(to, otherExtreme); } //else //{ // switch(thisNailRole) // { // case Role.Father: // parentWindow.assignedMember.fatherID = -1; // break; // case Role.Mother: // parentWindow.assignedMember.motherID = -1; // break; // } //} }
private void LogAnnotationData(string timestamp) { if (isLogging && annotationsStreamWriter != null) { foreach (GameObject line in GameObject.FindGameObjectsWithTag("Line")) { LineScript lineScript = line.GetComponent <LineScript>(); Chart parent = line.GetComponentInParent <Chart>(); annotationsStreamWriter.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", timestamp, photonToParticipantDictionary[lineScript.OriginalOwner.ActorNumber], photonToParticipantDictionary[lineScript.photonView.OwnerActorNr], lineScript.GetLinePositions(), (parent != null) ? parent.ID : "" ); } } }
static public void AddToUndo(GameObject _gO) { int numOverUndo = m_undoObjects.Count - m_undoPos; for (int i = 0; i < numOverUndo; i++) { GameObject gO = m_undoObjects[m_undoObjects.Count - 1].GetObj(); if (gO.layer == LayerMask.NameToLayer("Path")) { LineScript.AddToPathPool(gO); } m_undoObjects.RemoveAt(m_undoObjects.Count - 1); } m_undoPos++; UndoItem uItem = new UndoItem(_gO); m_undoObjects.Add(uItem); }
// Use this for initialization void Start() { UIGameManager.instance.mainCameraLocation = transform; hook = GameManager.instance.hook; player = GameManager.instance.player; GameManager.instance.fish = this; myRigidbody = GetComponent <Rigidbody2D>(); lineRenderer = hook.GetComponent <LineRenderer>(); if (GameManager.instance.fishDetect.gameObject.activeSelf) { GameManager.instance.fishDetect.gameObject.SetActive(false); } fishData = GameManager.instance.GetFishDataById(GameManager.instance.currentSpawnedFish.id); patterns = fishData.patterns; //==== Random Pattern ===== moveForce = fishData.moveForce; //based on the fish maxSpeed = fishData.maxSpeed; //based on the fish timeBetweenMove = fishData.timeBetweenMove; //based on the fish timeToMove = fishData.timeToMove; //based on the fish decelerateSpeed = fishData.decelerateSpeed; //based on the fish timeBetweenMoveCounter = Random.Range(timeBetweenMove * 0.75f, timeBetweenMove * 1.25f); //Randomizes a bit of the timer that the fish stops to move again timeToMoveCounter = Random.Range(timeToMove * 0.75f, timeBetweenMove * 1.25f); //Randomizes a bit of the timer that the fish keep moving //==== Circle Pattern ===== angle = 0; radius = fishData.radius; circleSpeed = fishData.circleSpeed; //==== Square Pattern ===== acceleration = 2.5f; deceleration = 5f; squarePatternReady = false; speed = 2f; //==== Overall ===== waypointAux = false; InvokeRepeating("changePattern", 3F, 3F); changePattern(); currentDrag = 0; color = new Color32(255, 255, 255, 255); }
// Use this for initialization void Start() { //get the car script component car = GetComponent <CarScript>(); //get line script component line = GameObject.FindGameObjectWithTag("Line").GetComponent <LineScript>(); //get the max velocity of the car maxCarVel = car.GetMaxVelocity(); //get the steering(acceleration) scale of the car steeringValue = car.GetSteeringScale(); //find the input and text objects in the scene and set them as variables here carPositionInputField = GameObject.FindGameObjectWithTag("FuzzyCarPositionInputField"); linePositionInputField = GameObject.FindGameObjectWithTag("FuzzyLinePositionInputField"); velocityInputField = GameObject.FindGameObjectWithTag("FuzzyVelocityInputField"); steeringText = GameObject.FindGameObjectWithTag("FuzzySteeringText").GetComponent <Text>(); }
private IEnumerator read(LineScript ls) { canvas.enabled = true; movement.enabled = false; float waittime = (ls.time == 0f)?2f:ls.time; bubble.text = ls.line; if (ls.clip) { waittime = ls.clip.length; audio.clip = ls.clip; audio.Play(); } yield return(new WaitForSeconds(waittime)); canvas.enabled = false; reader = null; movement.enabled = true; }
public bool DeleteTie(LineScript temp) { //NailScript connectedTo = null; //if (extremeOfLine == LineScript.Extremes.B) // connectedTo = temp.pointA; //else if (extremeOfLine == LineScript.Extremes.A) // connectedTo = temp.pointB; if (temp != null) { //tiedLine.Remove(temp); temp.DeleteLine(); return(true); } else { return(false); } }
private void Populate() { objectPool = new List <Element>(); linePool = new List <LineScript>(); foreach (ElementData ed in GameHandler.dataHandler.GetElementData(currentExpression)) { GameObject go = Instantiate(GameHandler.objectHandler.elements[(int)ed.type], panels); go.transform.localPosition = new Vector3(ed.positionX, ed.positionY, 0.0f); Element e = go.GetComponentInChildren <Element>(); e.SetData(objectPool.Count, this); ReLabel(e); objectPool.Add(e); } int currentElement = 0; foreach (ElementData ed in GameHandler.dataHandler.GetElementData(currentExpression)) { for (int i = 0; i < ed.inputs.Length; i++) { if (ed.inputs[i] != null) { // Add line // TODO - Make special line for bools GameObject go = Instantiate(GameHandler.objectHandler.line, lines); LineScript ls = go.GetComponent <LineScript>(); ls.SetConnect1(objectPool[currentElement].GetHandels()[i]); ls.SetConnect2(objectPool[GameHandler.dataHandler.GetElementInputDestinationIndex(currentExpression, currentElement, i)].GetHandleOut()); ls.SetPlaced(false); } } currentElement++; } }
/// <summary> /// 라인을 클릭했을 시 라인이 가지고 있던 유닛이 해당 라인에 소환이 됨 /// </summary> /// <param name="line">전투가 벌어지는 라인</param> public void SpawnUnit(LineScript line) { Debug.Log("Spawn"); newUnit.transform.SetParent(lineList[line.lineNumber].transform); if (playerNumber == 1) { newUnit.transform.localPosition = new Vector3(-650, -162.5f, 0); } else if (playerNumber == 2) { newUnit.transform.localPosition = new Vector3(650, -162.5f, 0); } unitSpawnButtonList[(int)newUnit.GetComponent <Unit>().getUnitType()].SettingData(); if (checkClocking) { clockingButton.SettingData(); } newUnit.SetActive(true); checkSpawnDoing = false; checkClocking = false; }
public void PinInteraction(NailScript pin) { if (!UI_Manager.editingInformation) { //if (currentInteraction == interactionMode.Tying) //{ if (currentStatus == pinInteractionStatus.None) { currentStatus = pinInteractionStatus.Dragging; currentLine = Instantiate(lineObject, this.transform).GetComponent <LineScript>(); currentLine.SetA(pin); currentLine.SetReady(); cancelButton.gameObject.SetActive(true); } else if (currentStatus == pinInteractionStatus.Dragging) { if (pin.CompatibleWithOtherExtreme(currentLine.pointA)) { currentStatus = pinInteractionStatus.None; if (currentLine != null) { currentLine.SetB(pin); } cancelButton.gameObject.SetActive(false); } } //} //else //{ // pin.DeleteAllTies(); //} } FamilyManager.instance.formulary.CloseFormulary(); }
// Use this for initialization void Start() { //get the car script component from the car car = GetComponent <CarScript>(); //get the line script component from the line line = GameObject.FindGameObjectWithTag("Line").GetComponent <LineScript>(); //get max velocity from the car script maxCarVel = car.GetMaxVelocity(); //get the steering scale(acceleration) from the car script steeringValue = car.GetSteeringScale(); //find the input field and text objects that we want to change in the scene and set the mas variables carPositionInputField = GameObject.FindGameObjectWithTag("RuleBasedCarPositionInputField"); linePositionInputField = GameObject.FindGameObjectWithTag("RuleBasedLinePositionInputField"); velocityInputField = GameObject.FindGameObjectWithTag("RuleBasedVelocityInputField"); steeringText = GameObject.FindGameObjectWithTag("RuleBasedSteeringText").GetComponent <Text>(); //set specific values for the rules to use //distance variable FarLeftDist = -1.5f; LeftDist = -0.025f; RightDist = 0.025f; FarRightDist = 1.5f; //velocity variable FastLeftVel = -0.75f * maxCarVel; LeftVel = -0.25f * maxCarVel; RightVel = 0.25f * maxCarVel; FastRightVel = 0.75f * maxCarVel; //steering output variables SteerHardLeft = -0.75f * steeringValue; SteerLeft = -0.5f * steeringValue; SteerRight = 0.5f * steeringValue; SteerHardRight = 0.75f * steeringValue; }
public void Enter() { if (otherHandle.Count > 0 && (handleType == HandleType.In || handleType == HandleType.BoolIn)) { } else { RectTransform trans = null; if (handleType == HandleType.BoolIn || handleType == HandleType.BoolOut) { trans = Instantiate(GameHandler.objectHandler.line, element.GetCallBack().lines).GetComponent <RectTransform>(); } else { trans = Instantiate(GameHandler.objectHandler.line, element.GetCallBack().lines).GetComponent <RectTransform>(); } trans.transform.position = transform.position; LineScript ls = trans.gameObject.GetComponent <LineScript>(); element.GetCallBack().currentDrawingLine = ls; ls.SetConnect1(this); } }
public void addRewardLoad() { LineScript load = lAllLine[checkpointline]; NewGame(load._blockHealth, load._saveScore, load._maxAmmo, load._crystalsForGame); }
void NewWave() { startPos.SetActive(true); startPosMain.transform.position = startPosNext.transform.position; startPosNext.SetActive(false); _first = true; GameObject newLine = RandomizeLine(); LineScript script = newLine.GetComponent <LineScript>(); LineScript copy = script; copy._blockHealth = _blockHealth; copy._crystalsForGame = _crystalsForGame; copy._maxAmmo = _maxAmmo; copy._saveScore = _score; lAllLine.Add(copy); GameObject obj; for (int i = 0; i < 7; i++) { Vector3 pos = Camera.main.ScreenToWorldPoint(_firstSpawnPosition); int id = script.blocksId[i]; if (id != 0) { obj = Instantiate(blocksPrefabs[id], canvas.transform); } else { obj = null; } if (obj != null) { if (obj.GetComponent <BlockScript>() != null) { BlockScript blockScript = obj.GetComponent <BlockScript>(); blockScript.setParram(_blockHealth, pos, _blockId, this, blockSizeX); blockScript.step = blockSizeX; blockScript.movePosition(); blockScript.SetSize(blockSizeX); lBlock.Add(blockScript); _blockId++; } else { BonusScript bonusScript = obj.GetComponent <BonusScript>(); bonusScript.setParram(this, _bonusId, pos, blockSizeX); bonusScript.step = blockSizeX; bonusScript.movePosition(); bonusScript.SetSize(blockSizeX); lBonus.Add(bonusScript); _bonusId++; } } _firstSpawnPosition.x += blockSizeX; //blockScript[i].setParram(_blockHealth, _blockId, this); //blockScript[i].step = blockSizeX; //blockScript[i].movePosition(); //blockScript[i].SetSize(blockSizeX); //lBlock.Add(blockScript[i]); //_blockId++; } //for(int i = 0; i < bonusScript.Length; i++) //{ // bonusScript[i].setParram(this,_bonusId); // bonusScript[i].step = blockSizeX; // bonusScript[i].movePosition(); // bonusScript[i].SetSize(blockSizeX); // lBonus.Add(bonusScript[i]); // _bonusId++; //} // MovePositionsBlocks(); _firstSpawnPosition.y = _firstSpawnY; _firstSpawnPosition.x = _firstSpawnX; lLine.Add(newLine); _canShoot = true; _blockHealth++; textScript.ammoCount.gameObject.SetActive(true); textScript.underLineAmmoText.SetActive(true); textScript.ammoCount.text = _maxAmmo.ToString(); textScript.score.text = Mathf.RoundToInt(_score).ToString(); textScript.BestScore.text = "Best- " + Mathf.RoundToInt(_bestScore).ToString(); }
void OnGUI() { if (lineScript == null) return; style.fontSize = CurrentFontSize; style.normal.textColor = guiColor; style.normal.background = buttonBG; GUI.color = guiColor; var centroid = StickyScript.transformToObject(new Vector3(Screen.width / 2, 0, 0), gameObject); var scaleX = CurrentScale; var scaleY = (int)(CurrentScale * 0.2f); var offsetX = (int)(scaleX / 2); var offsetY = (int)(scaleY / 2); var ySpace = (int)(scaleY / 2) + scaleY; var GuiRect = (new Rect(centroid.x - offsetX, centroid.y - offsetY, scaleX, scaleY)); if (GUI.Button(GuiRect, "Delete Handle", style)) { lineScript.DeleteHandle (Vector3.zero, false); StartCoroutine (MenuClose()); } GuiRect.y += ySpace; if (GUI.Button(GuiRect, "Insert Sticky", style)) { lineScript.SplitLineSticky(transform.position); StartCoroutine (MenuClose()); } GuiRect.y += ySpace; if (GUI.Button(GuiRect, "Delete Chain", style)) { var sticky0 = lineScript.ThisChain.Sticky0; var sticky1 = lineScript.ThisChain.Sticky1; lineScript = null; sticky0.GetComponent<StickyScript>().destroyConnection(sticky1.GetComponent<StickyScript>(), true); StartCoroutine (MenuClose()); } GuiRect.y += ySpace; }
//Find a line that has not yet been drawn given some parameters, draw it private static bool DrawAvailLine(int MinX, int MaxX, int MinY, int MaxY, int MinZ, int MaxZ) { int i, j, k; int rndSeed = new System.Random().Next(0, 3); GameObject drawnLine = null; //Loop through X lines, then Y lines, then Z lines if (rndSeed == 0) { for (j = MinY; j <= MaxY; j++) { for (k = MinZ; k <= MaxZ; k++) { drawnLine = MainGameScript.Grid_LinesX[MinX, j, k]; if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false) { Debug.Log("CPU Drawing line: X" + MinX + j + k); LineScript.Draw('X', MinX, j, k); return(true); } } } for (i = MinX; i <= MaxX; i++) { for (k = MinZ; k <= MaxZ; k++) { drawnLine = MainGameScript.Grid_LinesY[i, MinY, k]; if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false) { Debug.Log("CPU Drawing line: Y" + i + MinY + k); LineScript.Draw('Y', i, MinY, k); return(true); } } } for (i = MinX; i <= MaxX; i++) { for (j = MinY; j <= MaxY; j++) { drawnLine = MainGameScript.Grid_LinesZ[i, j, MinZ]; if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false) { Debug.Log("CPU Drawing line: Z" + i + j + MinZ); LineScript.Draw('Z', i, j, MinZ); return(true); } } } } //Loop through Y lines, then Z lines, then X lines else if (rndSeed == 1) { for (i = MinX; i <= MaxX; i++) { for (k = MinZ; k <= MaxZ; k++) { drawnLine = MainGameScript.Grid_LinesY[i, MinY, k]; if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false) { Debug.Log("CPU Drawing line: Y" + i + MinY + k); LineScript.Draw('Y', i, MinY, k); return(true); } } } for (i = MinX; i <= MaxX; i++) { for (j = MinY; j <= MaxY; j++) { drawnLine = MainGameScript.Grid_LinesZ[i, j, MinZ]; if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false) { Debug.Log("CPU Drawing line: Z" + i + j + MinZ); LineScript.Draw('Z', i, j, MinZ); return(true); } } } for (j = MinY; j <= MaxY; j++) { for (k = MinZ; k <= MaxZ; k++) { drawnLine = MainGameScript.Grid_LinesX[MinX, j, k]; if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false) { Debug.Log("CPU Drawing line: X" + MinX + j + k); LineScript.Draw('X', MinX, j, k); return(true); } } } } //Loop through Z lines, then X lines, then Y lines else { for (i = MinX; i <= MaxX; i++) { for (j = MinY; j <= MaxY; j++) { drawnLine = MainGameScript.Grid_LinesZ[i, j, MinZ]; if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false) { Debug.Log("CPU Drawing line: Z" + i + j + MinZ); LineScript.Draw('Z', i, j, MinZ); return(true); } } } for (j = MinY; j <= MaxY; j++) { for (k = MinZ; k <= MaxZ; k++) { drawnLine = MainGameScript.Grid_LinesX[MinX, j, k]; if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false) { Debug.Log("CPU Drawing line: X" + MinX + j + k); LineScript.Draw('X', MinX, j, k); return(true); } } } for (i = MinX; i <= MaxX; i++) { for (k = MinZ; k <= MaxZ; k++) { drawnLine = MainGameScript.Grid_LinesY[i, MinY, k]; if (drawnLine.GetComponentsInChildren <MeshRenderer>()[0].enabled == false) { Debug.Log("CPU Drawing line: Y" + i + MinY + k); LineScript.Draw('Y', i, MinY, k); return(true); } } } } return(false); }