| 123456789101112131415161718192021222324252627282930313233343536373839 |
- import EventType from "./EventType";
- import Role from "./Role";
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class Saw extends cc.Component {
- canGet:boolean = true;
- onLoad(){
- this.node.group = EventType.GROUP_OBJECT;
- this.node.getChildByName('Prop').addComponent(Prop).init(this);
- }
- onCollisionStay(other:cc.Collider){
- if(this.canGet){
- let role = other.node.getComponent(Role);
- if(role&&role.pickUpSaw()){
- this.canGet = false;
- window.controller.destroySaw(this.node);
- }
- }
- }
- }
- class Prop extends cc.Component {
- parentScript:any;
- init(parentScript:any){
- this.parentScript = parentScript;
- this.node.group = EventType.GROUP_PROP;
- }
- onCollisionStay(other:cc.Collider){
- this.parentScript.onCollisionStay(other);
- }
- }
|