/*
文件名:LodingStage.nut
路径:User/Stage/LodingStage.nut
创建日期:2024-12-10	12:11
文件用途: 加载界面
*/
function InitGame() {
    //初始化Socekt连接
    MySocket("192.168.200.15", 19003);
    // MySocket("127.0.0.1", 19666);

    //设定全局默认音量
    _Globa_Audio_Volume_ = 0.1;

    Script();

    //初始化资产管理器
    _AssetManager_();
    //初始化字体
    _FontAssetManager_();

    //进入下一个场景
    TestStage();
}

function LoginStage() {
    local T = CL_StageObject();
    T.SetName("加载界面舞台");

    local AniTime = 800;

    //大背景
    local BackGround = CL_SpriteObject("sprite/loding.img", 0);
    T.Addchild(BackGround);

    //Kiwano图标
    local Kiwano = CL_SpriteObject("sprite/loding.img", 1);
    Kiwano.SetAnchor(0.5, 0.5);
    Kiwano.SetScale(0.35, 0.35);
    Kiwano.SetPosition(1066 / 2, 800);
    Kiwano.SetUpdateFunc(function(sp, dt) {
        if (!("time" in sp.Var)) sp.Var.time <- 0;
        sp.Var.time += dt;
        local rate = Math.sq_GetAccel(100, 0, sp.Var.time, AniTime, true);
        sp.SetOpacity(rate / 100.0);
    });
    T.Addchild(Kiwano);

    //Yosin图标
    local Yosin = CL_SpriteObject("sprite/loding.img", 2);
    Yosin.SetAnchor(0.5, 0.5);
    Yosin.SetPosition(1066 / 2, 300);
    Yosin.SetOpacity(0.0);
    Yosin.SetUpdateFunc(function(sp, dt) {
        if (!("time" in sp.Var)) sp.Var.time <- 0;
        sp.Var.time += dt;
        local rate = Math.getUniformVelocity(0, 100, sp.Var.time - AniTime, AniTime);
        sp.SetOpacity(rate / 100.0);
        if (rate >= 100) {
            InitGame();
        }
    });
    T.Addchild(Yosin);

    T.Enter();
}