init
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import { _decorator, Node, Toggle } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { ViewManager } from '../../Main/Manager/ViewManager';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import PlayerDataManager from '../../Main/Manager/PlayerDataManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//设置界面
|
||||
@ccclass('Setting_UI')
|
||||
export class Setting extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
private _musicOn: boolean = true; //音乐开关
|
||||
private _soundOn: boolean = true; //音效开关
|
||||
private tgMusic: Toggle = null;
|
||||
private tgSound: Toggle = null;
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
// Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
GButton.BandClick(this._nodeTab.bgmask, ()=>{
|
||||
this.onClose()
|
||||
}, this);
|
||||
GButton.BandClick(this._nodeTab.btnClose, ()=>{
|
||||
this.onClose()
|
||||
}, this);
|
||||
// GButton.BandClick(this._nodeTab.tgMusic, ()=>{
|
||||
// this.onClose()
|
||||
// }, this);
|
||||
// GButton.BandClick(this._nodeTab.tgSound, ()=>{
|
||||
// this.onClose()
|
||||
// }, this);
|
||||
|
||||
this.tgMusic = this._nodeTab.tgMusic.getComponent(Toggle);
|
||||
this.tgSound = this._nodeTab.tgSound.getComponent(Toggle);
|
||||
|
||||
this.tgMusic.isChecked = PlayerDataManager.I.IsMusicOn;
|
||||
this.tgSound.isChecked = PlayerDataManager.I.IsSoundOn;
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//背景乐开关,在UI里设置
|
||||
onTgMusicClick(tg:any, ev:any) {
|
||||
PlayerDataManager.I.SetMusicOn(this.tgMusic.isChecked)
|
||||
}
|
||||
//音效开关,在UI里设置
|
||||
onTgSoundClick(tg:any, ev:any) {
|
||||
PlayerDataManager.I.SetSoundOn(this.tgSound.isChecked)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "878291a6-00e5-40f4-816e-a24b332882cf",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "878291a6-00e5-40f4-816e-a24b332882cf@6c48a",
|
||||
"displayName": "guihua_disgust",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "878291a6-00e5-40f4-816e-a24b332882cf",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "878291a6-00e5-40f4-816e-a24b332882cf@f9941",
|
||||
"displayName": "guihua_disgust",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": -23.5,
|
||||
"offsetY": -22.5,
|
||||
"trimX": 69,
|
||||
"trimY": 45,
|
||||
"width": 740,
|
||||
"height": 1144,
|
||||
"rawWidth": 925,
|
||||
"rawHeight": 1189,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-370,
|
||||
-572,
|
||||
0,
|
||||
370,
|
||||
-572,
|
||||
0,
|
||||
-370,
|
||||
572,
|
||||
0,
|
||||
370,
|
||||
572,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
69,
|
||||
1144,
|
||||
809,
|
||||
1144,
|
||||
69,
|
||||
0,
|
||||
809,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0.0745945945945946,
|
||||
0,
|
||||
0.8745945945945945,
|
||||
0,
|
||||
0.0745945945945946,
|
||||
0.9621530698065601,
|
||||
0.8745945945945945,
|
||||
0.9621530698065601
|
||||
],
|
||||
"minPos": [
|
||||
-370,
|
||||
-572,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
370,
|
||||
572,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "878291a6-00e5-40f4-816e-a24b332882cf@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "878291a6-00e5-40f4-816e-a24b332882cf@6c48a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "c11affc3-eadc-4651-95b4-3adb7d39dbf8",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "c11affc3-eadc-4651-95b4-3adb7d39dbf8@6c48a",
|
||||
"displayName": "adelle_beaumont_disgust",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "c11affc3-eadc-4651-95b4-3adb7d39dbf8",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "c11affc3-eadc-4651-95b4-3adb7d39dbf8@f9941",
|
||||
"displayName": "adelle_beaumont_disgust",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": -3.5,
|
||||
"offsetY": -23,
|
||||
"trimX": 60,
|
||||
"trimY": 46,
|
||||
"width": 798,
|
||||
"height": 1143,
|
||||
"rawWidth": 925,
|
||||
"rawHeight": 1189,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-399,
|
||||
-571.5,
|
||||
0,
|
||||
399,
|
||||
-571.5,
|
||||
0,
|
||||
-399,
|
||||
571.5,
|
||||
0,
|
||||
399,
|
||||
571.5,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
60,
|
||||
1143,
|
||||
858,
|
||||
1143,
|
||||
60,
|
||||
0,
|
||||
858,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0.06486486486486487,
|
||||
0,
|
||||
0.9275675675675675,
|
||||
0,
|
||||
0.06486486486486487,
|
||||
0.9613120269133726,
|
||||
0.9275675675675675,
|
||||
0.9613120269133726
|
||||
],
|
||||
"minPos": [
|
||||
-399,
|
||||
-571.5,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
399,
|
||||
571.5,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "c11affc3-eadc-4651-95b4-3adb7d39dbf8@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "c11affc3-eadc-4651-95b4-3adb7d39dbf8@6c48a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
import { _decorator, Node, v2 } from "cc";
|
||||
import { I_LevelConfig, I_LevelStepData, I_NpcTalkBack, I_TalkRecordInfo } from "../Config/CommonConfig";
|
||||
import SocketUnit from "../Common/SocketUnit";
|
||||
import Utils from "../Common/Utils";
|
||||
import { InnerMsgCode } from "../Config/InnerMsgCode";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
/**聊天状态 */
|
||||
export enum E_TalkStatusType {
|
||||
succ = 0, //成功
|
||||
talking = 1, //对话中
|
||||
fail = 2, //失败
|
||||
noCount = 3, //次数不足
|
||||
}
|
||||
|
||||
|
||||
//游戏管理器
|
||||
@ccclass('GameManager')
|
||||
export default class GameManager {
|
||||
|
||||
private static _I: GameManager = null;
|
||||
public static get I(): GameManager {
|
||||
if (!GameManager._I) {
|
||||
GameManager._I = new GameManager();
|
||||
GameManager._I.init();
|
||||
}
|
||||
return GameManager._I;
|
||||
}
|
||||
|
||||
private init(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//长连接相关==============================================================
|
||||
private _socket: SocketUnit = null;
|
||||
/**连接长连接 */
|
||||
public connetSorcket(record_id:string){
|
||||
this.disconnectSocket();
|
||||
this._socket = new SocketUnit();
|
||||
this._socket.connect(`ws://47.119.190.199:20190/game/ai/response/${record_id}`);
|
||||
this._socket.onDataReceived((data: any) => {
|
||||
let resData = JSON.parse(data.data)
|
||||
// console.log("收到长连接消息", resData)
|
||||
Utils.sendInnerMsg(InnerMsgCode.Data_NpcTalkBack, resData || {})
|
||||
})
|
||||
}
|
||||
/**断开长连接 */
|
||||
public disconnectSocket(){
|
||||
if (this._socket){
|
||||
this._socket.disconnect();
|
||||
}
|
||||
this._socket = null;
|
||||
}
|
||||
/**获取npc回复 */
|
||||
public getNpcTalkBack(data: any){
|
||||
if (this._socket){
|
||||
this._socket.sendData(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//关卡数据相关==============================================================
|
||||
private static _levelCfgArray: I_LevelConfig[] = [];
|
||||
private static _levelCfgMap: {[key: string]: I_LevelConfig} = {};
|
||||
/**设置关卡配置数据 */
|
||||
public static SetLevelCfg(levelCfg: any[]) {
|
||||
GameManager._levelCfgArray = levelCfg;
|
||||
let info:any = null;
|
||||
for (let i = 0; i < levelCfg.length; i++) {
|
||||
info = levelCfg[i];
|
||||
GameManager._levelCfgMap[info.id] = info;
|
||||
}
|
||||
}
|
||||
|
||||
/**获取关卡配置 */
|
||||
public static getLevelCfg(levelId: string): I_LevelConfig {
|
||||
return GameManager._levelCfgMap[levelId];
|
||||
}
|
||||
|
||||
|
||||
private static _AIVoiceSwt: boolean = false;
|
||||
/**设置是否显示AI语音 */
|
||||
public static set AIVoiceSwt(value: boolean) {
|
||||
GameManager._AIVoiceSwt = value;
|
||||
}
|
||||
/**获取是否显示AI语音 */
|
||||
public static get AIVoiceSwt(): boolean {
|
||||
return GameManager._AIVoiceSwt;
|
||||
}
|
||||
|
||||
|
||||
private static _curLevelId: string = "";
|
||||
/**设置当前关卡ID */
|
||||
public static set CurLevelId(value: string) {
|
||||
GameManager._curLevelId = value;
|
||||
}
|
||||
/**获取当前关卡ID */
|
||||
public static get CurLevelId(): string {
|
||||
return GameManager._curLevelId;
|
||||
}
|
||||
|
||||
|
||||
private static _recordId: string = "";
|
||||
/**设置当前关卡流程ID */
|
||||
public static set RecordId(value: string) {
|
||||
GameManager._recordId = value;
|
||||
}
|
||||
/**获取当前关卡流程ID */
|
||||
public static get RecordId(): string {
|
||||
return GameManager._recordId;
|
||||
}
|
||||
|
||||
|
||||
private static _curLevelData: I_LevelStepData = null;
|
||||
/**设置当前步骤数据 */
|
||||
public static set CurLevelData(value: I_LevelStepData) {
|
||||
GameManager._curLevelData = value;
|
||||
}
|
||||
/**获取当前步骤数据 */
|
||||
public static get CurLevelData(): I_LevelStepData {
|
||||
return GameManager._curLevelData;
|
||||
}
|
||||
|
||||
|
||||
private static _curNpcTalkData: I_NpcTalkBack = null;
|
||||
/**设置当前NPC回复数据 */
|
||||
public static set CurNpcTalkData(value: I_NpcTalkBack) {
|
||||
GameManager._curNpcTalkData = value;
|
||||
}
|
||||
/**获取当前NPC回复数据 */
|
||||
public static get CurNpcTalkData(): I_NpcTalkBack {
|
||||
return GameManager._curNpcTalkData;
|
||||
}
|
||||
|
||||
|
||||
private static stepScoreList: number[] = [];
|
||||
/**设置关卡步骤评分 */
|
||||
public static AddStepScore(score: number) {
|
||||
GameManager.stepScoreList.push(score);
|
||||
}
|
||||
/**清空关卡步骤评分 */
|
||||
public static ClearStepScore() {
|
||||
GameManager.stepScoreList = [];
|
||||
}
|
||||
/**获取关卡当前评分
|
||||
* @returns [总分,平均分]
|
||||
*/
|
||||
public static getGameScore(): [number,number] {
|
||||
let totalScore = 0;
|
||||
let totalStep = 0;
|
||||
GameManager.stepScoreList.forEach((score) => {
|
||||
totalScore += score;
|
||||
totalStep++;
|
||||
})
|
||||
let scoreRate = totalStep > 0 ? Math.floor(totalScore / totalStep) : 0;
|
||||
return [totalScore, scoreRate];
|
||||
}
|
||||
|
||||
|
||||
private static talkRecordList: I_TalkRecordInfo[] = [];
|
||||
/**添加对话记录 */
|
||||
public static AddTalkRecord(record: I_TalkRecordInfo) {
|
||||
GameManager.talkRecordList.push(record);
|
||||
}
|
||||
/**清空对话记录 */
|
||||
public static ClearTalkRecord() {
|
||||
GameManager.talkRecordList = [];
|
||||
}
|
||||
/**获取对话记录 */
|
||||
public static get TalkRecordList(): I_TalkRecordInfo[] {
|
||||
return GameManager.talkRecordList;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 952 KiB |
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "5be9de77-65bb-49f4-a536-5d995f52f012",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "5be9de77-65bb-49f4-a536-5d995f52f012@6c48a",
|
||||
"displayName": "tarenaya_laugh",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "5be9de77-65bb-49f4-a536-5d995f52f012",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "5be9de77-65bb-49f4-a536-5d995f52f012@f9941",
|
||||
"displayName": "tarenaya_laugh",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 50.5,
|
||||
"offsetY": -72,
|
||||
"trimX": 105,
|
||||
"trimY": 144,
|
||||
"width": 816,
|
||||
"height": 1045,
|
||||
"rawWidth": 925,
|
||||
"rawHeight": 1189,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-408,
|
||||
-522.5,
|
||||
0,
|
||||
408,
|
||||
-522.5,
|
||||
0,
|
||||
-408,
|
||||
522.5,
|
||||
0,
|
||||
408,
|
||||
522.5,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
105,
|
||||
1045,
|
||||
921,
|
||||
1045,
|
||||
105,
|
||||
0,
|
||||
921,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0.11351351351351352,
|
||||
0,
|
||||
0.9956756756756757,
|
||||
0,
|
||||
0.11351351351351352,
|
||||
0.8788898233809924,
|
||||
0.9956756756756757,
|
||||
0.8788898233809924
|
||||
],
|
||||
"minPos": [
|
||||
-408,
|
||||
-522.5,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
408,
|
||||
522.5,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "5be9de77-65bb-49f4-a536-5d995f52f012@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "5be9de77-65bb-49f4-a536-5d995f52f012@6c48a"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user