private void InputHandler() { forwardValue = (Input.GetKey(forward) ? Fixed.one : Fixed.zero) - (Input.GetKey(back) ? Fixed.one : Fixed.zero); rightValue = (Input.GetKey(right) ? Fixed.one : Fixed.zero) - (Input.GetKey(left) ? Fixed.one : Fixed.zero); vertical = Input.GetAxis(verticalAxis).ToFixed(); horizontal = Input.GetAxis(horizontalAxis).ToFixed(); atkState = Input.GetButton(atk); crounchState = Input.GetButton(crounch); skillQState = Input.GetButton(skillQ); jumpState = Input.GetButton(jump); keyMap[GameKeyCode.ATK] = atkState; keyMap[GameKeyCode.CROUNCH] = crounchState; keyMap[GameKeyCode.SKILLQ] = skillQState; keyMap[GameKeyCode.JUMP] = jumpState; if (invertY) { vertical = -vertical; } if (invertX) { horizontal = -horizontal; } Direction = new Fixed2(forwardValue, rightValue); MouseDirection = new Fixed2(horizontal, vertical); }
public static Fixed2 Support(ShapeBase a, ShapeBase b, Fixed2 dir) { Fixed2 p1 = a.Support(dir); Fixed2 p2 = b.Support(dir); return(p1 - p2); }
private void Update() { if (!useKey || isDown) { return; } Vector3 pos = new Vector3(); if (Input.GetKey(left)) { pos.x -= 1; } if (Input.GetKey(right)) { pos.x += 1; } if (Input.GetKey(down)) { pos.y -= 1; } if (Input.GetKey(up)) { pos.y += 1; } moveObj.transform.position = transform.position + pos.normalized * maxScale; Vector3 tmp = GetVector3(); dir = new Fixed2(tmp.x, tmp.y); }
void PcControl() { if (!useKey || onDrag) { return; } Vector3 pos = new Vector3(); isDown = false; if (Input.GetKey(left)) { pos.x -= 1; isDown = true; } if (Input.GetKey(right)) { pos.x += 1; isDown = true; } if (Input.GetKey(down)) { pos.y -= 1; isDown = true; } if (Input.GetKey(up)) { pos.y += 1; isDown = true; } moveObj.transform.position = transform.position + pos.normalized * maxScale; Vector3 tmp = GetVector3(); dir = new Fixed2(tmp.x, tmp.y); }
public void FixedTest() { Observation o = new Observation(); { Fixed n = Fixed.Create(o); { Assert.True(n.Identifier.Get(out Identifier value) == true); Assert.True(value.System == "fixedIdentifierSystem"); Assert.True(value.Value == "fixedIdentifierValue"); } { Assert.True(n.Code.Get(out CodeableConcept value) == true); Assert.True(value.Coding.Count() == 1); Assert.True(value.Coding.First().System == "codeSystem"); Assert.True(value.Coding.First().Code == "codeCode"); Assert.True(value.Coding.First().Display == "codeDisplay"); Assert.True(value.Text == "codeText"); } { Assert.True(n.Status.Get(out Code <ObservationStatus> status) == true); Assert.True(status.Value == ObservationStatus.Cancelled); } } { Fixed1 n = Fixed1.Create(o); { Assert.True(n.Effective.Get(out FhirDateTime value) == true); DateTimeOffset v = value.ToDateTimeOffset(new TimeSpan(0)); Assert.True(v.Year == 1002); Assert.True(v.Month == 1); Assert.True(v.Day == 2); Assert.True(v.Hour == 3); Assert.True(v.Minute == 4); Assert.True(v.Second == 5); } { Assert.True(n.Value.Get(out Quantity value) == true); Assert.True(value.Value == 10); Assert.True(value.System == "www.things.com"); Assert.True(value.Code == "things"); } } { Fixed2 n = Fixed2.Create(o); { Assert.True(n.Effective.Get(out Period value) == true); Assert.True(value.Start == "1002-01-02"); Assert.True(value.End == "1003-04-05"); } { Assert.True(n.Value.Get(out FhirBoolean value) == true); Assert.True(value.Value == true); } } }
public static void ShootBullet(NetData netData, Fixed2 position, Fixed rotation) { Bullet bullet = new Bullet(); bullet.user = netData; bullet.Init(netData.client); bullet.Reset(position, rotation); netData.client.objectManager.Instantiate(bullet); }
public BoxShap(FixedNumber x, FixedNumber y) { Fixed2[] v2s = new Fixed2[4]; v2s[0] = new Fixed2(x / 2, y / 2); v2s[1] = new Fixed2(-x / 2, y / 2); v2s[2] = new Fixed2(x / 2, -y / 2); v2s[3] = new Fixed2(-x / 2, -y / 2); Points = v2s; }
protected virtual void ShootBullet(Fixed2 position, FixedNumber rotation) { Bullet data = new Bullet(); data.user = this.user; data.Init(user.client); data.Reset(position, rotation); user.client.objectManager.Instantiate(data); }
protected void ShootBullet(Fixed2 position, FixedNumber rotation) { Bullet bullet = new Bullet(); bullet.user = data; bullet.Init(); bullet.Reset(position, rotation); NetObjectManager.Instantiate <Bullet>(bullet); // UnityEngine.Debug.LogError("bullet" + rotation); }
public void OnBeginDrag(PointerEventData eventData) { isDown = true; Vector3 tmp = GetVector3(); dir = new Fixed2(tmp.x, tmp.y); if (BeginMove != null) { BeginMove(); } }
protected void ShootBullet(Fixed2 position, Fixed rotation, SkillNode skillnode, ISkillNodeRun run) { Bullet bullet = new Bullet(); bullet.skillNode = skillnode; bullet.skill = run.skill; bullet.user = netData; bullet.Init(netData.client); bullet.Reset(position, rotation); netData.client.objectManager.Instantiate(bullet); }
protected override void FrameUpdate() { // Debug.LogError("move"+Input.GetKey(IDG.KeyNum.MoveKey) ); Fixed2 move = Input.GetKey(IDG.KeyNum.MoveKey) ? Input.GetJoyStickDirection(IDG.KeyNum.MoveKey):Fixed2.zero; // Debug.LogError("move"+move); transform.Position += move * deltaTime; if (move.x != 0 || move.y != 0) { transform.Rotation = move.ToRotation(); } }
public Rectangle(Fixed x, Fixed y, Fixed width, Fixed height) { this.width = width; this.height = height; this.center = new Fixed2(x, y); points = new List <Fixed2>(); points.Add(new Fixed2(center.x - width, center.y - height)); points.Add(new Fixed2(center.x + width, center.y - height)); points.Add(new Fixed2(center.x + width, center.y + height)); points.Add(new Fixed2(center.x - width, center.y + height)); }
private Fixed2 SquareToCircle(Fixed2 v) { Fixed x = v.x; Fixed y = v.y; Fixed sqrtX = v.x * v.x; Fixed sqrtY = v.y * v.y; x = x * Fixed.Sqrt(Fixed.one - sqrtX / two); y = y * Fixed.Sqrt(Fixed.one - sqrtY / two); return(new Fixed2(x, y)); }
void PcControl() { if (!useKey || onDrag || unityClient.client.localPlayer == null) { return; } isDown = Input.GetKey(pcKey); Vector3 pos = Input.mousePosition - unityClient.mainCamera.WorldToScreenPoint(unityClient.client.localPlayer.view.transform.position); moveObj.transform.position = transform.position + pos.normalized * maxScale; Vector3 tmp = GetVector3(); dir = new Fixed2(tmp.x, tmp.y); }
public CircleShap(FixedNumber r, int num) { FixedNumber t360 = new FixedNumber(360); FixedNumber tmp = t360 / num; Fixed2[] v2s = new Fixed2[num]; int i = 0; for (FixedNumber tr = new FixedNumber(0); tr < t360 && i < num; tr += tmp, i++) { v2s[i] = Fixed2.Parse(tr) * r; } Points = v2s; }
public void OnBeginDrag(PointerEventData eventData) { isDown = true; onDrag = true; if (moveToPointDownPos) { backTransform.position = eventData.position; } Vector3 tmp = GetVector3(); dir = new Fixed2(tmp.x, tmp.y); if (BeginMove != null) { BeginMove(); } }
public bool DontHasPath(Fixed2 dir) { var others = player.client.physics.OverlapShap(new ShapBase(player.Shap.GetPoints(), player.transform.Position + dir.normalized * 0.5f.ToFixed(), dir.ToRotation())); if (others.Contains(player)) { others.Remove(player); } if (others.Count > 0) { return(true); } else { return(false); } }
public void Fire(Fixed2 position, FixedNumber rotation) { var t = InputCenter.Time - lastTime; if (t > gunSetting.fireRate) { timer += (gunSetting.recoilTime + gunSetting.fireRate - t); if (timer <= 0) { timer = new FixedNumber(0); } FixedNumber rote = new FixedNumber(gunSetting.recoilFrouceCurve.Evaluate(timer.ToFloat()) - 1) * gunSetting.recoilScale; lastTime = InputCenter.Time; ShootBullet(position, rotation + rote); } else { } }
protected void ShootBullet(Fixed2 position, Fixed2 direction) { UnityEngine.Debug.DrawRay(position.ToVector3(), direction.ToVector3() * 10, UnityEngine.Color.red, 0.1f); var others = data.client.physics.OverlapShap(ray.ResetDirection(position, direction, new FixedNumber(10))); foreach (var other in others) { if (other != data) { if (other is HealthData) { (other as HealthData).GetHurt(new FixedNumber(10)); } } } //Bullet bullet = new Bullet(); //bullet.user = data; //bullet.Init(data .client); //bullet.Reset(position, rotation); //data.client.objectManager.Instantiate(bullet); }
public Fixed2 Support(Fixed2 dir) { int index = 0; Fixed maxDot, t; Fixed2 p; p = this[index]; maxDot = Fixed2.Dot(p, dir); for (; index < points.Length; index++) { t = Fixed2.Dot(this[index], dir); if (t > maxDot) { maxDot = t; p = this[index]; } } return(p + Center); }
public void OnInit(BattleNetworkHandler handler) { var playerPos = new Fixed2(handler.random.Range(0, 20), handler.random.Range(0, 20)); for (int i = 0; i < player; i++) { var netObj = new CharacterNetController(); netObj.Init(handler, i); netObj.prefab = "Player1"; var col = netObj.AddComponent <BoxCollision>(); col.width = 1.ToFixed(); col.height = 1.ToFixed(); var localPos = playerPos + Fixed2.left * i.ToFixed() * 10.ToFixed(); netObj.transform.position = new Fixed3(localPos.x, Fixed.zero, localPos.y); netObj.InstantiateGameObject(); } }
public void OnDrag(PointerEventData eventData) { Vector3 movePos = eventData.position; movePos = movePos - backTransform.position; if (movePos.magnitude > maxScale) { movePos = movePos.normalized * maxScale; } else { } moveObj.position = backTransform.position + movePos; Vector3 tmp = GetVector3(); dir = new Fixed2(tmp.x, tmp.y); if (OnMove != null) { OnMove(Direction()); } }
public void PhysicsEffect() { if (data.Shap == null) { return; } if (data.isTrigger || !data.rigibody.CheckCollision(data)) { if (_position != _lastPos || _rotation != _lastRota) { _lastPos = _position; _lastRota = _rotation; data.Shap.ResetSize(); Tree4.Move(data); } } else { _rotation = _lastRota; _position = _lastPos; } }
public void Init(FSClient client) { var map = client.GetManager <RandomMapCreator>(); var playerPos = Fixed2.zero; if (map) { playerPos = map.GetRandomPos(); } else { playerPos = new Fixed2(client.random.Range(0, 20), client.random.Range(0, 20)); } int count = GameUser.user.fightRoom.playerInfos.Count; for (int i = 0; i < count; i++) { var player = new PlayerData(); player.Init(client, i); if (map != null) { player.transform.Position = playerPos + Fixed2.left * i.ToFixed(); } else { player.transform.Position = new IDG.Fixed2(0, i); } client.objectManager.Instantiate(player); } for (int i = 0; i < m_nItemCount; i++) { ItemData item; if (i % 2 == 0) { var Titem = new SkillItem(); item = Titem; Titem.Init(client); if (client.random.Range(0, 100) < 50) { Titem.skillId = SkillId.拳击右直; } else { Titem.skillId = SkillId.拳击左直; } } else { var Titem = new WeaponItem(); item = Titem; Titem.Init(client); Titem.weaponId = WeaponId.F57; } if (map) { item.transform.Position = map.GetRandomPos(); } else { item.transform.Position = new Fixed2(client.random.Range(0, 20), client.random.Range(0, 20)); } client.objectManager.Instantiate(item); } for (int i = 0; i < enemy; i++) { var item = new ZombieData(); item.Init(client); if (map) { item.transform.Position = map.GetRandomPos(); } else { item.transform.Position = new Fixed2(client.random.Range(0, 20), client.random.Range(0, 20)); } client.objectManager.Instantiate(item); } }
public void ReceviceStep(INetworkProtocol protocol) { Direction = protocol.GetVector2(); }
public void OnEnd(Fixed2 fixed2) { dirTarget.SetActive(false); }
public void Reset(Fixed2 position, FixedNumber rotation) { transform.Reset(position, rotation); }
public static Fixed Dot(Fixed2 a, Fixed2 b) { return(a.x * b.x + a.y * b.y); }
public Fixed Dot(Fixed2 b) { return(Dot(this, b)); }