GameMainLine.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { Color, Component, Sprite, _decorator,Node } from "cc";
  2. import GameUtils from "../../GameUtils/GameUtils";
  3. import GameMainPoint from "./GameMainPoint";
  4. const { ccclass, property } = _decorator;
  5. @ccclass
  6. export default class GameMainLine extends Component {
  7. private _oneLine: GameMainPoint = null
  8. private _twoLine: GameMainPoint = null
  9. private _isOK: boolean = false
  10. private color:number=0;
  11. resetData(oneLine: GameMainPoint, twoLine: GameMainPoint) {
  12. this._oneLine = oneLine
  13. this._twoLine = twoLine
  14. }
  15. getOneLine() {
  16. return this._oneLine
  17. }
  18. getTwoLine() {
  19. return this._twoLine
  20. }
  21. //设置线的颜色
  22. setColor(colorIndex: number) {
  23. let allColor = [Color.GREEN, Color.YELLOW, Color.RED]
  24. colorIndex = colorIndex >= 3 ? 2 : colorIndex
  25. this.color=colorIndex;
  26. this.node.getComponent(Sprite).color = allColor[colorIndex]
  27. this._isOK = colorIndex == 0
  28. //console.log("setColor:"+colorIndex);
  29. this.AddPointCount();
  30. }
  31. getIsOk() {
  32. return this._isOK
  33. }
  34. AddPointCount(){
  35. this._oneLine.AddColorNum(this.color);
  36. this._twoLine.AddColorNum(this.color);
  37. }
  38. public destroySelf(){
  39. this.node.destroy();
  40. }
  41. }