123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- import BaseEvent from "../base/BaseEvent";
- /**
- * 藤蔓控制的门
- */
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class FOpenDoorVine extends BaseEvent {
- @property(cc.Prefab)
- mMapDialog: cc.Prefab = null;
- @property([cc.String])
- text: Array<string> = [];
- @property({
- displayName: '靠近的提示',
- type: cc.Node
- })
- mNearTips: cc.Node = null;
- @property({
- displayName: '藤蔓出现的提示',
- type: cc.Node
- })
- mFindTips: cc.Node = null;
- @property({
- displayName: '提示图标',
- type: cc.SpriteFrame
- })
- mTipsIcon: cc.SpriteFrame = null;
- @property({
- displayName: '出现的藤蔓',
- type: cc.Node
- })
- mGearNode: cc.Node = null;
- private isOver = false
- onLoad() {
- super.onLoad()
- if(this.mGearNode){
- this.mGearNode.active = false
- }
- if(this.mNearTips){
- this.mNearTips.active = false
- }
- if(this.mFindTips){
- this.mFindTips.active = false
- }
- }
- onBegin(tag:number){
- if(this.isOver){
- return
- }
- if (tag == 1) {
- if(this.mNearTips){
- this.mNearTips.active = false
- }
- this.showOpt(this.mTipsIcon, () => {
- this.closeOpt()
- this.pause()
- this.dialog(0)
- })
- }else if(tag == 2){
- if(this.mNearTips){
- this.mNearTips.active = true
- }
- }
- }
- onEnd(tag:number){
- if (tag == 1) {
- this.closeOpt()
- }else if (tag == 2) {
- if(this.mNearTips){
- this.mNearTips.active = false
- }
- }
- }
- private dialog(index:number){
- if(index >= this.text.length){
- if(this.mGearNode){
- this.vine()
- }
- return;
- }
- let texts = this.text[index].split('|')
- let mid = parseInt(texts.shift());
- if(mid == -1){//主角
- let my = this.ff.mainSprite.node;
- this.showDialog(my,texts,()=>{
- index ++;
- this.dialog(index);
- });
- }
- }
- /**
- * 藤蔓出现
- */
- private vine(){
- let pos = this.mGearNode.getPosition()
- let target = this.mGearNode.children[0].children[0]
- this.mGearNode.active = true
- target.y += 100
- this.moveCamera(pos,1,()=>{
- cc.tween(target).sequence(
- cc.moveBy(1,cc.v2(0,-100)),
- cc.callFunc(()=>{
- this.isOver = true
- this.resume()
- if(this.mFindTips){
- this.mFindTips.active = true
- }
- })
- ).start()
- })
- }
- }
|