{ "code": "var Vector3 = Laya.Vector3;\r\nexport class TextData {\r\n constructor(_message, _pos, _size, _fontSize, _color = null) {\r\n this.fontSize = 30;\r\n this.message = \"\";\r\n this.size = new Laya.Vector2(_size.x, _size.y);\r\n this.fontSize = _fontSize;\r\n this.color = _color;\r\n this.message = _message;\r\n this.pos = _pos;\r\n }\r\n}\r\nexport class GameUtils {\r\n static Vector3MulNumber(v3, f) {\r\n return new Vector3(v3.x * f, v3.y * f, v3.z * f);\r\n }\r\n static angleToEangle(_angle) {\r\n return _angle * Math.PI / 180;\r\n }\r\n static absEangle(_angle) {\r\n var x = _angle.x;\r\n if (x == -0) {\r\n x = 0;\r\n }\r\n var y = _angle.y;\r\n if (y == -0) {\r\n y = 0;\r\n }\r\n var z = _angle.z;\r\n if (z == -0) {\r\n z = 0;\r\n }\r\n return new Vector3(x, y, z);\r\n }\r\n static debugVector3(_vector3) {\r\n console.log(_vector3.x + \" \" + _vector3.y + \" \" + _vector3.z);\r\n }\r\n static getConverseVector3(_vector3) {\r\n return new Vector3(-_vector3.x, -_vector3.y, -_vector3.z);\r\n }\r\n static getRandomInt(left, right) {\r\n if (left >= right) {\r\n return 0;\r\n }\r\n var size = right - left + 1;\r\n var curNumber = Math.random() * size + left;\r\n return Math.floor(curNumber);\r\n }\r\n static getRandom(left, right) {\r\n if (left >= right) {\r\n return 0;\r\n }\r\n var size = right - left + 1;\r\n var curNumber = Math.random() * size + left;\r\n return curNumber;\r\n }\r\n static getRandoms(left, right) {\r\n if (left >= right) {\r\n return 0;\r\n }\r\n var size = right - left;\r\n var curNumber = Math.random() * size + left;\r\n return curNumber;\r\n }\r\n static TweenMove(targetTransform, TargetPos, duration, _completeHandle = null) {\r\n var curPos = targetTransform.position;\r\n var tween = Laya.Tween.to(curPos, { x: TargetPos.x, y: TargetPos.y, z: TargetPos.z, update: new Laya.Handler(this, function () {\r\n targetTransform.position = curPos;\r\n }) }, duration * 1000, null, Laya.Handler.create(this, function () {\r\n tween.clear();\r\n if (_completeHandle != null) {\r\n _completeHandle.run();\r\n }\r\n }));\r\n return tween;\r\n }\r\n static TweenProgress(_progress, _fromValue, _tovalue, _duration, _completeHandle = null) {\r\n _progress.value = _fromValue;\r\n var tween = Laya.Tween.to(_progress, { value: _tovalue }, _duration * 1000, null, _completeHandle);\r\n return tween;\r\n }\r\n static lerp(form, to, t) {\r\n if (t <= 0) {\r\n return form;\r\n }\r\n else if (t >= 1) {\r\n return to;\r\n }\r\n var a = t * to + (1 - t) * form;\r\n return a;\r\n }\r\n static LogVector3(name, Pos) {\r\n console.log(name + \":\" + Pos.x + \" \" + Pos.y + \" \" + Pos.z);\r\n }\r\n static LogVector2(name, Pos) {\r\n console.log(name + \":\" + Pos.x + \" \" + Pos.y);\r\n }\r\n static LogRotioion(name, Rot) {\r\n console.log(name + \":\" + Rot.x + \" \" + Rot.y + \" \" + Rot.z + \" \" + Rot.w);\r\n }\r\n static DelayToDo(_delayDuration, _doFunction, agrs = null) {\r\n Laya.timer.once(_delayDuration * 1000, this, _doFunction, [agrs], false);\r\n }\r\n static CopyDic(_obj) {\r\n var curObj = {};\r\n for (var key in _obj) {\r\n curObj[key] = _obj[key];\r\n }\r\n return curObj;\r\n }\r\n static TweenLookAtMove(targetTransform, TargetPos, lookPos, duration, _completeHandle = null) {\r\n var curPos = targetTransform.position;\r\n var tween = Laya.Tween.to(curPos, { x: TargetPos.x, y: TargetPos.y, z: TargetPos.z, update: new Laya.Handler(this, () => {\r\n targetTransform.position = curPos;\r\n var quaternion1 = new Laya.Quaternion();\r\n Laya.Quaternion.lookAt(curPos, lookPos, new Vector3(0, 1, 0), quaternion1);\r\n quaternion1.invert(quaternion1);\r\n Laya.Quaternion.slerp(targetTransform.rotation, quaternion1, 0.3, quaternion1);\r\n targetTransform.rotation = quaternion1;\r\n }) }, duration * 1000, null, Laya.Handler.create(this, function () {\r\n tween.clear();\r\n if (_completeHandle != null) {\r\n _completeHandle();\r\n }\r\n }));\r\n return tween;\r\n }\r\n static TweenGoldAward(_num, _pos = null, _completeHandle = null) {\r\n if (_num == 0)\r\n return;\r\n var parent = new Laya.Box;\r\n parent.width = 400;\r\n parent.height = 100;\r\n parent.pivotX = parent.width / 2;\r\n parent.pivotY = parent.height / 2;\r\n if (_pos == null) {\r\n _pos = new Laya.Vector2(Laya.stage.width / 2, Laya.stage.height / 2);\r\n }\r\n parent.pos(_pos.x, _pos.y);\r\n var _Image = new Laya.Image;\r\n _Image.skin = \"localview/shoujiemian_1_6_1.png\";\r\n _Image.width = 60;\r\n _Image.height = 60;\r\n _Image.left = 50;\r\n _Image.y = 10;\r\n parent.addChild(_Image);\r\n var curText = new Laya.Text;\r\n curText.width = 300;\r\n curText.height = 50;\r\n curText.align = \"center\";\r\n curText.valign = \"middle\";\r\n curText.font = \"Microsoft YaHei\";\r\n curText.fontSize = 35;\r\n curText.color = \"#ff8e00\";\r\n curText.bold = true;\r\n curText.font = \"Microsoft YaHei\";\r\n curText.text = \"金币 +\" + _num;\r\n curText.x = 60;\r\n curText.y = 10;\r\n parent.addChild(curText);\r\n Laya.stage.addChild(parent);\r\n var tween = Laya.Tween.to(parent, { y: parent.y - 200 }, 1000, Laya.Ease.expoInOut, Laya.Handler.create(this, () => {\r\n tween.clear();\r\n parent.destroy();\r\n if (_completeHandle) {\r\n _completeHandle.run();\r\n }\r\n }), 100);\r\n }\r\n static TweenText(textData, _hight, _completeHandle = null, hide = true) {\r\n var curText = new Laya.Text();\r\n curText.width = textData.size.x;\r\n curText.height = textData.size.y;\r\n curText.align = \"center\";\r\n curText.valign = \"middle\";\r\n curText.font = \"Microsoft YaHei\";\r\n curText.fontSize = textData.fontSize;\r\n curText.pivotX = curText.width / 2;\r\n curText.pivotY = curText.height / 2;\r\n curText.color = \"#5ad122\";\r\n curText.bold = true;\r\n curText.stroke = 5;\r\n curText.strokeColor = \"#ffffff\";\r\n if (textData.color) {\r\n textData.color = textData.color;\r\n }\r\n curText.text = textData.message;\r\n curText.zOrder = 1;\r\n Laya.stage.addChild(curText);\r\n curText.pos(textData.pos.x, textData.pos.y);\r\n var tween = Laya.Tween.to(curText, { y: curText.y - _hight, update: new Laya.Handler(this, function () {\r\n }) }, 500, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {\r\n tween.clear();\r\n if (hide) {\r\n curText.destroy();\r\n }\r\n if (_completeHandle) {\r\n _completeHandle.run();\r\n }\r\n }));\r\n if (hide) {\r\n Laya.Tween.to(curText, { alpha: 0.4 }, 500);\r\n }\r\n return curText;\r\n }\r\n static GetMoney(_num, _pos = null, _completeHandle = null) {\r\n if (_num == 0)\r\n return;\r\n var fafaafsfa = new Laya.Box;\r\n fafaafsfa.width = 400;\r\n fafaafsfa.height = 100;\r\n fafaafsfa.pivotX = fafaafsfa.width / 2;\r\n fafaafsfa.pivotY = fafaafsfa.height / 2;\r\n if (_pos == null) {\r\n _pos = new Laya.Vector2(Laya.stage.width / 2, Laya.stage.height / 2);\r\n }\r\n fafaafsfa.pos(_pos.x, _pos.y);\r\n var aafafaffa = new Laya.Image;\r\n aafafaffa.skin = \"sign/qiandao_1_5_4.png\";\r\n aafafaffa.width = 60;\r\n aafafaffa.height = 60;\r\n aafafaffa.left = 50;\r\n aafafaffa.y = 10;\r\n fafaafsfa.addChild(aafafaffa);\r\n var faasfafsafs = new Laya.Text;\r\n faasfafsafs.width = 300;\r\n faasfafsafs.height = 50;\r\n faasfafsafs.align = \"center\";\r\n faasfafsafs.valign = \"middle\";\r\n faasfafsafs.font = \"Microsoft YaHei\";\r\n faasfafsafs.fontSize = 35;\r\n faasfafsafs.color = \"#ff8e00\";\r\n faasfafsafs.bold = true;\r\n faasfafsafs.font = \"Microsoft YaHei\";\r\n faasfafsafs.text = \"金币 +\" + _num;\r\n faasfafsafs.x = 60;\r\n faasfafsafs.y = 10;\r\n fafaafsfa.addChild(faasfafsafs);\r\n Laya.stage.addChild(fafaafsfa);\r\n var faasfsaf = Laya.Tween.to(fafaafsfa, { y: fafaafsfa.y - 200 }, 1000, Laya.Ease.expoInOut, Laya.Handler.create(this, () => {\r\n faasfsaf.clear();\r\n fafaafsfa.destroy();\r\n if (_completeHandle) {\r\n _completeHandle.run();\r\n }\r\n }), 100);\r\n }\r\n}\r\n", "references": [] }