|
|
@@ -5,6 +5,9 @@
|
|
|
// Learn life-cycle callbacks:
|
|
|
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
|
|
+import { RewardState } from "../../data/GameDefinition";
|
|
|
+import TaskVO from "../../vo/TaskVO";
|
|
|
+
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
|
|
@ccclass
|
|
|
@@ -16,26 +19,27 @@ export default class task_item extends cc.Component {
|
|
|
lbl_reward_icon: cc.Label = null;
|
|
|
@property({ type: cc.Label, displayName: '奖励描述' })
|
|
|
lbl_task_desc: cc.Label = null;
|
|
|
- @property({ type: cc.Label, displayName: '按钮描述' })
|
|
|
- lbl_btn_desc: cc.Label = null;
|
|
|
- @property({ type: cc.Button, displayName: '操作按钮' })
|
|
|
- btn_op: cc.Button = null;
|
|
|
+ // @property({ type: cc.Label, displayName: '按钮描述' })
|
|
|
+ // lbl_btn_desc: cc.Label = null;
|
|
|
@property({ type: cc.Sprite, displayName: '进度条' })
|
|
|
node_bar: cc.Sprite = null;
|
|
|
+ @property({ type: cc.Button, displayName: '领取按钮' })
|
|
|
+ btn_unlock: cc.Button = null;
|
|
|
+ @property({ type: cc.Button, displayName: '前往按钮' })
|
|
|
+ btn_lock: cc.Button = null;
|
|
|
|
|
|
|
|
|
/** 数据 */
|
|
|
- private item_data = {
|
|
|
- index: 0,
|
|
|
- };
|
|
|
+ private item_data: TaskVO = null;
|
|
|
/** 动画组件 */
|
|
|
private comp_ani: cc.Animation = null;
|
|
|
/** 是否正在移除中 */
|
|
|
private is_removing: boolean = false;
|
|
|
onLoad() {
|
|
|
- this.comp_ani = this.node.getComponent(cc.Animation);
|
|
|
- XXEvent.addClickEvent(this.btn_op, this.onClickOp, this);
|
|
|
+ XXEvent.addClickEvent(this.btn_lock, this.onClocGotoUI, this);
|
|
|
+ XXEvent.addClickEvent(this.btn_unlock, this.onClickOp, this);
|
|
|
this.node.on('ui-playanim-hide', this.playHide, this);
|
|
|
+ this.comp_ani = this.node.getComponent(cc.Animation);
|
|
|
this.comp_ani.on(cc.Animation.EventType.FINISHED, () => {
|
|
|
this.removeSelf();
|
|
|
})
|
|
|
@@ -48,7 +52,7 @@ export default class task_item extends cc.Component {
|
|
|
/** ScrollList数据更新
|
|
|
* - 自动初始化,onLoad之后,start之前
|
|
|
*/
|
|
|
- async setItemData(data: any, tableviewUtils) {
|
|
|
+ async setItemData(data: TaskVO, tableviewUtils) {
|
|
|
this.item_data = data;
|
|
|
this.node.opacity = 255;
|
|
|
this.node.x = 0;
|
|
|
@@ -56,9 +60,48 @@ export default class task_item extends cc.Component {
|
|
|
this.initItemStyle();
|
|
|
}
|
|
|
private initItemStyle() {
|
|
|
- this.lbl_reward_icon.string = `${this.item_data.index}`;
|
|
|
+ // 按钮描述
|
|
|
+ if (this.item_data.state === RewardState.lock) {
|
|
|
+ this.btn_unlock.node.active = false;
|
|
|
+ this.btn_lock.node.active = true;
|
|
|
+ } else if (this.item_data.state === RewardState.unlock) {
|
|
|
+ this.btn_unlock.node.active = true;
|
|
|
+ this.btn_lock.node.active = false;
|
|
|
+ } else if (this.item_data.state === RewardState.none) {
|
|
|
+ this.btn_unlock.node.active = false;
|
|
|
+ this.btn_lock.node.active = false;
|
|
|
+ }
|
|
|
+ // 任务进度
|
|
|
+ if (this.item_data.task_stage === 1) {
|
|
|
+ // 奖励数量
|
|
|
+ this.lbl_reward_icon.string = `${this.item_data.activevalue1}`;
|
|
|
+ // 任务描述
|
|
|
+ this.lbl_task_desc.string = XXI18n.replace(this.item_data.description, { 0: this.item_data.count1 });
|
|
|
+ // 任务进度
|
|
|
+ let range = this.item_data.bar / this.item_data.count1;
|
|
|
+ range = range >= 1 ? 1 : range;
|
|
|
+ this.node_bar.fillRange = range;
|
|
|
+ } else if (this.item_data.task_stage === 2) {
|
|
|
+ this.lbl_reward_icon.string = `${this.item_data.activevalue2}`;
|
|
|
+
|
|
|
+ this.lbl_task_desc.string = XXI18n.replace(this.item_data.description, { 0: this.item_data.count2 });
|
|
|
+
|
|
|
+ let range = this.item_data.bar / this.item_data.count2;
|
|
|
+ range = range >= 1 ? 1 : range;
|
|
|
+ this.node_bar.fillRange = range;
|
|
|
+ }
|
|
|
}
|
|
|
+ /** 前往某某界面 */
|
|
|
+ private onClocGotoUI() {
|
|
|
+
|
|
|
+ }
|
|
|
+ /** 领取奖励 */
|
|
|
private onClickOp() {
|
|
|
+ if (this.item_data.state === RewardState.lock) {
|
|
|
+ // 跳转页面 的逻辑
|
|
|
+ } else if (this.item_data.state === RewardState.none) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (this.is_removing) return;
|
|
|
let _data = {
|
|
|
node: this.node_reward_icon.node,
|