public void setSquare(int oldSquareId, int newSquareID) { //float step = speed * Time.deltaTime; oldSquare = squareList [(oldSquareId) - 1]; newSquare = squareList [(newSquareID) - 1]; rsm = GetComponentInParent <rSmoothMove> (); //rsm.setSpeed (3.0F); SquareSetup oldSquareSettings = newSquare.GetComponent <SquareSetup>(); SquareSetup newSquareSettings = newSquare.GetComponent <SquareSetup>(); //transform.position = squareSettings.getCoords (); rBase = oldSquareSettings.getCoords(); if (inplay == true) { rsm.setSpeed(3.0F); rsm.destination = Vector3.MoveTowards(oldSquareSettings.getCoords(), newSquareSettings.getCoords(), (float)0.0001); /* SquareSetup rocketSquare = squareList[oldSquareId].GetComponent<SquareSetup>(); * SquareSetup preRocketSquare = squareList[currentSquare].GetComponent<SquareSetup>(); * preRocketSquare.takeRocket (); * Transform x = preRocketSquare.getRocket (); * rocketSquare.giveRocket (x);*/ } else { transform.position = Vector3.MoveTowards(oldSquareSettings.getCoords(), newSquareSettings.getCoords(), (float)0.0001); inplay = true; } currentSquare = newSquareID; }
public void setSquare(int oldSquareId, int newSquareID) { //float step = speed * Time.deltaTime; oldSquare = squareList [(oldSquareId) - 1]; newSquare = squareList [(newSquareID) - 1]; SquareSetup oldSquareSettings = newSquare.GetComponent <SquareSetup>(); SquareSetup newSquareSettings = newSquare.GetComponent <SquareSetup>(); SmoothMove sm = GetComponentInParent <SmoothMove>(); sm.setSpeed(3.0F); foreach (Transform square in squareList) { SquareSetup sq = square.GetComponent <SquareSetup>(); if (sq.isRocket()) { sq.takeRocket(); int c = sq.getRocket().GetComponent <rocketController>().move(); squareList[c - 1].GetComponent <SquareSetup>().giveRocket(sq.getRocket()); } } if (newSquareSettings.isRocket()) { Transform rocket = newSquareSettings.getRocket(); rocketController rc = rocket.GetComponent <rocketController>(); Transform tc = squareList [(rc.getTargetSquare()) - 1]; SquareSetup tcSquareSettings = tc.GetComponent <SquareSetup> (); sm.setVector(tcSquareSettings.getCoords()); rc.fireIt(tcSquareSettings.getCoords()); //transform.position = Vector3.position (oldSquareSettings.getCoords (), tcSquareSettings.getCoords (), (float)0.0001); //transform.position = tcSquareSettings.getCoords (); currentSquare = tcSquareSettings.getsquareID(); Renderer r = rocket.GetComponent <Renderer> (); //r.enabled = false; } else { sm.setVector(newSquareSettings.getCoords()); //transform.position = newSquareSettings.getCoords (); //transform.position = Vector3.MoveTowards (oldSquareSettings.getCoords (), newSquareSettings.getCoords (), (float)0.0001); currentSquare = newSquareID; } }