123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- import { _decorator, Component, Node, tween, Vec3 } from 'cc';
- import ui_base from '../../../core/ui/ui_base';
- import { ModuleDef } from '../../../scripts/ModuleDef';
- import { GameUILayers, gui } from '../../../core/ui/ui';
- import { Layout_HomePage } from './Layout_HomePage';
- import { UIManager } from '../UI/UIManager';
- import { toggleBreath, toggleSlideOutAndBack_Nodes } from '../../../module_extra/Customize/Customize_Ani';
- import { Root } from '../../game/process/Root';
- import { button_Sound, SoundName } from '../../../module_extra/Customize/Customize_Sound';
- import { Customize_RedPointMgr, NodeName } from '../../../module_extra/Customize/Customize_RedPointMgr';
- import { RedPointPersistType, RedPointState, RedPointType } from '../../../module_extra/Customize/Customize_RedPoint';
- import { UIName } from '../UI/UI_ClassManager';
- const { ccclass, property } = _decorator;
- @ccclass('UI_HomePage')
- export class UI_HomePage extends ui_base {
- private offset: Vec3[] = [
- new Vec3(450, 0), // 向右
- new Vec3(-450, 0), // 向左
- new Vec3(0, -700), // 向下
- new Vec3(0, 1334) // 向上
- ];
- private duration: number = 0.3;
- luckyGift: string = "LuckyGift";
- subscriptionGift: string = "SubscriptionGift";
- piggyBank: string = "PiggyBank";
- count = 1;
- constructor() {
- super(ModuleDef.GAME, "ui/UI_HomePage/HomePage", GameUILayers.HUD, Layout_HomePage);
- }
- protected onCreated(): void {
- Root.getInstance().cancelBlurBg();
- const layout = this.getLayout<Layout_HomePage>();
- this.initRedPointTree();
- this.showPanel();
- }
- public showPanel(): void {
- super.showPanel();
- let flag: boolean = false;//是否需要做动画
- if (!UIManager.getInstance().Show_Ani) {
- UIManager.getInstance().Show_Ani = true;
- } else {
- flag = true;
- }
- const layout = this.getLayout<Layout_HomePage>();
- let count = 3;
- const onOneFinish = () => {
- count--;
- if (count === 0) {
- this.onButtonEvent(layout.Start_Btn, () => {
- button_Sound(SoundName.clickUI);
- Root.getInstance().Mode = 1;
- UIManager.getInstance().DestoryAllUI();
- UIManager.getInstance().pushUI(UIName.MAIN);
- })
- this.onButtonEvent(layout.LuckyGift_Btn, () => {
- button_Sound(SoundName.clickUI);
- UIManager.getInstance().pushUI(UIName.LUCKYGIFT, true);
- Customize_RedPointMgr.instance.SetState(NodeName.homePage, this.luckyGift, RedPointState.Hide);
- Customize_RedPointMgr.instance.SaveToLocal();
- });
- this.onButtonEvent(layout.SubscriptionGift_Btn, () => {
- button_Sound(SoundName.clickUI);
- // UIManager.getInstance().pushUI();
- Customize_RedPointMgr.instance.SetState(NodeName.homePage, this.subscriptionGift, RedPointState.Hide);
- Customize_RedPointMgr.instance.SaveToLocal();
- });
- this.onButtonEvent(layout.PiggyBank_Btn, () => {
- button_Sound(SoundName.clickUI);
- UIManager.getInstance().pushUI(UIName.PIGGYBANK, true);
- Customize_RedPointMgr.instance.SetState(NodeName.homePage, this.piggyBank, RedPointState.Hide);
- Customize_RedPointMgr.instance.SaveToLocal();
- });
- }
- };
- this.duration = flag ? this.duration : 0;
- toggleSlideOutAndBack_Nodes(layout.Left_Groups, this.offset[0], this.duration, onOneFinish);
- toggleSlideOutAndBack_Nodes(layout.Right_Groups, this.offset[1], this.duration, onOneFinish);
- toggleSlideOutAndBack_Nodes(layout.Down_Groups, this.offset[3], this.duration, onOneFinish);
- toggleBreath(layout.Start_Btn.node, 0.8);
- }
- public new_close() {
- const layout = this.getLayout<Layout_HomePage>();
- let count = 3;
- const onOneFinish = () => {
- count--;
- if (count === 0) {
- super.new_close();
- }
- };
- toggleSlideOutAndBack_Nodes(layout.Left_Groups, this.offset[0], 0.3, onOneFinish);
- toggleSlideOutAndBack_Nodes(layout.Right_Groups, this.offset[1], 0.3, onOneFinish);
- toggleSlideOutAndBack_Nodes(layout.Down_Groups, this.offset[3], 0.3, onOneFinish);
- }
- private initRedPointTree() {
- if (!Customize_RedPointMgr.instance.GetState(NodeName.homePage, this.luckyGift)) {
- console.log("添加");
- Customize_RedPointMgr.instance.Add(NodeName.homePage, this.luckyGift, NodeName.homePage, RedPointType.Enternal, RedPointPersistType.Temporary);
- Customize_RedPointMgr.instance.SetState(NodeName.homePage, this.luckyGift, this.count == 0 ? RedPointState.Hide : RedPointState.Show, this.count);
- }
- if (!Customize_RedPointMgr.instance.GetState(NodeName.homePage, this.subscriptionGift)) {
- console.log("添加");
- Customize_RedPointMgr.instance.Add(NodeName.homePage, this.subscriptionGift, NodeName.homePage, RedPointType.Enternal, RedPointPersistType.Temporary);
- Customize_RedPointMgr.instance.SetState(NodeName.homePage, this.subscriptionGift, this.count == 0 ? RedPointState.Hide : RedPointState.Show, this.count);
- }
- if (!Customize_RedPointMgr.instance.GetState(NodeName.homePage, this.piggyBank)) {
- console.log("添加");
- Customize_RedPointMgr.instance.Add(NodeName.homePage, this.piggyBank, NodeName.homePage, RedPointType.Enternal, RedPointPersistType.Temporary);
- Customize_RedPointMgr.instance.SetState(NodeName.homePage, this.piggyBank, this.count == 0 ? RedPointState.Hide : RedPointState.Show, this.count);
- }
- Customize_RedPointMgr.instance.Init(NodeName.homePage, this.luckyGift, this.OnLuckyGiftShow.bind(this));
- Customize_RedPointMgr.instance.Init(NodeName.homePage, this.subscriptionGift, this.OnSubscriptionGiftShow.bind(this));
- Customize_RedPointMgr.instance.Init(NodeName.homePage, this.piggyBank, this.OnPiggyBankShow.bind(this));
- }
- private OnLuckyGiftShow(state: RedPointState, data: number = 1) {
- const layout = this.getLayout<Layout_HomePage>();
- layout.LuckyGift_Btn.node.getChildByName('hint_point').active = state === RedPointState.Show;
- }
- private OnSubscriptionGiftShow(state: RedPointState, data: number = 1) {
- const layout = this.getLayout<Layout_HomePage>();
- layout.SubscriptionGift_Btn.node.getChildByName('hint_point').active = state === RedPointState.Show;
- }
- private OnPiggyBankShow(state: RedPointState, data: number = 1) {
- const layout = this.getLayout<Layout_HomePage>();
- layout.PiggyBank_Btn.node.getChildByName('hint_point').active = state === RedPointState.Show;
- }
- }
|