123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import { _decorator, Component, Node, tween, Vec3, AudioSource } from 'cc';
- import { GameEvent } from '../Common/Base/GameEventConfig';
- import GameEventManager from '../Common/Base/GameEventManager';
- import { Global } from '../Common/Global';
- const { ccclass, property } = _decorator;
- @ccclass('GameAnimal')
- export class GameAnimal extends Component {
- audioPlaying:boolean=false;
- pause:boolean=false;
- audioTime=0;
- timerCount=0;
- start() {
- // this.node.on(Node.EventType.TOUCH_END, this._onTouchEndNode, this);
- // this.node.on(Node.EventType.TOUCH_CANCEL, this._onTouchEndNode, this);
- this.setDefault();
- this.node.setScale(Vec3.ZERO);
- }
- update(deltaTime: number) {
-
- }
- // _onTouchEndNode(){
- // GameEventManager.getInstance().dispathcGameEvent(GameEvent.ClickUp,this.node.name);
- // }
- BiggerAnimal(flag:boolean){
- if(flag){
- this.node.setScale(new Vec3(1.2,1.2,1));
- }else{
- this.node.setScale(new Vec3(1,1,1));
- }
- }
- beforeDestroy(){
- // this.node.off(Node.EventType.TOUCH_END, this._onTouchEndNode, this);
- // this.node.off(Node.EventType.TOUCH_CANCEL, this._onTouchEndNode, this);
- }
- setIsRight(isright){
- this.node.children[1].active=isright;
- this.node.children[2].active=!isright;
- }
- setDefault(){
- this.node.children[1].active=false;
- this.node.children[2].active=false;
- this.BiggerAnimal(false);
- }
- onDestroy(){
-
- }
- pausePlay(){
- if(this.audioPlaying){
- this.node.getComponent(AudioSource).pause();
- this.pause=true;
- }
- }
- RestartPlay(){
- if(this.audioPlaying){
- this.node.getComponent(AudioSource).play();
- this.pause=false;
- }
- }
- PlayMyAudio(func){
- let audio=this.node.getComponent(AudioSource);
- audio.play();
- this.audioPlaying=true;
- this.audioTime=audio.duration;
- Global.cdSchedule.schedule(()=>{
- if(func){
- func();
- }
- Global.cdSchedule.unschedule(this.node.name);
- },this.audioTime,this.node.name)
- }
- ShowCard(func){
- tween(this.node).to(0.4,{scale:new Vec3(1,1,1)},{ easing: 'elasticOut' }).call(()=>{
- if(func){
- func();
- }
-
- }).start();
- }
- }
|