| 45 | } |
| 46 | |
| 47 | public move(): void{ |
| 48 | // If the lolligator is facing left, then it goes to the left |
| 49 | if(this.isLeft){ |
| 50 | this.x -= 1; |
| 51 | // If we're not fully visible but we should be |
| 52 | if(this.visibleType == PondLolligatorVisibleType.NOT_FULLY_VISIBLE_YET && this.x + this.width < this.pondLines[this.pondLineIndex].getX2() - 2 && Random.oneChanceOutOf(5)) |
| 53 | this.visibleType = PondLolligatorVisibleType.FULLY_VISIBLE; |
| 54 | else if(this.visibleType == PondLolligatorVisibleType.FULLY_VISIBLE && (this.x < this.pondLines[this.pondLineIndex].getX1() + 2 || Random.oneChanceOutOf(2))) |
| 55 | this.visibleType = PondLolligatorVisibleType.NOT_FULLY_VISIBLE_ANYMORE; |
| 56 | } |
| 57 | // Else it goes to the right |
| 58 | else{ |
| 59 | this.x += 1; |
| 60 | // If we're not fully visible but we should be |
| 61 | if(this.visibleType == PondLolligatorVisibleType.NOT_FULLY_VISIBLE_YET && this.x > this.pondLines[this.pondLineIndex].getX1() + 2 && Random.oneChanceOutOf(5)) |
| 62 | this.visibleType = PondLolligatorVisibleType.FULLY_VISIBLE; |
| 63 | else if(this.visibleType == PondLolligatorVisibleType.FULLY_VISIBLE && (this.x + this.width > this.pondLines[this.pondLineIndex].getX2() - 2 || Random.oneChanceOutOf(2))) |
| 64 | this.visibleType = PondLolligatorVisibleType.NOT_FULLY_VISIBLE_ANYMORE; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // Called to know if the lolligator should be deleted or not |
| 69 | public shouldBeDeleted(): boolean{ |