| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- let gameConfig = require("GameConfig");
- let library = require("../Library");
- cc.Class({
- extends: cc.Component,
- properties: {
- gameStates: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- playerController: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- actionPrefabs: {
- default: [],
- type: cc.Prefab,
- serializable: true,
- },
- bg: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- },
- onLoad () {
- this.gameStatesScp = this.gameStates.getComponent('GameStates');
- this.playerControllerScp = this.playerController.getComponent('PlayerController');
- this.delayTime = -1;
- },
- playActions()
- {
- let actionPlay = gameConfig.actionPlay[this.gameStatesScp.currentRound];
- // if(actionPlay.length == 0) return;
- for(let i=0;i<actionPlay.length;i++)
- {
- let c_act = actionPlay[i];
- this.spawnAction(c_act.name,c_act.offsetX,c_act.speed);
- }
- },
- spawnAction(name,offsetX,speed)
- {
- let tPrefab = cc.instantiate(this.actionPrefabs[name]);
- tPrefab.getComponent('ActionPlay').speed = speed;
- tPrefab.getComponent('ActionPlay').playerControllerScp = this.playerControllerScp;
- tPrefab.getComponent('ActionPlay').gameStatesScp = this.gameStatesScp;
- tPrefab.getComponent('ActionPlay').nameIndex = name;
- tPrefab.parent = this.node;
- tPrefab.setPosition(-720/2-offsetX,0);
- },
- });
|