public void Clear( ) { LightOffset = null; Transform = null; ChunkPosition = null; RemoveItemSkills.Clear(); }
private static object ConvertValue(Type type, string value) { if (type.IsArray) { var split = value.Split(new string[] { Environment.NewLine, "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries); var t = type.GetElementType(); var arr = Array.CreateInstance(t, split.Length); for (var i = 0; i < split.Length; i++) { arr.SetValue(ConvertValue(t, split[i]), i); } return(arr); } if (type == typeof(Color)) { return(SVector3.Deserialize(value).ToColor()); } if (type == typeof(Vector3)) { return(SVector3.Deserialize(value).ToVector3()); } if (type == typeof(Vector2)) { return(SVector3.Deserialize(value).ToVector2()); } if (type == typeof(Quaternion)) { return(Quaternion.Euler(SVector3.Deserialize(value))); } return(TypeDescriptor.GetConverter(type).ConvertFrom(value)); }
internal void DoDuplicateNode(string id, Vector3 position) { var old = GameObject.Find(id); var oldNode = (old.GetComponent(typeof(NodePhysX)) as NodePhysX); var links = GameObject.FindGameObjectsWithTag("link").Select(p => p.GetComponent <Link>()); links = links.Where(p => p.source == old || p.target == old).ToArray(); var createAction = new CreateNode() { name = oldNode.Text, position = SVector3.FromVector3(position) }; DoAction(createAction); foreach (var l in links) { DoAction(new CreateLink() { SourceId = l.target == old ? l.source.name : createAction.nodeId, TargetId = l.target == old ? createAction.nodeId : l.source.name }); } DoAction(new CreateLink() { SourceId = old.name, TargetId = createAction.nodeId }); }
public EntityValues(int i, Vector3 l, Vector3 r, Vector3 v, Inventory I, Characteristics c) { indexInPrefabs = i; location = new SVector3(l); rotation = new SVector3(r); velocity = new SVector3(v); inventory = I; }
static public SVector3 Convert(Vector3 val) { SVector3 ret = new SVector3(); ret.x = val.x; ret.y = val.y; ret.z = val.z; return(ret); }
Hashtable GameSaverable.SaveGame() { Hashtable hs = new Hashtable(); hs.Add("points", SVector3.List(pointsList)); hs.Add("leftTime", _lifeLeftTime); return(hs); }
public static void CopyTo(Vector3[] fromArray, SVector3[] toArray) { toArray = new SVector3 [fromArray.Length]; for (int i = 0; i < toArray.Length; i++) { toArray [i] = fromArray [i]; } }
static public SVector3 Convert(IM.Vector3 val) { SVector3 ret = new SVector3(); ret.x = val.x.raw; ret.y = val.y.raw; ret.z = val.z.raw; return(ret); }
public static SVector3 Random(float min, float max) { SVector3 sVector3 = new SVector3(); sVector3.x = UnityEngine.Random.Range(min, max); sVector3.y = UnityEngine.Random.Range(min, max); sVector3.z = UnityEngine.Random.Range(min, max); return(sVector3); }
public void RestoreState(object state) { SVector3 restoredPosition = (SVector3)state; agent.enabled = false; transform.position = restoredPosition.ToVector3(); agent.enabled = true; GetComponent <ActionScheduler>().CancelAction(); }
public static bool GetBelowGroundSpawnPoint(ref SpawnPoint spawnPoint, SpawnerStateSetting setting, Location spawnLocation, WIGroup spawnGroup) { bool succeeded = false; spawnPoint = new SpawnPoint(); switch (setting.Method) { case SpawnerPlacementMethod.SherePoint: //cast a ray from the center of the location outwards Vector3 starget = (UnityEngine.Random.onUnitSphere * spawnLocation.worlditem.ActiveRadius) + spawnLocation.worlditem.tr.position; Vector3 sscale = Vector3.one; RaycastHit hit; if (Physics.Linecast(spawnLocation.worlditem.tr.position, starget, out hit, Globals.LayersTerrain)) { spawnPoint.Transform.Position = spawnLocation.worlditem.tr.InverseTransformPoint(hit.point); spawnPoint.Transform.Rotation = Quaternion.FromToRotation(Vector3.up, hit.normal).eulerAngles; //random forward vector, normal up vector spawnPoint.Transform.Scale = sscale; switch (hit.collider.gameObject.layer) { case Globals.LayerNumFluidTerrain: spawnPoint.HitWater = true; break; case Globals.LayerNumSolidTerrain: default: spawnPoint.HitTerrainMesh = true; break; } succeeded = true; } break; case SpawnerPlacementMethod.TopDown: default: //get a random point in sphere scaled to the location's radius mTerrainHit.groundedHeight = spawnLocation.worlditem.ActiveRadius; mRandomSphere = UnityEngine.Random.onUnitSphere * mTerrainHit.groundedHeight; mRandomSphere.y = 0f; mTerrainHit.feetPosition = mRandomSphere + spawnLocation.worlditem.tr.position; //get the terrain height in world space, then store it in local space //WorldChunk chunk = spawnLocation.worlditem.Group.GetParentChunk (); mTerrainHit.feetPosition.y = GameWorld.Get.TerrainHeightAtInGamePosition(ref mTerrainHit); spawnPoint.Transform.Position = spawnLocation.worlditem.tr.InverseTransformPoint(mTerrainHit.feetPosition); spawnPoint.Transform.Rotation = Quaternion.LookRotation(SVector3.Random(-1f, 1f), mTerrainHit.normal).eulerAngles; spawnPoint.Transform.Scale = Vector3.one; spawnPoint.HitWater = mTerrainHit.hitWater; spawnPoint.HitTerrainMesh = mTerrainHit.hitTerrainMesh; if (!mTerrainHit.isGrounded) { Debug.Log("TERRAIN HIT WAS NOT GROUNDED"); } succeeded = true; break; } return(succeeded); }
public void BasicLoadData(SVector3 position, SVector3 rotation, SVector3 speed, Characteristics newCharacteristics) { gameObject.transform.position = position.ToV3(); gameObject.transform.eulerAngles = rotation.ToV3(); gameObject.GetComponent <Rigidbody2D>().velocity = speed.ToV3(); thisHealth.values = newCharacteristics; if (transform.eulerAngles.y != 0) { facingRight = false; } }
public static Vector3 Deserialize(this SVector3 _Vector3) { Vector3 returnVal = new Vector3 { x = _Vector3.x, y = _Vector3.y, z = _Vector3.z }; return(returnVal); }
void Update() { //animation if (curves[0] != null) { transform.position = new Vector3(curves[0].Evaluate(Time.time), curves[1].Evaluate(Time.time), curves[2].Evaluate(Time.time)); transform.rotation = Quaternion.Euler(new Vector3(curves[3].Evaluate(Time.time), curves[4].Evaluate(Time.time), curves[5].Evaluate(Time.time))); CoordControl.text = "Pos: " + transform.position.ToString() + "\nRot: " + transform.rotation.eulerAngles.ToString(); } //input Vector3 move = new Vector3(); Vector3 rotate = new Vector3(); if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { rotate.y = Input.GetAxis("Horizontal") * speed * Time.deltaTime; move.y = Input.GetAxis("Vertical") * speed * Time.deltaTime; } else { move.x = Input.GetAxis("Horizontal") * speed * Time.deltaTime; move.z = Input.GetAxis("Vertical") * speed * Time.deltaTime; } //adjust speed with mouse wheel move.z += Input.GetAxis("Mouse ScrollWheel") * 15; if (speed < 5) { speed = 5; } movementSpeed.text = "Flyspeed: " + speed; move = transform.TransformDirection(move); var oldRot = transform.rotation.eulerAngles; var newRot = (transform.rotation * Quaternion.Euler(rotate)).eulerAngles; if (oldRot.Equals(newRot) && move.Equals(Vector3.zero)) { return; } graphController.DoAction(new MoveCamera() { newPos = SVector3.FromVector3(transform.position + move), oldPos = SVector3.FromVector3(transform.position), newRot = SVector3.FromVector3(newRot), oldRot = SVector3.FromVector3(oldRot), duration = 0 }); }
public SResults(Results res) { position = res.position; rotation = res.rotation; camX = res.camX; speed = res.speed; isGrounded = res.isGrounded; jumped = res.jumped; crouch = res.crouch; groundPoint = res.groundPoint; groundPointTime = res.groundPointTime; timestamp = res.timestamp; }
protected void SendUseSkill(string skillID, Units target, Vector3 targetPos, bool isCrazyMode = true) { UseSkillInfo info = new UseSkillInfo { unitId = this.self.unique_id, skillId = skillID, targetUnit = (!(target != null)) ? 0 : target.unique_id, targetPosition = SVector3.Build(targetPos.x, targetPos.y, targetPos.z), targetRotate = this.self.transform.eulerAngles.y, controlMode = (!isCrazyMode) ? 1 : 0 }; PvpEvent.SendUseSkill(info); }
public void ExecuteSaving() { GameObject Player = GameObject.Find("Player"); playerPosition = new SVector3(Player.transform.position); playerRotation = new SVector3(Player.transform.eulerAngles); playerSpeed = new SVector3(Player.GetComponent <Rigidbody2D>().velocity); playerCharacteristics = Player.GetComponent <PlayerControls>().thisHealth.values; playerInventory = Player.GetComponent <PlayerControls>().inventory; playerMunitions = Player.GetComponent <PlayerControls>().munitions; playerSpells = Player.GetComponent <PlayerControls>().spells; MS.SaveMap(); talks = GameObject.Find("WorldManager").GetComponent <WorldManagement>().GetTalks(); }
public void IssueComand(IUnit unit, Vector3 moveTarget, bool moveTargetActive) { // HANDLE MOVEMENT ushort entityID = ClientGameRunner.Instance.em.GetEntity(unit.GetGameObject()).id; SVector3 mt = null; if (moveTargetActive) { mt = new SVector3(moveTarget); } UnitCommand uc = new UnitCommand(entityID, mt); SendUnitCommand(uc); }
public static SVector3 Serialize(this Vector3 _Vector3) { if (_Vector3 == null) { return(null); } SVector3 returnVal = new SVector3 { x = _Vector3.x, y = _Vector3.y, z = _Vector3.z }; return(returnVal); }
public void StopMove_Impl(SVector3 curPos, float rotate) { if (GlobalSettings.Instance.PvpSetting.isPlayerMoveBeforeServer && Singleton <PvpManager> .Instance.IsInPvp && this.self.isPlayer) { return; } this.self.serverTargetPos = MoveController.ServerPosInvalide; Vector3 position = base.transform.position; Vector3 vector = MoveController.SVectgor3ToVector3(curPos); Vector3 serverTargetPos = this.self.serverTargetPos; if (this.navAgent != null) { this.navAgent.StopMove(); } }
protected IEnumerator RefreshSplineNodes() { for (int i = 0; i < Props.Nodes.Count; i++) { SVector3 nodePosition = Props.Nodes [i]; GameObject node = MasterSpline.AddSplineNode(); node.transform.parent = tr; node.transform.localPosition = nodePosition; double waitUntil = WorldClock.RealTime + 0.01f; while (WorldClock.RealTime < waitUntil) { yield return(null); } } mRefreshingSplineNodes = false; yield break; }
public static SVector3 Parse(string sVector3String) { SVector3 sVector3 = new SVector3(); char[] splitChar = new char [1] { ',' }; string[] splitString = sVector3String.Split(splitChar, StringSplitOptions.None); if (splitString.Length >= 2) { sVector3.x = float.Parse(splitString [0]); sVector3.y = float.Parse(splitString [1]); sVector3.z = float.Parse(splitString [2]); } return(sVector3); }
public void RefreshSpline() { MasterSpline.updateMode = Spline.UpdateMode.DontUpdate; MasterSplineMesh.updateMode = SplineMesh.UpdateMode.DontUpdate; MasterSpline.enabled = false; if (Application.isPlaying) { if (!mRefreshingSplineNodes) { mRefreshingSplineNodes = true; StartCoroutine(RefreshSplineNodes()); } } else { for (int i = 0; i < Props.Nodes.Count; i++) { SVector3 nodePosition = Props.Nodes [i]; GameObject node = new GameObject("Node"); //MasterSpline.AddSplineNode(); node.transform.parent = transform; node.transform.localPosition = nodePosition; SplineNode s = node.AddComponent <SplineNode> (); MasterSpline.splineNodesArray.Add(s); } } tr.localPosition = Vector3.up * (Props.BaseHeight + Props.CurrentWaterLevel); MasterSplineMesh.segmentCount = Props.SegmentCount; MasterSplineMesh.uvScale = Props.UVScale; MasterSplineMesh.xyScale = Props.MeshScale; WaterAnimation.FlowDirection = Props.FlowDirection; WaterAnimation.FlowSpeed = Props.FlowSpeed; WaterAnimation.FoamSpeed = Props.FoamSpeed; }
public CollectibleInfo(ItemStack item, Vector3 pos) { itemStack = item; this.pos = pos; }
public SMesh(Mesh m, string _name) { vertices = new SVector3[m.vertices.Length]; transfer(m.vertices, vertices); uv = new SVector2[m.uv.Length]; transfer(m.uv, uv); normals = new SVector3[m.normals.Length]; transfer(m.normals, normals); triangles = m.triangles; name = _name; }
private void transfer(Vector3[] v, SVector3[] s) { for (int i = 0; i < v.Length; i++) { s[i] = new SVector3(v[i]); } }
public void CopyFrom(SVector3 other) { x = other.x; y = other.y; z = other.z; }
public STransform(SVector3 position) { Position = position; Rotation = SVector3.zero; Scale = SVector3.one; }
public STransform(SVector3 position, SVector3 rotation) { Position = position; Rotation = rotation; Scale = SVector3.one; }
public STransform(SVector3 position, SVector3 rotation, SVector3 scale) { Position = position; Rotation = rotation; Scale = scale; }
private Vector3[] Restore(SVector3[] s) { Vector3[] v = new Vector3[s.Length]; for (int i = 0; i < v.Length; i++) { v[i] = s[i].Restore(); } return v; }
public SaveImage(Texture t, Transform tr) { texture = t != null ? ((Texture2D)t).EncodeToPNG() : null; scale = new SVector3(tr.localScale); }
public void PaintModeController() { if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && Input.GetKeyDown(KeyCode.Z)) { graphControl.UndoAction(); } if (Input.GetKeyDown(KeyCode.F2)) { if (graphControl.SelectedNode != null) { graphControl.Select(graphControl.SelectedNode, true); } } if (Input.GetKeyDown(KeyCode.F3)) { if (graphControl.SelectedNode != null) { //delete node graphControl.DoAction(new DeleteNode() { nodeId = graphControl.SelectedNode.name }); } } if (Input.GetKeyDown(KeyCode.F1)) { if (graphControl.SelectedNode != null) { var worldpos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, lazyZ)); graphControl.DoDuplicateNode(graphControl.SelectedNode.name, worldpos); } } // Paint only if not over Panel if (!gameCtrlUI.PanelIsPointeroverPanel(Input.mousePosition)) { // Check what was clicked on when MouseButtonDown if (Input.GetMouseButtonDown(0)) { btnDownPointerPos = Input.mousePosition; if (verbose) { Debug.Log(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + ": Detected MouseButtonDown. mousePosition: x: " + btnDownPointerPos.x + " y: " + btnDownPointerPos.y + " z: " + btnDownPointerPos.z); } if (graphControl.IsRecording()) { //Ray ray = Camera.main.ScreenPointToRay(btnDownPointerPos); //hitObjBtnDown = null; //if (Physics.Raycast(ray, out hitInfoBtnDown)) btnDownHitGo = null; btnDownHitGo = gameCtrlHelper.ScreenPointToRaySingleHitWrapper(Camera.main, btnDownPointerPos); if (btnDownHitGo != null) { //hitObjBtnDown = hitInfoBtnDown.collider.gameObject; if (verbose) { Debug.Log(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + ": GetMouseButtonDown: Ray did hit. On Object: " + btnDownHitGo); } paintedLinkObject = Instantiate(paintedLinkPrefab, new Vector3(0, 0, 0), Quaternion.identity) as paintedLink; paintedLinkObject.name = "paintedLink"; //paintedLinkObject.sourceObj = hitObjBtnDown; //paintedLinkObject.targetVector = hitObjBtnDown.transform.position; paintedLinkObject.sourceObj = btnDownHitGo; paintedLinkObject.targetVector = btnDownHitGo.transform.position; } } } if (Input.GetMouseButton(0) && paintedLinkObject != null && graphControl.IsRecording()) { if (verbose) { Debug.Log(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + ": Entered GetMouseButton, about to start paintlink()"); } Vector3 mousePosWorld = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, lazyZ)); if (verbose) { Debug.Log(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + ": Painting Link. Current mousePosition is: (" + Input.mousePosition.x + ", " + Input.mousePosition.y + ", " + lazyZ + "). Converted worldPosition is: " + mousePosWorld); } paintedLinkObject.targetVector = mousePosWorld; } if (Input.GetMouseButtonUp(0)) { btnUpPointerPos = Input.mousePosition; if (verbose) { Debug.Log(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + ": Detected MouseButtonUp. mousePosition: x: " + btnUpPointerPos.x + " y: " + btnUpPointerPos.y + " z: " + btnUpPointerPos.z); } if (graphControl.PaintMode) { // Ray ray = Camera.main.ScreenPointToRay(btnUpPointerPos); // hitObjBtnUp = null; // if (Physics.Raycast(ray, out hitInfoBtnUp)) btnUpHitGo = null; btnUpHitGo = gameCtrlHelper.ScreenPointToRaySingleHitWrapper(Camera.main, btnUpPointerPos); string newNodeId = null; if (btnUpHitGo == null && graphControl.IsRecording()) { //create new node if release on empty space Vector3 clickPosWorld = Camera.main.ScreenToWorldPoint(new Vector3(btnUpPointerPos.x, btnUpPointerPos.y, lazyZ)); newNodeId = "node_" + graphControl.NextId; graphControl.DoAction(new CreateNode() { nodeId = newNodeId, position = SVector3.FromVector3(clickPosWorld) }); btnUpHitGo = GameObject.Find(newNodeId); graphControl.SelectById(newNodeId, true); } if (btnUpHitGo != null) { // If on ButtonDown a node was rayhit, and on ButtonUp a different nodes, we just want to link these nodes together if (btnDownHitGo != null) { if (btnDownHitGo != btnUpHitGo && graphControl.IsRecording()) { if (verbose) { Debug.Log(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + ": GetMouseButtonUp: ButtonDown node and a differing ButtonUp was selected. This linking the ButtonDown node: " + btnDownHitGo + " with the ButtonUp node: " + btnUpHitGo); } graphControl.DoAction(new CreateLink() { SourceId = btnDownHitGo.name, TargetId = btnUpHitGo.name }); } else { //select node graphControl.Select(btnUpHitGo.GetComponent(typeof(NodePhysX)) as NodePhysX); } } } if (paintedLinkObject != null) { GameObject.Destroy(paintedLinkObject.gameObject); } } } } }
public EnvironmentStuffingValues(Vector3 v, int i) { location = new SVector3(v); indexInPrefabs = i; }