Untitled

SubGameRandomSelect.py

import os
import random

game_list = list(set("""
Rubik's Cube
Maze
Solve the no connection puzzle
Solve a Numbrix puzzle
Solve a Hopido puzzle
Solve a Holy Knight's tour
Solve a Hidato puzzle
Word wheel
Chess player
Minesweeper game
Flipping bits game
Towers of Hanoi
Deal cards for FreeCell
RCRPG
Remote agent
Go Fish
Knight's tour
Hunt_The_Wumpus
CLI-based maze-game
Greed
Word wheel
Hunt The Wumpus
Robots
Black Box
Mastermind
Hexapawn
Nim Game
Snake
Tamagotchi emulator
Rock-paper-scissors
Morpion solitaire
Sokoban
16Puzzle
asteroids
bang
betwixt
blix
boom
boomerang
climb
clocks
colorSort
columns
crackTheLock
fiveOrMore
flappypac
flipIt
halloween
knightsTour
mastermind
mazeClimb
memdots
minesweeper
minicow
ninjaJump
numbers
pairs
panic
pegSolitaire
plusPlus
pong
pudi
reaction
riseRise
rps
spaceInvaders
spikes
square
stairs
steps
tetris
tictactoe
timber
upJump
zenax
13
Add 7
Blocks
Bones
Chain shot
Colors sort
Dice puzzle
FlipFlop
Greed
Hippodrome
Inundo
Lights out
Mines
MobFlux
Move!
Game of Pig
Ping
Pipes
Queens quadrille
Robots
SET Game
Solichess
YANG
15 Puzzle
Arkanoid
Black box
Break the C0D3
Hexapawn
Sector26
Snake
Binary
Blox
Button Game
Cascade II
FloodThis
Funk It!
HiLights
Knight's Tour
Lines
MasterMind
Memory Game
Rivers
Space Invaders
Tower of Hanoi
Tic tac toe
Theseus and the Minotaur
Turn It!
TrafficJam
""".lower().strip().split('\n')))


def get_path(index):
    return f'roll{file_index}'


if __name__ == '__main__':
    file_index = 0
    filepath = get_path(file_index)
    while True:
        if not (os.path.exists(filepath) or os.path.exists(f'{filepath}.select')):
            break
        file_index += 1
        filepath = get_path(file_index)
    with open(filepath, 'w') as file:
        file.write(game_list[random.SystemRandom().randint(0, len(game_list) - 1)])

calc.js

let Long = require('long');

cc.Class({
    extends: cc.Component,

    properties: {
        exp: {
            default: '',
        },
    },

    setVal (x) {
        this.exp = x;
        this.node.children[0].getComponent(cc.Label).string = this.exp;
    },

    append (x) {
        if (/\d+/.test(x)) {
            this.exp += x;
        } else {
            this.exp += ' ' + x + ' ';
        }
        this.node.children[0].getComponent(cc.Label).string = this.exp;
    },

    eval () {
        if (this.exp === '') return;
        let n = Long.fromString('7797466619350050522', false);
        let values = this.exp.split(' ').filter(x => x !== '');
        let ops = {
            '+': (a, b) => a.add(b),
            '-': (a, b) => a.sub(b),
            '*': (a, b) => a.mul(b),
            '/': (a, b) => a.div(b),
        }
        let i = 0;
        while (values.length !== 1) {
            if (!/\d+/.test(values[i])) {
                values[i + 1] = ops[values[i]](Long.fromString(values[i - 1], false).mod(n), Long.fromString(values[i + 1], false).mod(n)).toUnsigned().mod(n).toString();
                values.splice(i - 1, 2);
                i--;
            } else {
                i++;
            }
        }
        values[0] = Long.fromString(values[0], false).mod(n).toString();
        this.setVal(values[0] === '7233170664317018478' ? 'dabendan' : values[0]);
    },

    clear() {
        this.setVal('');
    },

    start () {},
});

calc.md

c^e == m (mod n)

n=7797466619350050522
e=3
c=2467890

m=7233170664317018478
m=0x646162656E64616E

calc_btn.js

cc.Class({
    extends: cc.Component,

    properties: {},

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            let val = this.node.children[0].children[0].getComponent(cc.Label).string;
            if (val === '=') {
                this.node.parent.parent.getComponent('calc').eval();
            } else if (val === 'C') {
                this.node.parent.parent.getComponent('calc').clear();
            } else {
                this.node.parent.parent.getComponent('calc').append(val);
            }
        }, this);
    },
});

desk_main_sub1_card.js

cc.Class({
    extends: cc.Component,

    properties: {},

    onLoad () {
        if (cc.find("Main").getComponent('player').MoireFringesCardFlag) {
            this.node.destroy();
        }
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            cc.find("Main").getComponent('player').MoireFringesCardFlag = true;
            console.info('set MoireFringesCardFlag');
            this.node.destroy();
        }, this);
    },
});

desk_main_sub2_key.js

cc.Class({
    extends: cc.Component,

    properties: {},

    onLoad () {
        if (cc.find("Main").getComponent('player').WardrobeKeyFlag) {
            this.node.destroy();
        }
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            cc.find("Main").getComponent('player').WardrobeKeyFlag = true;
            console.info('set WardrobeKeyFlag');
            this.node.destroy();
        }, this);
    },
});

desk_main_sub_r.js

cc.Class({
    extends: cc.Component,

    properties: {},

    onLoad () {
        if (!cc.find("Main").getComponent('player').MainDeskKeyFlag) {
            this.node.destroy();
        }
    },
});

desk_roll_btn.js

cc.Class({
    extends: cc.Component,

    properties: {
        val: {
            default: '?',
        }
    },

    setVal (val) {
        this.val = val;
        this.node.children[0].children[0].getComponent(cc.Label).string = this.val;
    },

    getVal () {
        return this.node.children[0].children[0].getComponent(cc.Label).string;
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            this.setVal(this.node.parent.parent.getComponent('desk_roll_r').next(this.getVal()));
            this.node.parent.parent.getComponent('desk_roll_r').winQ();
        }, this);
    },
});

desk_roll_r.js

cc.Class({
    extends: cc.Component,

    properties: {
        pool: {
            default: [],
        },
        target: {
            default: [],
        },
    },

    winQ () {
        let red = 0;
        let black = 0;
        let tmpTg = [...this.target];
        let sVal = [...Array(4).fill('')];
        for (let i = 0; i < 4; ++i) {
            sVal[i] = this.node.children[1].children[i].getComponent('desk_roll_btn').getVal();
        }
        for (let i = 0; i < 4; ++i) {
            if (sVal[i] === tmpTg[i]) {
                red++;
                sVal[i] = '';
                tmpTg[i] = '';
            }
        }
        for (let i = 0; i < 4; ++i) {
            if (sVal[i] === '') continue;
            let idx = tmpTg.indexOf(sVal[i]);
            if (idx !== -1) {
                black++;
                tmpTg = '';
            }
        }
        this.node.children[0].getComponent(cc.RichText).string = (red === 4 ?
            '<color=#000000>meishaonv</color>' :
            `${[...Array(red).fill('?')].join('')}${[...Array(black).fill('?')].join('')}`);
        if (red === 4) {
            cc.find("Main").getComponent('player').RollGameFlag = true;
            console.info('set RollGame');
            this.node.children[1].removeAllChildren();
        }
    },

    next (val) {
        return this.pool[(this.pool.indexOf(val) + 1) % this.pool.length];
    },

    onLoad () {
        this.pool = ['?', '?', '?', '?', '?', '?'];
        this.target = [...Array(4).fill('')];
        let tmpPool = [...this.pool];
        for (let i = 0; i < 4; ++i) {
            this.target[i] = tmpPool.splice(Math.floor(Math.random() * tmpPool.length), 1)[0];
        }
    },

    start () {
        if (cc.find("Main").getComponent('player').RollGameFlag) {
            this.node.children[0].getComponent(cc.RichText).string = '<color=#000000>meishaonv</color>';
            this.node.children[1].removeAllChildren();
        }
    },
});

desk_side_sub_r.js

cc.Class({
    extends: cc.Component,

    properties: {},

    onLoad () {
        if (!cc.find("Main").getComponent('player').SideKeyFlag) {
            this.node.destroy();
        }
    },
});

door_key.js

cc.Class({
    extends: cc.Component,

    properties: {},

    onLoad () {
        if (cc.find("Main").getComponent('player').DoorFlag) {
            this.node.destroy();
        }
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            cc.find("Main").getComponent('player').DoorFlag = true;
            console.info('set DoorFlag');
            this.node.destroy();
        }, this);
    },
});

door_r.js

cc.Class({
    extends: cc.Component,

    properties: {},

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            if (cc.find("Main").getComponent('player').DoorFlag) {
                console.info('done.');
                cc.director.loadScene('end');
            }
        }, this);
    },
});

jack_r.js

cc.Class({
    extends: cc.Component,

    properties: {
        btnAudio: {
            default: null,
            type: cc.AudioClip
        },
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            if (!cc.find("Main").getComponent('player').PowerFlag){
                cc.find("Main").getComponent('player').PowerFlag = true;
                console.info("set PowerFlag");
                cc.audioEngine.playEffect(this.btnAudio, false);
            }
        }, this);
    },
});

keyboard_black_keys.js

cc.Class({
    extends: cc.Component,

    properties: {

    },

    start () {
        let octave = ['C', 'D', 'E', 'F', 'G', 'A', 'B'];
        let pool = [
            octave.map(x => x + '5'),
            octave.map(x => x + '6'),
            [octave[0] + '7'],
        ].flat();
        for (let i = 0; i < 15; ++i) {
            this.node.children[i].getComponent('keyboard_key').init(pool[i], this.node.parent.children[2].children[i].getComponent(cc.AudioSource));
        }
    },
});

keyboard_key.js

cc.Class({
    extends: cc.Component,

    properties: {
        val: {
            default: '',
        },
        audio: {
            default: null,
            type: cc.AudioSource,
        },
    },

    init (val, audio) {
        this.val = val;
        this.audio = audio;
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            console.info(`get ${this.val}`);
            this.node.parent.parent.getComponent('keyboard_r').append(this.val);
            this.audio.play();
        }, this);
    },

    start () {},
});

keyboard_r.js

cc.Class({
    extends: cc.Component,

    properties: {
        target: {
            default: '',
        },
        played: {
            default: '',
        },
    },

    append(x) {
        this.played += x;
        if (this.played.indexOf(this.target) !== -1) {
            if (!cc.find("Main").getComponent('player').SightReadingFlag) {
                cc.find("Main").getComponent('player').SightReadingFlag = true;
                cc.find("Main").getComponent('player').MonitorStage++;
                console.info('set SightReadingFlag');
                this.initTarget();
            } else {
                cc.find("Main").getComponent('player').AllLast = true;
                console.info('set AllLast');
            }
        }
    },

    initTarget () {
        this.target = cc.find("Main").getComponent('player').SightReadingFlag ? 'A6G6C7G6F6E6F6E6' : 'C6E6G6B5C6D6C6';
    },

    start () {
        this.initTarget();
    },
});

keyboard_white_keys.js

cc.Class({
    extends: cc.Component,

    properties: {

    },

    start () {
        let octave = ['C#', 'D#', 'F#', 'G#', 'A#'];
        let pool = [
            octave.map(x => x + '5'),
            octave.map(x => x + '6'),
        ].flat();
        let poolIndex = 0;
        for (let i = 0; i < 14; ++i) {
            if (this.node.children[i].opacity !== 0) {
                this.node.children[i].getComponent('keyboard_key').init(pool[poolIndex], this.node.parent.children[3].children[poolIndex].getComponent(cc.AudioSource));
                ++poolIndex;
            }
        }
    },
});

main_desk_key.js

cc.Class({
    extends: cc.Component,

    properties: {},

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            cc.find("Main").getComponent('player').MainDeskKeyFlag = true;
            console.info('set MainDeskKeyFlag');
            this.node.destroy();
        }, this);
    },
});

main_pc_r.js

cc.Class({
    extends: cc.Component,

    properties: {
        btnAudio: {
            default: null,
            type: cc.AudioClip
        },
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            if (cc.find("Main").getComponent('player').UpsFlag &&
                !cc.find("Main").getComponent("player").MainPcFlag){
                cc.find("Main").getComponent('player').MainPcFlag = true;
                console.info("set MainPcFlag");
                cc.audioEngine.playEffect(this.btnAudio, false);
            }
        }, this);
    },
});

moire_fringes_mix.js

cc.Class({
    extends: cc.Component,

    properties: {
        moire_fringes_mix: {
            default: null,
            type: cc.Prefab,
        },
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            this.node.parent.addChild(cc.instantiate(this.moire_fringes_mix));
            this.node.destroy();
        }, this);
    },
});

moire_fringes_mix_key.js

cc.Class({
    extends: cc.Component,

    properties: {},

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            console.info('set SideKeyFlag');
            cc.find("Main").getComponent('player').SideKeyFlag = true;
            this.node.destroy();
        }, this);
    },
});

monitor_r.js

cc.Class({
    extends: cc.Component,

    properties: {
        monitorStage0: {
            default: null,
            type: cc.Prefab,
        },
        monitorStage1: {
            default: null,
            type: cc.Prefab,
        },
        monitorStage2: {
            default: null,
            type: cc.Prefab,
        },
        monitorStage3: {
            default: null,
            type: cc.Prefab,
        },
    },

    stageLoad () {
        console.debug(cc.find("Main").getComponent('player').MonitorStage);
        this.node.removeAllChildren();
        this.node.addChild(cc.instantiate(({
                    0: this.monitorStage0,
                    1: this.monitorStage1,
                    2: this.monitorStage2,
                    3: this.monitorStage3,
                })[cc.find("Main").getComponent('player').MonitorStage]));
    },

    start () {
        if (cc.find("Main").getComponent('player').MainPcFlag){
            this.stageLoad();
        }
    },
});

monitor_side_r.js

cc.Class({
    extends: cc.Component,

    properties: {
        monitorStage0: {
            default: null,
            type: cc.Prefab,
        },
        monitorStage1: {
            default: null,
            type: cc.Prefab,
        },
        monitorStage2: {
            default: null,
            type: cc.Prefab,
        },
    },

    stageLoad () {
        this.node.removeAllChildren();
        this.node.addChild(cc.instantiate(({
                    0: this.monitorStage0,
                    1: this.monitorStage1,
                    2: this.monitorStage2,
                })[cc.find("Main").getComponent('player').MonitorSideStage]));
    },

    start () {
        if (cc.find("Main").getComponent('player').SidePcFlag){
            this.stageLoad();
        }
    },
});

monitor_side_stage0_btn.js

cc.Class({
    extends: cc.Component,

    properties: {
        editbox: {
            default: null,
            type: cc.Node,
        }
    },

    start () {
        console.info('load MonitorSideStage0');
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            console.info(`get ${this.editbox.getComponent(cc.EditBox).string}`);
            if (this.editbox.getComponent(cc.EditBox).string === "dabendan") {
                console.info('done MonitorSideStage0');
                cc.find("Main").getComponent('player').MonitorSideStage++;
                this.node.parent.parent.getComponent('monitor_side_r').stageLoad();
            }
        }, this);
    },
});

monitor_side_stage1.js

cc.Class({
    extends: cc.Component,

    properties: {
        chessman: {
            default: null,
            type: cc.Prefab,
        },
        selected: {
            default: 0,
        }
    },

    moveQ (index, sIndex, sVal) {
        let x = index % 4;
        let y = Math.floor(index / 4);
        let sx = sIndex % 4;
        let sy = Math.floor(sIndex / 4);
        if (sVal === 'K' || sVal === 'Q' || sVal === 'B') {
            if (x === sx - 1 && y === sy - 1) return true;
            if (x === sx - 1 && y === sy + 1) return true;
            if (x === sx + 1 && y === sy + 1) return true;
            if (x === sx + 1 && y === sy - 1) return true;
        }
        if (sVal === 'K' || sVal === 'Q' || sVal === 'R') {
            if (x === sx && y === sy - 1) return true;
            if (x === sx && y === sy + 1) return true;
            if (x === sx + 1 && y === sy) return true;
            if (x === sx - 1 && y === sy) return true;
        }
        if (sVal === 'N') {
            if (x === sx - 1 && y === sy - 2) return true;
            if (x === sx - 1 && y === sy + 2) return true;
            if (x === sx + 1 && y === sy + 2) return true;
            if (x === sx + 1 && y === sy - 2) return true;
            if (x === sx - 2 && y === sy - 1) return true;
            if (x === sx - 2 && y === sy + 1) return true;
            if (x === sx + 2 && y === sy + 1) return true;
            if (x === sx + 2 && y === sy - 1) return true;
        }
        return false;
    },

    winQ () {
        for (let i = 0; i < 4; ++i) {
            if (this.node.children[i].getComponent('monitor_side_stage1_btn').val !== 'N') {
                return false;
            }
        }
        return true;
    },

    select (index) {
        let val = this.node.children[index].getComponent('monitor_side_stage1_btn').val;
        if (this.selected === null) {
            if (val === ' ') return;
            this.selected = index;
            this.node.children[index].getComponent('monitor_side_stage1_btn').setSelect();
        } else if (index === this.selected) {
            this.selected = null;
            this.node.children[index].getComponent('monitor_side_stage1_btn').unsetSelect();
        } else if (val === ' ') {
            if (this.moveQ(index, this.selected, this.node.children[this.selected].getComponent('monitor_side_stage1_btn').val)) {
                this.node.children[index].getComponent('monitor_side_stage1_btn').setVal(this.node.children[this.selected].getComponent('monitor_side_stage1_btn').val);
                this.node.children[this.selected].getComponent('monitor_side_stage1_btn').setVal(' ');
                this.selected = null;
            }
        }
        if (this.winQ()) {
            console.info('done MonitorSideStage1');
            console.info('set SidePcGameFlag');
            cc.find("Main").getComponent('player').SidePcGameFlag = true;
            cc.find("Main").getComponent('player').MonitorSideStage++;
            this.node.parent.getComponent('monitor_side_r').stageLoad();
        }
    },

    start () {
        this.selected = null;
        console.info('load MonitorSideStage1');
        let pool = [
            [...Array(1).fill(' ')],
            [...Array(2).fill('K')],
            [...Array(2).fill('Q')],
            [...Array(3).fill('B')],
            [...Array(4).fill('R')],
        ].flat();
        let index = 0;
        while (pool.length !== 0) {
            let cm = cc.instantiate(this.chessman);
            cm.getComponent('monitor_side_stage1_btn').initVal(index++, pool.splice(Math.floor(Math.random() * pool.length), 1)[0]);
            this.node.addChild(cm);
        }
        for (let _ = 0; _ < 4; ++_) {
            let cm = cc.instantiate(this.chessman);
            cm.getComponent('monitor_side_stage1_btn').initVal(index++, 'N');
            this.node.addChild(cm);
        }
    },
});

monitor_side_stage1_btn.js

cc.Class({
    extends: cc.Component,

    properties: {
        index: {
            default: 0,
        },
        val: {
            default: ' ',
        },
    },

    setSelect () {
        this.node.children[0].color = cc.Color.set(this.node.children[0].color, 51, 51, 51);
    },

    unsetSelect () {
        this.node.children[0].color = cc.Color.WHITE;
    },

    setVal(val) {
        this.val = val;
        this.node.children[0].children[0].getComponent(cc.Label).string = val;
        this.unsetSelect();
    },

    initVal(index, val) {
        this.index = index;
        this.setVal(val);
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            this.node.parent.getComponent('monitor_side_stage1').select(this.index);
        }, this);
    },

    start () {},
});

monitor_stage0_btn.js

cc.Class({
    extends: cc.Component,

    properties: {
        editbox: {
            default: null,
            type: cc.Node,
        }
    },

    start () {
        console.info('load MonitorStage0');
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            console.info(`get ${this.editbox.getComponent(cc.EditBox).string}`);
            if (this.editbox.getComponent(cc.EditBox).string === "meishaonv") {
                console.info('done MonitorStage0');
                cc.find("Main").getComponent('player').MonitorStage++;
                this.node.parent.parent.getComponent('monitor_r').stageLoad();
            }
        }, this);
    },
});

monitor_stage1.js

cc.Class({
    extends: cc.Component,

    properties: {
        moon: {
            default: null,
            type: cc.Prefab,
        },
        sun: {
            default: null,
            type: cc.Prefab,
        },
    },

    swap (x, y) {
        const getIndex = (x, y) => y * 5 + x;
        const getVal = (i) => this.node.children[0].children[i].getComponent('monitor_stage1_moon').val;
        const set = (x0, y0, x1, y1) => this.node.children[0].children[getIndex(x0, y0)].getComponent('monitor_stage1_moon').setVal(getVal(getIndex(x1, y1)));
        let tempVal = getVal(getIndex(x, y));
        set(x + 0, y + 0, x + 0, y + 1);
        set(x + 0, y + 1, x + 1, y + 1);
        set(x + 1, y + 1, x + 1, y + 0);
        this.node.children[0].children[getIndex(x + 1, y)].getComponent('monitor_stage1_moon').setVal(tempVal);
        for (let y = 0; y < 5; ++y) {
            for (let x = 0; x < 4; ++x) {
                if (getVal(getIndex(x, y)) !== getVal(getIndex(x + 1, y))) {
                    return false;
                }
            }
        }
        return true;
    },

    start () {
        console.info("load MonitorStage1");
        let pool = ['?', '?', '?', '?', '?'].flatMap(x => [...Array(5)].fill(x));
        //let pool = ['1', '2', '3', '4', '5'].flatMap(x => [...Array(5)].fill(x));
        for (let x = 0; x < 5 * 5; ++x) {
            let moon = cc.instantiate(this.moon);
            moon.index = x;
            moon.getComponent('monitor_stage1_moon').setVal(`<color=#FFC83D>${pool.splice(Math.floor(Math.random() * pool.length), 1)[0]}</color>`);
            this.node.children[0].addChild(moon)
        }
        for (let x = 0; x < 4 * 4; ++x) {
            let sun = cc.instantiate(this.sun);
            sun.getComponent('monitor_stage1_sum').setBoard(x, this.node);
            this.node.children[1].addChild(sun);
        }
    },
});

monitor_stage1_moon.js

cc.Class({
    extends: cc.Component,

    properties: {
        index: {
            default: 0,
        },
        val: {
            default: '❌',
        },
    },

    setVal (val) {
        this.val = val;
        this.node.getComponent(cc.RichText).string = this.val;
    },

    start () {
        this.setVal(this.val);
    },
});

monitor_stage1_sum.js

cc.Class({
    extends: cc.Component,

    properties: {
        index: {
            default: 0,
        },
        board: {
            default: null,
            type: cc.Node,
        },
    },

    setBoard (index, board) {
        this.index = index;
        this.board = board;
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (_) => {
            let x = this.index % 4;
            let y = Math.floor(this.index / 4);
            if (this.board.getComponent('monitor_stage1').swap(x, y)) {
                console.info('done MonitorStage1');
                console.info('set MainPcGameFlag');
                cc.find("Main").getComponent('player').MainPcGameFlag = true;
                cc.find("Main").getComponent('player').MonitorStage++;
                this.board.parent.getComponent('monitor_r').stageLoad();
            }
        }, this);
    },
});

monitor_stage3.js

cc.Class({
    extends: cc.Component,

    properties: {
        par1_part2: {
            default: null,
            type: cc.AudioClip,
        },
    },

    start () {
        cc.audioEngine.playEffect(this.par1_part2, false);
    },
});

player.js

cc.Class({
    extends: cc.Component,

    properties: {
        DoorFlag: { default: false, },
        PowerFlag: { default: false, },
        UpsFlag: { default: false, },
        RollGameFlag: { default: false, },
        MainPcFlag: { default: false, },
        MainPcGameFlag: { default: false, },
        MainDeskKeyFlag: { default: false, },
        MoireFringesCardFlag: { default: false, },
        WardrobeKeyFlag: { default: false, },
        SideKeyFlag: { default: false, },
        SidePcFlag: { default: false, },
        SidePcGameFlag: { default: false, },
        SightReadingFlag: { default:false, },
        AllLast: { default: false, },

        MonitorStage: { default: 0, },
        MonitorSideStage: { default: 0 },
    },

    start () {},
});

printer_r.js

cc.Class({
    extends: cc.Component,

    properties: {
        monitor_tip: {
            default: null,
            type: cc.Prefab,
        },
        door_key: {
            default: null,
            type: cc.Prefab,
        },
        mainDeskKey: {
            default: null,
            type: cc.Prefab,
        },
        par1_part1: {
            default: null,
            type: cc.Prefab,
        },
    },

    start () {
        this.node.removeAllChildren();
        if (cc.find("Main").getComponent('player').AllLast) {
            this.node.addChild(cc.instantiate(this.door_key));
        } else if (cc.find("Main").getComponent('player').SightReadingFlag) {
            this.node.addChild(cc.instantiate(this.monitor_tip));
        } else if (cc.find("Main").getComponent('player').MainPcGameFlag &&
            !cc.find("Main").getComponent('player').MainDeskKeyFlag) {
            this.node.addChild(cc.instantiate(this.mainDeskKey));
        } else if (cc.find("Main").getComponent('player').SidePcGameFlag) {
            this.node.addChild(cc.instantiate(this.par1_part1));
        }
    },
});

run_in_right.js

cc.Class({
    extends: cc.Component,

    properties: {
        prefab: {
            default: null,
            type: cc.Prefab,
        },
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (_) => {
            cc.find("Main/Right/Side").removeAllChildren();
            cc.find("Main/Right/Side").addChild(cc.instantiate(this.prefab));
        }, this);
    },
});

side_pc_r.js

cc.Class({
    extends: cc.Component,

    properties: {
        btnAudio: {
            default: null,
            type: cc.AudioClip
        },
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            if (cc.find("Main").getComponent('player').PowerFlag &&
                !cc.find("Main").getComponent("player").SidePcFlag){
                cc.find("Main").getComponent('player').SidePcFlag = true;
                console.info("set SidePcFlag");
                cc.audioEngine.playEffect(this.btnAudio, false);
            }
        }, this);
    },
});

ups_r.js

cc.Class({
    extends: cc.Component,

    properties: {
        btnAudio: {
            default: null,
            type: cc.AudioClip
        },
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            if (cc.find("Main").getComponent('player').PowerFlag &&
                !cc.find("Main").getComponent('player').UpsFlag){
                cc.find("Main").getComponent('player').UpsFlag = true;
                console.info("set UpsFlag");
                cc.audioEngine.playEffect(this.btnAudio, false);
            }
        }, this);
    },
});

wardrobe_r.js

cc.Class({
    extends: cc.Component,

    properties: {},

    kill () {
        this.node.destroy();
    },

    start () {},
});

wardrobe_r_sub.js

cc.Class({
    extends: cc.Component,

    properties: {
        wardrobe_r_sub_r: {
            default: null,
            type: cc.Prefab,
        }
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            if (cc.find("Main").getComponent('player').WardrobeKeyFlag) {
                this.node.parent.parent.addChild(cc.instantiate(this.wardrobe_r_sub_r));
                this.node.parent.getComponent('wardrobe_r').kill();
            }
        }, this);
    },
});

wardrobe_sub.js

cc.Class({
    extends: cc.Component,

    properties: {
        moire_fringes_mix: {
            default: null,
            type: cc.Prefab,
        },
    },

    start () {
        this.node.on(cc.Node.EventType.MOUSE_DOWN,  (e) => {
            if (cc.find("Main").getComponent('player').MoireFringesCardFlag &&
                !cc.find("Main").getComponent('player').SideKeyFlag) {
                this.node.parent.addChild(cc.instantiate(this.moire_fringes_mix));
                this.node.destroy();
            }
        }, this);
    },
});

 

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注