123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- import { RewardData } from "../../../data/sdata/SManage";
- import FF from "../../FF";
- import FSprite from "../../object/FSprite";
- import WOneByone from "./WOneByone";
- /**
- * 剧情1:解救伙伴
- */
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class FStory_rescue extends cc.Component {
- @property(cc.Prefab)
- mMapDialog: cc.Prefab = null;
- @property(dragonBones.ArmatureDisplay)
- mMonster: dragonBones.ArmatureDisplay = null;
-
- @property({
- type:cc.Node,
- displayName: '任务提示'
- })
- public iconTouch:cc.Node = null;
- private ff:FF;
- onLoad() {
- }
- onBeginContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider){
- if(other.node.group == 'A'){
- let obj = other.node.getComponent(FSprite);
- this.ff = obj.ff;
- if(obj == this.ff.mainSprite){
- this.showButton();
- }
- }
- }
- onEndContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider){
- if(other.node.group == 'A'){
- let obj = other.node.getComponent(FSprite);
- if(obj == this.ff.mainSprite){
- this.closeButton();
- }
- }
- }
- public showButton(){
- this.ff.control.mEventButton.node.active = true;
- this.ff.control.mEventButton.setCallback(()=>{
- this.startStory();
- });
- }
- public closeButton(){
- this.ff.control.mEventButton.node.active = false;
- }
- public startStory(){
- /**
- * 暂停所有
- */
- this.iconTouch.active = false;
- this.ff.pauseSprite(true);
- this.ff.mBlockInputEvents.active = true;
- this.showDialog1();
- }
-
- private showDialog1(){
- let dialogs = [
- '别打我,我就是个零时工',
- '钥匙给你',
- ];
- let node = cc.instantiate(this.mMapDialog);
- node.group = 'map'
- node.zIndex = 9999;
- node.x = this.node.x;
- node.y = this.node.y + this.node.height;
- node.parent = this.ff.mMap.mSprites;
- let obo = node.getComponent(WOneByone);
-
- obo.dialogs = dialogs;
- obo.setCallback(()=>{
- node.destroy();
- this.ff.setBlockInputCallback(null);
- this.ff.pauseSprite(false);
- this.ff.mBlockInputEvents.active = false;
- this.closeButton();
- this.node.removeComponent(cc.PhysicsBoxCollider);
- this.addKey();
- });
- this.ff.setBlockInputCallback(()=>{
- obo.jump();
- });
- obo._start();
- }
- /**
- * 添加一个钥匙
- */
- private addKey(){
- let list:Array<RewardData> = [
- {
- type:2,//0:money,1:gole,2:good
- icon:'icon/good/2001',
- count:1,//数量
- id:2001,//道具对应的id
- pz:0,
- star:0,
- PR:0
- }
- ];
- let pos = this.mMonster.node.parent.getPosition();
- this.ff.addGoods(list,pos);
- let header = this.ff.mFFheader;
- header.addTmpGood(2001,1);
- }
- }
|