public static void ToProto(ref rotation dst, Quaternion src) { dst.x = (int)(src.x * RESOLUTION); dst.y = (int)(src.y * RESOLUTION); dst.z = (int)(src.z * RESOLUTION); dst.w = (int)(src.w * RESOLUTION); }
/// <summary> /// Takes a block, and the physical game object associated with it, and orients it to the rotation, and facing defined in /// the block data /// </summary> /// <param name="block"></param> /// <param name="model"></param> /// <returns></returns> internal static void orientBlock(Block block, GameObject model) { rotation rot = block.rotate; model.transform.Rotate(0, 0, 90 * (int)rot); faceBlock(block, model); }
void startRewind() { gameObject.GetComponent <SpinnerObject>().enableRotation = false; rotation rotation = new rotation(); if (rotations.Count > 1) { rotation = rotations.Last.Value; } else { rotation = rotations.First.Value; } transform.rotation = rotation.rot; if (rotations.Count > 1) { rotations.RemoveLast(); } else { Debug.Log("Somethign"); } }
public static void ToNative(ref Quaternion dst, rotation src) { dst.x = (float)src.x / (float)RESOLUTION; dst.y = (float)src.y / (float)RESOLUTION; dst.z = (float)src.z / (float)RESOLUTION; dst.w = (float)src.w / (float)RESOLUTION; }
void Start() { startPos = transform.position; GameObject player = GameObject.FindWithTag("Player"); rot = player.GetComponent <rotation>(); }
public override string ToString() { if (this.value == null) { this.value = new ArrayList(); } StringBuilder sb = new StringBuilder(); for (int intI = 0; intI < this.value.Count; intI++) { if (this.value[intI] is vector) { vector v = (vector)this.value[intI]; sb.AppendFormat(new System.Globalization.CultureInfo("en-us"), "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", (double)v.x, (double)v.y, (double)v.z); } else if (this.value[intI] is rotation) { rotation r = (rotation)this.value[intI]; sb.AppendFormat(new System.Globalization.CultureInfo("en-us"), "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", (double)r.x, (double)r.y, (double)r.z, (double)r.s); } else { sb.Append(this.value[intI].ToString()); } } return(sb.ToString()); }
public rotation osNpcGetRot(key npc) { rotation rot = new rotation(this.rdmRandom.Next(0, (int)(Math.PI * 2)), this.rdmRandom.Next(0, (int)(Math.PI * 2)), this.rdmRandom.Next(0, (int)(Math.PI * 2)), this.rdmRandom.Next(0, (int)(Math.PI * 2))); Verbose("osNpcGetRot(\"{0}\")={1}", npc, rot); return(rot); }
public void BlockCalculation(int i) { Debug.Log("shit"); switch (i) { case 0: final = 0; Debug.Log("zero"); break; case 1: final = 1; break; case 2: if (upblock == rightblock) { final = 2; } else if (rightblock == downblock) { final = 2; } else { final = 3; } break; case 3: if (!upblock) { blockrotation = rotation.zero; } else if (!rightblock) { blockrotation = rotation.three; } else if (!downblock) { blockrotation = rotation.six; } else { blockrotation = rotation.nine; } final = 4; break; case 4: final = 5; break; } BlockSettings[final].BoxColl.SetActive(true); SpriteObj.GetComponent <SpriteRenderer>().sprite = BlockSettings[final].Texture; BlockSet(); }
public void rotate() { if (detector.canRotate() && !lockRotation) { transform.Rotate(0, 0, 90f); int rot = (int)transform.eulerAngles.z / 90; actitveRotation = (rotation)rot; } }
/// <summary> /// Generates a random block. Note this is nto used in the following or previous functions /// and it should be self evident why. /// </summary> /// <returns></returns> internal static Block generateRandomBlock() { List <BlockType> blocks = blockMan.blockTypes; BlockType desired = blocks[random.Next(0, blocks.Count - 1)]; facing face = Randomizer.RandomEnumValue <facing>(); rotation rot = Randomizer.RandomEnumValue <rotation>(); Block pBlock = new Block(desired.UID, face, rot); return(pBlock); }
public static rotation operator /(rotation q, rotation r) { // 23 feb 2008 rotation rot = new rotation( r.s * q.x + r.z * q.y - r.y * q.z - r.x * q.s, r.s * q.y - r.z * q.x - r.y * q.s + r.x * q.z, r.s * q.z - r.z * q.s + r.y * q.x - r.x * q.y, r.s * q.s + r.z * q.z + r.y * q.y + r.x * q.x); return(rot); }
public static rotation operator *(rotation q, rotation r) { rotation rot = new rotation( r.s * q.x - r.z * q.y + r.y * q.z + r.x * q.s, r.s * q.y + r.z * q.x + r.y * q.s - r.x * q.z, r.s * q.z + r.z * q.s - r.y * q.x + r.x * q.y, r.s * q.s - r.z * q.z - r.y * q.y - r.x * q.x); return(rot); }
void Start() { if (isLocalPlayer) { nb_col = 0; last_nb_col = nb_col; nb_victim = 0; isCol = false; velo = 50; //GetComponent<Rigidbody2D>().AddForce(forward * Time.deltaTime * velo); rb = GetComponent <Rigidbody2D>(); dir = rotation.positive; isAlready = false; direction = Vector2.up; } }
/// <summary> /// Initialises a new instance of the <see cref="SecondLife"/> class. /// </summary> public SecondLife() { this.host = null; rdmRandom = new Random(); dtDateTimeScriptStarted = DateTime.Now.ToUniversalTime(); htLandPassList = new Hashtable(); htLandBanList = new Hashtable(); fVolume = 0.0; sObjectName = null; vPosition = new vector(127, 128, 20); rRotation = rotation.ZERO_ROTATION; rRotationlocal = rotation.ZERO_ROTATION; vScale = vector.ZERO_VECTOR; sSitText = "sittext"; fSoundRadius = 1.0; iStartParameter = 0; vRegionCorner = vector.ZERO_VECTOR; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "ColorChange") { setRandomColor(); Instantiate(colorChanger, new Vector2(transform.position.x, currentObstacle.transform.position.y), transform.rotation); //Destroy(colorChanger.gameObject); Scores(5); scoreText.text = "Score: " + score.ToString(); audioSource.PlayOneShot(sound, 1f); Destroy(collision.gameObject); return; } if (collision.tag == "Score") { Scores(1); collision.GetComponent <CircleCollider2D>().enabled = false; // Destroy(collision.gameObject); currentObstacle = Instantiate(obstacle[Random.Range(0, obstacle.Length)], new Vector2(transform.position.x, transform.position.y + distance), Quaternion.identity); obstacleCount++; Debug.Log(currentObstacle); rotm = GameObject.Find(currentObstacle.name).GetComponent <rotation>(); rotm.randomRotate = Random.Range(0, 1); //передаем рандом в rotation.cs //currentObstacle.AddComponent<rotation>(); return; } if (collision.tag != currentColor) { Save(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); //загружаем и создаем индекс. Нужно подключить using UnityEngine.SceneManagement; Scores(-score); maxScore = SaveLoad.currentScore; maxScoreText.text = "Record: " + maxScore.ToString(); } }
/// <summary> /// Pass in the structure which holds your blocks, as well as the type of block you would like added, and /// this will add that block at a random spot to your structure /// </summary> /// <param name="structure"></param> /// <param name="type"></param> /// <returns>The altered datastructure, null if failed</returns> internal static bool insertBlockTypeAtRandom(IndividualDatastructure structure, BlockType type) { double openSpace = BlockFunctions.randomOpenSpace(structure.openSpaces); ///This is our block facing face = Randomizer.RandomEnumValue <facing>(); rotation rot = Randomizer.RandomEnumValue <rotation>(); Block pBlock = new Block(type.UID, face, rot); ///If we've gotten to this point, then we can successfully place ourself into the individual /* * IVE BEEN GETTING AN ERROR WHERE WE TRY TO PLACE BLOCKS THAT ALREADY EXIST. * NO IDEA WHY THIS HAPPENS AND IT SHOULDN'T SO I'M SIMPLY PUTTING THIS CONDITIONAL HERE AS A JANK FIX */ if (structure.contents.ContainsKey(openSpace)) { return(false); } structure.contents.Add(openSpace, pBlock); ///Remove the open space from structure.openSpaces structure.openSpaces.Remove(openSpace); ///Add the possible neighbours of the placed block to our open neighbours list List <double> openConsiderations = BlockFunctions.addNeighboursToOpen(openSpace, structure.contents); ///Iterating over the open spots we are considering, and check to see if they are already filled or not. ///Then adding them to our open spaces list if they are not. foreach (double possible in openConsiderations) { if (structure.contents.ContainsKey(possible)) { continue; } structure.openSpaces.Add(possible); } return(true); }
public void osNpcSetRot(key npc, rotation rot) { Verbose("osNpcSetRot(\"{0}\", {1})", npc, rot); }
/// <summary> /// The constructor for the block. Notice that block type is an int. This is only for when we create the physical block, /// we can lookup what type it is within our blocktype class /// </summary> /// <param name="active"></param> /// <param name="UID">The UID of the block type</param> public Block(int TID, facing face, rotation rot) { this.type = TID; this.face = face; this.rotate = rot; }
public void osForceDropAttachmentAt(vector pos, rotation rot) { Verbose("osForceDropAttachmentAt({0}, {1})", pos, rot); }
void Update() { if (!isLocalPlayer) { return; } //SearchTarget(); if (isCol == true && timer <= System.DateTime.Now) { isCol = false; } if (nb_col == last_nb_col && nb_col > 0) { ++nb_victim; } else { nb_victim = 0; } if (nb_victim == 10) { nb_victim = 0; Receive_knockback(); } if (Input.GetKey(KeyCode.Space) && isCol == false) { angle = transform.eulerAngles.z * Mathf.Deg2Rad; sin = Mathf.Sin(angle); cos = Mathf.Cos(angle); if (isAlready == false) { forward = new Vector3( direction.x * cos - direction.y * sin, direction.x * sin + direction.y * cos, 0f); } if (velo < 2000) { velo += 2f; } GetComponent <Rigidbody2D>().velocity = forward * Time.deltaTime * velo; //transform.position += forward * Time.deltaTime * speed; if (isAlready == false) { if (dir == rotation.positive) { dir = rotation.negative; } else if (dir == rotation.negative) { dir = rotation.positive; } } isAlready = true; } else { last_forward = GetComponent <Rigidbody2D>().velocity; if (velo > 3) { velo -= 4f; } //GetComponent<Rigidbody2D>().velocity = forward * Time.deltaTime * speed * velo; //GetComponent<Rigidbody2D>().velocity if (dir == rotation.positive) { transform.Rotate(Vector3.forward * Time.deltaTime * time, Space.Self); //* (pone.MassProperty/5) } else if (dir == rotation.negative) { transform.Rotate(Vector3.back * Time.deltaTime * time, Space.Self); } isAlready = false; } }
virtual public IEnumerator UB() { SpriteObj.GetComponent <SpriteRenderer>().sortingOrder = 8; yield return(new WaitForSeconds(.02f)); BlockSettings[final].BoxColl.SetActive(false); upblock = false; rightblock = false; leftblock = false; downblock = false; connections = 0; final = 0; canupdate = true; RaycastHit hit; LayerMask l = 1 << 9; // Does the ray intersect any objects excluding the player layer if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, 0.7f, l)) { if (hit.collider.tag == gameObject.tag) { blockrotation = rotation.zero; connections++; upblock = true; } } if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.right), out hit, 0.7f, l)) { if (hit.collider.tag == gameObject.tag) { if (upblock != true) { blockrotation = rotation.three; } connections++; rightblock = true; } } if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.back), out hit, 0.7f, l)) { if (hit.collider.tag == gameObject.tag) { if (upblock != true || rightblock != true) { blockrotation = rotation.six; } connections++; downblock = true; } } if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.left), out hit, 0.7f, l)) { if (hit.collider.tag == gameObject.tag) { if (upblock != true || rightblock != true || downblock != true) { blockrotation = rotation.nine; } connections++; leftblock = true; } } BlockCalculation(connections); yield return(null); }
public void osSetInertia(Float mass, vector centerOfMass, vector principalInertiaScaled, rotation InertiaRot) { Verbose("osSetInertia({0}, {1}, {2}, {3})", mass, centerOfMass, principalInertiaScaled, InertiaRot); }
/// <summary> /// Takes a face and a rotation, and returns what that face should be after rotation /// </summary> /// <param name="before">the face</param> /// <param name="rotate">the rotation value</param> /// <returns></returns> internal static facing rotateFace(facing before, rotation rotate) { facing retFace = before; #region 90degrees if (rotate == rotation.R90) { switch (before) { case facing.DOWN: retFace = facing.LEFT; break; case facing.LEFT: retFace = facing.UP; break; case facing.UP: retFace = facing.RIGHT; break; case facing.RIGHT: retFace = facing.DOWN; break; default: break; } } #endregion #region 180degrees if (rotate == rotation.R180) { switch (before) { case facing.DOWN: retFace = facing.UP; break; case facing.LEFT: retFace = facing.RIGHT; break; case facing.UP: retFace = facing.DOWN; break; case facing.RIGHT: retFace = facing.LEFT; break; default: break; } } #endregion #region 270degrees if (rotate == rotation.R270) { switch (before) { case facing.DOWN: retFace = facing.RIGHT; break; case facing.LEFT: retFace = facing.DOWN; break; case facing.UP: retFace = facing.LEFT; break; case facing.RIGHT: retFace = facing.UP; break; default: break; } } #endregion return(retFace); }
public static vector operator /(vector v, rotation r) { rotation inverseR = new rotation(-r.x, -r.y, -r.z, r.s); return(v * inverseR); }
public void osSetInertiaAsCylinder(Float mass, Float radius, Float length, vector centerOfMass, rotation rot) { Verbose("osSetInertiaAsCylinder({0}, {1}, {2}, {3}, {4})", mass, radius, length, centerOfMass, rot); }
public void osSetInertiaAsBox(Float mass, vector boxSize, vector centerOfMass, rotation rot) { Verbose("osSetInertiaAsBox({0}, {1}, {2}, {3})", mass, boxSize, centerOfMass, rot); }
public virtual void at_rot_target(integer iHandle, rotation rTargetRotation, rotation rCurrentRotation) { }
public integer osTeleportObject(key objectUUID, vector targetPos, rotation rot, integer flags) { Verbose("osTeleportObject(\"{0}\", {1}, {2}, {3})=1", objectUUID, targetPos, rot, flags); return(1); }
static rotation() { ZERO_ROTATION = new rotation(0, 0, 0, 1); }