public virtual void doFire(CLUnit attacker, CLUnit target, Vector3 orgPos, Vector3 dir, object attr, object data, object callbak) { this.attr = attr; this.data = data; this.attacker = attacker; this.target = target; onFinishCallback = callbak; int SpeedRandomFactor = MapEx.getBytes2Int(attr, "SpeedRandomFactor"); // int SpeedRandomFactor = NumEx.bio2Int (MapEx.getBytes (attr, "SpeedRandomFactor")); speed = MapEx.getBytes2Int(attr, "Speed") / 10.0f; // speed = (NumEx.bio2Int (MapEx.getBytes (attr, "Speed"))) / 10.0f; if (SpeedRandomFactor > 0) { speed = speed + attacker.fakeRandom(-SpeedRandomFactor, SpeedRandomFactor) / 100.0f; } high = MapEx.getBytes2Int(attr, "High") / 10.0f; // high = NumEx.bio2Int (MapEx.getBytes (attr, "High")); if (MapEx.getBool(attr, "IsHighOffset")) { high = high * (1.0f + attacker.fakeRandom(-200, 200) / 1000.0f); } bool isZeroY = high > 0 ? true : false; float dis = MapEx.getBytes2Int(attr, "Range") / 10.0f; // float dis = NumEx.bio2Int (MapEx.getBytes (attr, "Range")) / 10.0f; isFollow = MapEx.getBool(attr, "IsFollow"); isMulHit = MapEx.getBool(attr, "IsMulHit"); needRotate = MapEx.getBool(attr, "NeedRotate"); RefreshTargetMSec = MapEx.getBytes2Int(attr, "RefreshTargetMSec"); lastResetTargetTime = DateEx.nowMS; lastResetToPosTime = DateEx.nowMS; //dir.y = 0; Utl.RotateTowards(transform, dir); origin = orgPos; transform.position = origin; Vector3 toPos = Vector3.zero; if (target != null && dis <= 0) { toPos = target.transform.position; } else { toPos = origin + dir.normalized * dis; //toPos.y = 0; } int PosRandomFactor = MapEx.getBytes2Int(attr, "PosRandomFactor"); // int PosRandomFactor = NumEx.bio2Int (MapEx.getBytes (attr, "PosRandomFactor")); if (PosRandomFactor > 0) { toPos.x += attacker.fakeRandom(-PosRandomFactor, PosRandomFactor) / 100.0f; toPos.y += attacker.fakeRandom(-PosRandomFactor, PosRandomFactor) / 100.0f; } //if (isZeroY) { // toPos.y = 0; //} if (boxCollider != null) { if (MapEx.getBool(attr, "CheckTrigger")) { boxCollider.enabled = true; } else { boxCollider.enabled = false; } } haveCollider = (boxCollider != null && boxCollider.enabled); v3Diff = toPos - origin; if (angleOffset != 0) { Vector3 center = origin + v3Diff / 2.0f; // transform.position = center + new Vector3 (0, high, 0); Vector3 _v3 = Utl.RotateAround(center + new Vector3(0, high, 0), center, v3Diff, angleOffset * Mathf.Sin(Mathf.Deg2Rad * Utl.getAngle(v3Diff).y)); // transform.RotateAround (center, v3Diff, angleOffset * Mathf.Sin (Mathf.Deg2Rad * Utl.getAngle (v3Diff).y)); highV3 = _v3 - center; } else { highV3 = new Vector3(0, high, 0); } magnitude = v3Diff.magnitude <= 0.00001f ? 1 : 1.0f / v3Diff.magnitude; hitTarget = null; curveTime = 0; curveTime2 = 0; isStoped = false; isFireNow = true; RotateBullet(); CancelInvoke("timeOut"); int stayTime = MapEx.getBytes2Int(attr, "MaxStayTime"); // int stayTime = NumEx.bio2Int (MapEx.getBytes (attr, "MaxStayTime")); if (stayTime > 0.00001) { Invoke("timeOut", stayTime / 10.0f); } }