public void Activate() { timeElapsed = 0; tc = transform.parent.GetComponent <TransformController>(); active = true; startPos = tc.obj.position; startRot = tc.obj.eulerAngles; startScale = tc.obj.localScale; if (scale == Vector3.zero) { scale = tc.obj.localScale; } }
public void LeaveBlock(string blockID) { if (blocks.ContainsKey(blockID)) { lock (blocks[blockID]) { TransformController t = blocks[blockID].GetComponentInChildren <TransformController>(); if (t != null) { t.PlayerLeave(); } } } }
private void OnEnable() { tc = transform.GetComponentInParent <TransformController>(); target = tc.Target; if (target == null) { #if UNITY_EDITOR Debug.LogError("PositionController-OnEnable: target is not set."); #endif return; } mainCamera = Camera.main; }
public static void SendMessage() { //Debug.Log(msg.Optype + " " + msg.Posx + " " + msg.Posy + " " + msg.Posz); //Debug.Log(msg.Optype); while (SkillQueue.Count != 0) { int skill = SkillQueue.Dequeue(); //Debug.Log("skill = " + skill); msg.Optype += skill; } byte[] sendMsg = TransformController.Transform(msg); if (ClientSocket.Poll(-1, SelectMode.SelectWrite)) { ClientSocket.Send(sendMsg); } //if ((msg.Optype & (1 << 5)) == 0) msg.Optype += (1 << 5); }
private void Start() { cubeController.SetActive(false); cubeController.transform.localPosition = Vector3.zero; cubeController.transform.rotation = Quaternion.identity; TransformController tc = transform.GetComponentInParent <TransformController>(); GameObject target = tc.Target; // コントロール対象を囲むワイヤーフレームの大きさを設定する cubeController.transform.localScale = tc.PositionControlerScale * TransformControlManager.Instance.positionCubeScale; cubeController.AddComponent <PositionController>(); cubeController.GetComponent <MeshRenderer>().sharedMaterial = TransformControlManager.Instance.positionCubeMaterial; cubeController.SetActive(true); }
public void OnRegisterClick() { string username = user_name.text; string userpwd = user_pwd.text; msg.Optype = (1 << 1); msg.Username = username; msg.Userpwd = userpwd; //Controller.SetIPEndPoint(new IPEndPoint(IPAddress.Parse("118.89.189.165"), 3360)); //Controller.SetSocket(new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)); ServerEndPoint = new IPEndPoint(IPAddress.Parse("118.89.189.165"), 3360); // Connect to server IP and port ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // Client communication socket try { ClientSocket.Connect(ServerEndPoint); //Controller.GetSocket().Connect(Controller.GetIPEndPoint()); Debug.Log("Successfully connected to the server"); } catch (Exception e) { Debug.Log(e.Message); } byte[] sendMsg = TransformController.Transform(msg); if (ClientSocket.Poll(-1, SelectMode.SelectWrite)) { ClientSocket.Send(sendMsg); } if (ClientSocket.Poll(-1, SelectMode.SelectRead)) { ClientSocket.Receive(sendMsg); //Controller.GetSocket().Send(msg); //Controller.GetSocket().Receive(msg); if (sendMsg[0] == '1') { Debug.Log("user already exist"); } else if (sendMsg[0] == '2') { Debug.Log("register success"); } ClientSocket.Close(); //Controller.GetSocket().Close(); } }
private void SetChildPositionAndScale(Transform child, RotationController.RotationAxis axis, int i) { TransformController tc = transform.GetComponentInParent <TransformController>(); var basePos = tc.PositionControlerScale * TransformControlManager.Instance.positionCubeScale / 2.0f; switch (axis) { case RotationController.RotationAxis.x: child.localPosition = new Vector3( 0, basePos.y * ((i & 2) != 0 ? -1 : 1), basePos.z * ((i & 1) != 0 ? -1 : 1)); break; case RotationController.RotationAxis.y: child.localPosition = new Vector3( basePos.x * ((i & 2) != 0 ? -1 : 1), 0, basePos.z * ((i & 1) != 0 ? -1 : 1)); break; case RotationController.RotationAxis.z: child.localPosition = new Vector3( basePos.x * ((i & 2) != 0 ? -1 : 1), basePos.y * ((i & 1) != 0 ? -1 : 1), 0); break; default: #if UNITY_EDITOR Debug.LogError("Parameter axis is invalid"); #endif return; } // TODO:さまざまな大きさに対応できるようにする float localScaleX = 0.1f / tc.Target.transform.localScale.x; float localScaleY = 0.1f / tc.Target.transform.localScale.y; float localScaleZ = 0.1f / tc.Target.transform.localScale.z; child.localScale = new Vector3(localScaleX, localScaleY, localScaleZ) * TransformControlManager.Instance.controllerScale; }
private void Update() { if (EventSystem.current.IsPointerOverGameObject()) { return; } var currentTool = GetCurrentTool(); if (currentTool == Tool.Select) { if (Input.GetKeyDown(KeyCode.Mouse0)) { RaycastHit hit; var ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { int x = Mathf.FloorToInt(hit.point.x + hit.normal.x / -2); int y = Mathf.FloorToInt(hit.point.y + hit.normal.y / -2); int z = Mathf.FloorToInt(hit.point.z + hit.normal.z / -2); if (ModelManager.GetCube(x, y, z) && !CubeSelectionController.DoesCubeExist(x, y, z) && TransformController.GetSelectedTranformComponents() == 0) { int color = ModelManager.GetCubeColor(x, y, z); //CubeSelectionController.ResetCubePositions(); CubeSelectionController.AddCube(x, y, z, color); ModelManager.RemoveCube(x, y, z); TransformController.UpdateVisibleTools(); } } else { var controllerPosition = CubeSelectionController.GetPosition(); foreach (var cube in CubeSelectionController.GetAllCubes()) { ModelManager.AddCube(cube.x + (int)controllerPosition.x, cube.y + (int)controllerPosition.y, cube.z + (int)controllerPosition.z, cube.color); } CubeSelectionController.Clear(); CubeSelectionController.ResetPosition(); TransformController.UpdateVisibleTools(); } } } else if (currentTool == Tool.Create) { if (Input.GetKey(KeyCode.Mouse0) && Input.GetKey(KeyCode.LeftShift) && Time.time - lastRapidTool > 0.15f) { lastRapidTool = Time.time; RaycastHit hit; var ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { int x = Mathf.FloorToInt(hit.point.x + hit.normal.x / 2); int y = Mathf.FloorToInt(hit.point.y + hit.normal.y / 2); int z = Mathf.FloorToInt(hit.point.z + hit.normal.z / 2); ModelManager.AddCube(x, y, z); UndoManager.AddAction(new CreateBlockAction(x, y, z, ColorpickerController.GetClosestColor().GetAsIndex())); } } else if (Input.GetKeyDown(KeyCode.Mouse0)) { RaycastHit hit; var ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { int x = Mathf.FloorToInt(hit.point.x + hit.normal.x / 2); int y = Mathf.FloorToInt(hit.point.y + hit.normal.y / 2); int z = Mathf.FloorToInt(hit.point.z + hit.normal.z / 2); ModelManager.AddCube(x, y, z); UndoManager.AddAction(new CreateBlockAction(x, y, z, ColorpickerController.GetClosestColor().GetAsIndex())); } else { var point = ray.GetPoint(5); int x = Mathf.FloorToInt(point.x); int y = Mathf.FloorToInt(point.y); int z = Mathf.FloorToInt(point.z); ModelManager.AddCube(x, y, z); UndoManager.AddAction(new CreateBlockAction(x, y, z, ColorpickerController.GetClosestColor().GetAsIndex())); } } } else if (currentTool == Tool.Destroy) { if (Input.GetKey(KeyCode.Mouse0) && Input.GetKey(KeyCode.LeftShift) && Time.time - lastRapidTool > 0.15f) { lastRapidTool = Time.time; RaycastHit hit; var ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { int x = Mathf.FloorToInt(hit.point.x + hit.normal.x / -2); int y = Mathf.FloorToInt(hit.point.y + hit.normal.y / -2); int z = Mathf.FloorToInt(hit.point.z + hit.normal.z / -2); int color = ModelManager.GetCubeColor(x, y, z); ModelManager.RemoveCube(x, y, z); UndoManager.AddAction(new RemoveBlockAction(x, y, z, color)); } } else if (Input.GetKeyDown(KeyCode.Mouse0)) { RaycastHit hit; var ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { int x = Mathf.FloorToInt(hit.point.x + hit.normal.x / -2); int y = Mathf.FloorToInt(hit.point.y + hit.normal.y / -2); int z = Mathf.FloorToInt(hit.point.z + hit.normal.z / -2); int color = ModelManager.GetCubeColor(x, y, z); ModelManager.RemoveCube(x, y, z); UndoManager.AddAction(new RemoveBlockAction(x, y, z, color)); } } } else if (currentTool == Tool.Paint) { if (Input.GetKey(KeyCode.Mouse0)) { RaycastHit hit; var ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { int x = Mathf.FloorToInt(hit.point.x + hit.normal.x / -2); int y = Mathf.FloorToInt(hit.point.y + hit.normal.y / -2); int z = Mathf.FloorToInt(hit.point.z + hit.normal.z / -2); int color = ModelManager.GetCubeColor(x, y, z); int colorpickerValue = ColorpickerController.GetClosestColor().GetAsIndex(); if (color != colorpickerValue) { UndoManager.AddAction(new PaintBlockAction(x, y, z, color, ColorpickerController.GetClosestColor().GetAsIndex())); ModelManager.AddCube(x, y, z); } } } } else if (currentTool == Tool.Colorpicker) { if (Input.GetKeyDown(KeyCode.Mouse0)) { RaycastHit hit; var ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { int x = Mathf.FloorToInt(hit.point.x + hit.normal.x / -2); int y = Mathf.FloorToInt(hit.point.y + hit.normal.y / -2); int z = Mathf.FloorToInt(hit.point.z + hit.normal.z / -2); int color = ModelManager.GetCubeColor(x, y, z); int paletteWidth = ColorPaletteManager.GetPaletteWidth(); ColorpickerController.SetColor(color % paletteWidth, Mathf.FloorToInt(color / paletteWidth)); } } } if (Input.GetKeyDown(KeyCode.Mouse1)) { CursorController.AddUser("mainLook"); isLooking = true; } if (Input.GetKeyUp(KeyCode.Mouse1)) { CursorController.RemoveUser("mainLook"); isLooking = false; } if (Input.GetKeyDown(KeyCode.LeftShift)) { movementSpeed = 0.35f; } if (Input.GetKeyUp(KeyCode.LeftShift)) { movementSpeed = 0.175f; } }
void Awake() { transformController = GameObject.FindGameObjectWithTag("Player").GetComponent <TransformController> (); }
public MoveStep(TransformController positionController, Direction direction) { this.positionController = positionController; this.direction = direction; }
void Awake() { transformController = GameObject.FindGameObjectWithTag("Player").GetComponent <TransformController> (); rampBottom.mass = biasStartsAtBottom ? massBias : massBase; rampTop.mass = biasStartsAtBottom ? massBase : massBias; }
void Awake() { transformController = GetComponent <TransformController> (); laserDiffuser = GetComponentInChildren <LaserDiffuser> (); }
public static void ReceiveMessage() { if (ClientSocket.Poll(-1, SelectMode.SelectRead)) { byte[] head = new byte[4]; ClientSocket.Receive(head); int n = TransformController.BytesToInt(head, 0); for (int i = 0; i < n; i++) { if (ClientSocket.Poll(-1, SelectMode.SelectRead)) { ClientSocket.Receive(head); //for (int j = 0; j < 4; j++) Debug.Log(j + " " + head[j]); int bodyLength = TransformController.BytesToInt(head, 0); byte[] body = new byte[bodyLength]; if (ClientSocket.Poll(-1, SelectMode.SelectRead)) { ClientSocket.Receive(body); Msg recv = TransformController.Deserialize <Msg>(body); clientFrame = recv.Frame; //Debug.Log("Optype = " + recv.Optype); //Debug.Log("Username = "******"clientFrame = " + clientFrame); int playerId = PlayerMap[recv.Username]; //Debug.Log("username = "******"playerid = " + playerId); //Debug.Log("playerid hearusername = "******"username hereplayerid = " + playerMap[recv.Username]); if ((recv.Optype & (1 << 3)) != 0) // Move { Vector3 move = new Vector3(recv.Posx, recv.Posy, recv.Posz); PlayerPos[playerId] += move; //Debug.Log(recv.Username + " " + move); //Vector3 trans = new Vector3(forward.x, forward.y, forward.z); //Debug.Log(nowPos + " " + trans); //IsWalking[playerId] = (recv.Posx != 0) || (recv.Posz != 0); IsWalking[playerId] = !Mathf.Approximately(recv.Posx, 0f) || !Mathf.Approximately(recv.Posz, 0f); //Debug.Log(recv.Posx + " " + recv.Posz + (!Mathf.Approximately(recv.Posx, 0f) || !Mathf.Approximately(recv.Posz, 0f))); } for (int j = 0; j < skills.skill_config_list.Count; j++) { if (clientFrame < SkillAnimation[playerId][j]) { IsSkill[playerId][j] = true; } else { IsSkill[playerId][j] = false; } } bool nowState = false; for (int j = 0; j < 2; j++) { nowState |= IsSkill[playerId][j]; } if (nowState == false) { if (clientFrame >= SkillNextFrame[playerId][0]) // Skill0 //Debug.Log(recv.Username); { Skill_data skill0 = skills.skill_config_list[0]; if ((recv.Optype & (1 << 4)) != 0) { //List<int> skillFrame = skillAttackFrame[playerId]; List <int> skillFrame = skill0.skill_attack_frame; foreach (int x in skillFrame) { //Skill newSkill = new Skill(playerId, clientFrame + x - 1, playerPos[playerId], skillAreaType[playerId], skillRadius[playerId], skillDamage[playerId]); Skill newSkill = new Skill(playerId, clientFrame + x - 1, PlayerPos[playerId], skill0.skill_area_type, skill0.skill_radius, skill0.skill_damage); AllSkillRelease.Add(newSkill); } //skillNextFrame[playerId] = clientFrame + skillCoolDown[playerId] - 1; SkillNextFrame[playerId][0] = clientFrame + skill0.skill_cool_down - 1; //skillAnimation[playerId] = clientFrame + skillTotFrame[playerId] - 1; SkillAnimation[playerId][0] = clientFrame + skill0.skill_tot_frame - 1; IsSkill[playerId][0] = true; } } if (clientFrame >= SkillNextFrame[playerId][1]) // Skill1 { Skill_data skill1 = skills.skill_config_list[1]; if ((recv.Optype & (1 << 5)) != 0) { List <int> skillFrame = skill1.skill_attack_frame; /*foreach (int x in skillFrame) { * Skill newSkill = new Skill(playerId, clientFrame + x - 1, PlayerPos[playerId], skill1.skill_area_type, skill1.skill_radius, skill1.skill_damage); * AllSkillRelease.Add(newSkill); * }*/ SkillNextFrame[playerId][1] = clientFrame + skill1.skill_cool_down - 1; SkillAnimation[playerId][1] = clientFrame + skill1.skill_tot_frame - 1; IsSkill[playerId][1] = true; } } for (int j = AllSkillRelease.Count - 1; j >= 0; j--) { Skill nowSkill = AllSkillRelease[j]; if (nowSkill.attackFrame == clientFrame) { for (int k = 0; k < PlayerName.Count; k++) { int nowPlayerId = PlayerMap[PlayerName[k]]; //Debug.Log("nowPlayerId = " + nowPlayerId + ", nowplayerName = " + playerName[nowPlayerId]); //Debug.Log("playerId = " + playerId + ", playerName = " + recv.Username); //Debug.Log("releasePosition = " + nowSkill.releasePosition + ", playerPosition = " + playerPos[nowPlayerId]); if (nowPlayerId != nowSkill.releasePlayerIndex && IsDie[nowPlayerId] == false) { //Debug.Log("dddddd"); bool releaseTag = false; if (nowSkill.areaType == 1 && (nowSkill.releasePosition - PlayerPos[nowPlayerId]).sqrMagnitude <= nowSkill.radius) { releaseTag = true; } if (releaseTag == true) { NowHealthPoint[nowPlayerId] -= nowSkill.damage; if (NowHealthPoint[nowPlayerId] < 0) { NowHealthPoint[nowPlayerId] = 0; IsDie[nowPlayerId] = true; } } } } AllSkillRelease.Remove(AllSkillRelease[j]); } } } } } } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); WorldSpace.AddDrawableGroup(new ControllerDrawableGroup(1, "Controller", RenderContext)); KeyPreview = true; KinectDeviceManager dev = null; //BasicGrid grid=new BasicGrid(); //grid.Load(RenderContext); Controller = new TransformController(RenderContext, ScreenContext.HitChekcer); WorldSpace.AddResource(Controller, "Controller"); //if (!String.IsNullOrEmpty(Settings.Default.InitLoadModel)) //{ // MMDModel model = MMDModelWithPhysics.OpenLoad(Settings.Default.InitLoadModel, RenderContext); // WorldSpace.AddResource(model); // if (!String.IsNullOrEmpty(Settings.Default.InitLoadMotion)) // { // model.MotionManager.ApplyMotion(model.MotionManager.AddMotionFromFile(Settings.Default.InitLoadMotion, false)); // } //} //更新する必要のあるワールドスペースは、UpdateRequireWorldsに追加しなけれbなりません。 //PlaneBoard bill = new PlaneBoard(RenderContext, resourceView, new Vector2(800, 800)); //WorldSpace.AddResource(bill); //bill.Transformer.Position = new Vector3(0, 0, 20); #region Kinectテストコード #if KINECT OpenNIManager.Initialize(); dev = OpenNIManager.getDevice(); ColTexture = new ColorTexture(RenderContext, dev); tex2 = new DepthTexture(RenderContext, 1000, dev); #endif #endregion //format = SpriteBatch.CreateTextformat("Meiriyo", 30, FontWeight.ExtraBold); //brush = SpriteBatch.CreateRadialGradientBrush(g, // new RadialGradientBrushProperties() {CenterPoint = new PointF(100,100),GradientOriginOffset = new PointF(0,0),HorizontalRadius = 100f,VerticalRadius = 200f}).Brush; //brush = SpriteBatch.CreateSolidColorBrush(Color.Aquamarine); ScreenContext.CameraMotionProvider = new BasicCameraControllerMotionProvider(this, this); BasicGrid gird = new BasicGrid(); gird.Visibility = true; gird.Load(RenderContext); ScreenContext.WorldSpace.AddResource(gird); //textureの世界には、childウィンドウに追加からできるようにしてあります。 ControlForm controlForm = new ControlForm(RenderContext, ScreenContext, null, dev); controlForm.Show(this); //OpenFileDialog ofd = new OpenFileDialog(); //if (ofd.ShowDialog() == DialogResult.OK) //{ // VMDCameraMotionProvider camMotion=VMDCameraMotionProvider.OpenFile(ofd.FileName); // ScreenContext.CameraMotionProvider = camMotion; // camMotion.Start(); //} #region Kinectテストコード #if KINECT PlaneBoard bill = new PlaneBoard(RenderContext, ColTexture.TextureResourceView); bill.Transformer.Position = new Vector3(0, 0, 50); //bill.Transformer.Rotation *= Quaternion.RotationAxis(new Vector3(0,1,0),(float) (Math.PI)); form.WorldSpace.AddResource(bill); form.WorldSpace.AddDynamicTexture(ColTexture); #endif #endregion }
public void OnLoginClick() { string username = user_name.text; string userpwd = user_pwd.text; msg.Optype = (1 << 0); msg.Username = username; msg.Userpwd = userpwd; //Controller.SetIPEndPoint(new IPEndPoint(IPAddress.Parse("118.89.189.165"), 3360)); //Controller.SetSocket(new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)); ServerEndPoint = new IPEndPoint(IPAddress.Parse("118.89.189.165"), 3360); // Connect to server IP and port ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // Client communication socket try { ClientSocket.Connect(ServerEndPoint); //Controller.GetSocket().Connect(Controller.GetIPEndPoint()); Debug.Log("Successfully connected to the server"); } catch (Exception e) { Debug.Log(e.Message); } ClientSocket.Blocking = false; byte[] sendMsg = TransformController.Transform(msg); if (ClientSocket.Poll(-1, SelectMode.SelectWrite)) { ClientSocket.Send(sendMsg); } if (ClientSocket.Poll(-1, SelectMode.SelectRead)) { ClientSocket.Receive(sendMsg); if (sendMsg[0] == '2') { Debug.Log("login success"); // save user name PlayerPrefs.SetString("username", username); // save socket GlobalController.instance.ClientSocket = ClientSocket; // load new scene SceneManager.LoadScene("DN_LV2_2_4"); //SceneManager.LoadScene("PlayScene"); } else { if (sendMsg[0] == '1') { Debug.Log("user not found"); } else if (sendMsg[0] == '3') { Debug.Log("user already login"); } else if (sendMsg[0] == '4') { Debug.Log("password wrong"); } ClientSocket.Close(); //Controller.GetSocket().Close(); } } }
public TurnTakerController(Transform transform, GameMap map, int initialRow, int initialCol) { controller = new TransformController(transform, map, initialRow, initialCol); }
private void ApplyTransformation() { TransformController transformController = MoveObject.GetComponent <TransformController>(); transformController.RotateFragment(Quaternion.Euler(ExpectedRotationEulerUnity), Fragments.transform); }