DatingEventViewImpl.ts 2.69 KB
import { CCPureView } from "../../../../common/classbase/CCViewBase";
import { RegView } from "../../PresenterCCViewFactory";
import { DatingEventViewType, DatingEventViewProps, DatingEventView } from "../type/DatingEventView";
import { DummyLabel, DummyNode } from "../../../../common/CCDummyObjects";
import { GameRecord } from "../../../../avg/AVG";

const { ccclass, property } = cc._decorator;

@ccclass
@RegView(DatingEventViewType, "prefab/ui/DatingEventView")
export class DatingEventViewImpl extends CCPureView<DatingEventViewProps> implements DatingEventView {
    @property(cc.Node)
    private arrowGuideNode = DummyNode;
    @property(cc.Label)
    private roleLikeLabel = DummyLabel;
    @property(cc.Label)
    private maskLabel = DummyLabel;

    onLoad() {
    }

    showArrowGuide = (isShow: boolean, wordPos?: cc.Vec3) => {
        this.arrowGuideNode.active = isShow;
        if (isShow && wordPos) {
            this.arrowGuideNode.position = this.node.convertToNodeSpaceAR(wordPos);
            this.arrowGuideNode.angle = wordPos.y > this.node.height / 2 ? 180 : 0;
        }
    }

    showRoleLikeLabel = () => {
        this.roleLikeLabel.string = "艾尔好感:" + this.getRoleLikeByRoleId(3).toString() + "," + "该隐好感:" + this.getRoleLikeByRoleId(4).toString()
            + "," + "系统好感:" + this.getRoleLikeByRoleId(5).toString() + "," + "芙好感:" + this.getRoleLikeByRoleId(8).toString()
            + "," + "布鲁斯好感:" + this.getRoleLikeByRoleId(22).toString();
    }

    showMaskLabel = () => {
        this.maskLabel.string =
            "armask:" + this.getMaskValue("armask") + "," + "msmask:" + this.getMaskValue("msmask") + "," + "jsmask:" + this.getMaskValue("jsmask")
            + "," + "bymask:" + this.getMaskValue("bymask") + "," + "gymask:" + this.getMaskValue("gymask")
            + "," + "barmask:" + this.getMaskValue("barmask") + "," + "harmask:" + this.getMaskValue("harmask")
            + "," + "hsmask:" + this.getMaskValue("hsmask") + "," + "szmask:" + this.getMaskValue("szmask")
            + "," + "bzf:" + this.getMaskValue("bzf") + "," + "xs:" + this.getMaskValue("xs") + "," + "fhh:" + this.getMaskValue("fhh")
            + "," + "fyhh:" + this.getMaskValue("fyhh") + "," + "aryc:" + this.getMaskValue("aryc");
    }

    getMaskValue(maskName: string): number {
        let r = GameRecord.recordVariables[maskName] as number;
        r = r ? r : 0;
        return r;
    }

    getRoleLikeByRoleId(id: number): number {
        let g = GameRecord.globalVariables["like" + id];
        g = g ? g : 0;
        let r = GameRecord.recordVariables["like" + id];
        r = r ? r : 0;
        let l = g + r;
        return l;
    }
}