1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import { _decorator, Component, Enum, Node } from 'cc';
- import { CupHeight, WaterColors } from '../TakeGobletGlobalInstance';
- import { Water } from './Water';
- const { ccclass, property } = _decorator;
- @ccclass('TempCup')
- export class TempCup extends Component {
- @property({ type: Enum(CupHeight), displayName: '杯高度' })
- cupHeight: CupHeight = CupHeight.One
- @property(Node)
- waters: Node = null!; //水节点
- private _currentColor: WaterColors = WaterColors.Blue;
- private _isFull: boolean = false;
- get isFull(): boolean {
- return this._isFull;
- }
- get currentColor(): WaterColors {
- return this._currentColor;
- }
- start() {
- }
- update(deltaTime: number) {
- }
- fill(color: WaterColors) {
- if (this._isFull) return;
- const waterNode = this.waters.children[0];
- if (waterNode) {
- const water = waterNode.getComponent(Water)!;
- water.color = color;
- waterNode.active = true;
- this._currentColor = color;
- this._isFull = true;
- }
- }
- reset() {
- this.waters.children[0].active = false;
- this._isFull = false;
- }
- }
|