Esempio n. 1
0
    public void Register(GameObject stage)
    {
        string[]  names = Config.SOUND_BTN.Split(':');
        AudioClip ac    = (AudioClip)UIPackage.GetItemAsset(names [0], names [1]);

        list.Add(Config.SOUND_BTN, ac);
        UIConfig.buttonSound = ac;

        string m = LocalStore.GetLocal(LocalStore.LOCAL_MUSIC);
        string s = LocalStore.GetLocal(LocalStore.LOCAL_SOUND);

        this.isMusic = m == "" ? true : Convert.ToBoolean(m);
        this.isSound = s == "" ? true : Convert.ToBoolean(s);

        mainCam      = GameObject.Find("Main Camera").GetComponent <AudioListener>();
        musicGo      = new GameObject();
        musicGo.name = "Music";
        musicGo.transform.SetParent(stage.transform);
        music = musicGo.AddComponent <AudioSource> ();

        soundGo      = new GameObject();
        soundGo.name = "Sound";
        soundGo.transform.SetParent(stage.transform);
        sound = soundGo.AddComponent <AudioSource> ();

        music.loop = true;
        sound.loop = false;

//		stage.AddComponent<AudioListener> ();
        SetSound(this.isSound);
    }
Esempio n. 2
0
    public void PlayMusic(string name)
    {
        if (!this.isMusic)
        {
            return;
        }
        if (lastMusic == name)
        {
            return;
        }
        AudioClip ac;

        if (list.ContainsKey(name))
        {
            ac = list [name];
        }
        else
        {
            string[] names = name.Split(':');
            ac          = (AudioClip)UIPackage.GetItemAsset(names [0], names [1]);
            list [name] = ac;
        }
        lastMusic = name;
        this.ac   = ac;
        TimerManager.inst.Add(0.05f, 0, Time_Tick1);
    }
Esempio n. 3
0
        public static void Init()
        {
            Stage.Instantiate();
            Stage.inst.referenceResolution = RESOLUTION;
            Stage.inst.matchWidthOrHeight  = 1;
            Stage.inst.updateManually      = true;

            UIEventProxy.IsOverUIObject = () => EventSystem.instance.IsPointerOverGameObject();

            UIConfig.defaultFont = "STHeitiSC-Medium,Droid Sans Fallback,LTHYSZK,Verdana,SimHei";

            UIPackage.AddPackage("UI/global");
            UIConfig.globalModalWaiting = UIPackage.GetItemURL("global", "ModalWaiting");
            UIConfig.windowModalWaiting = UIPackage.GetItemURL("global", "ModalWaiting");

            UIObjectFactory.SetLoaderExtension(typeof(CustomGLoader));

            UIConfig.buttonSound = ( AudioClip )UIPackage.GetItemAsset("global", "click");

            login     = new UILogin();
            hall      = new UIHall();
            room      = new UIRoom();
            loadLevel = new UILoadLevel();
            battle    = new UIBattle();
        }
Esempio n. 4
0
    private void PreloadResources()
    {
        // Preload configs
        LoadConfig("DefaultConfig");

        // Preload data tables
        LoadDataTable("Scene");
        LoadDataTable("Staff");
        LoadDataTable("Animal");
        LoadDataTable("Event");
        LoadDataTable("Facility");
        LoadDataTable("Shop");
        LoadDataTable("Fence");
        LoadDataTable("Land");
        LoadDataTable("FenceArea");

        // Preload dictionaries
        //        LoadDictionary("Default");

        // Preload fonts
        //        LoadFont("MainFont");

        CommonBinder.BindAll();
        ZooBinder.BindAll();

        UIPackage.AddPackage("UI/Common");
        UIConfig.defaultFont            = "tongxin";
        UIConfig.buttonSound            = UIPackage.GetItemAsset("Common", "ButtonClick") as NAudioClip;
        UIConfig.buttonSoundVolumeScale = 1f;

        var resManager = new FGuiResourceManager();

        resManager.Init();
        GameEntry.UI.SetResourceManager(resManager);
    }
Esempio n. 5
0
 void Start()
 {
     DontDestroyOnLoad(this);
     gameObject.AddComponent <TimeTickService>();
     gameObject.AddComponent <AudioManager>();
     UIPackage.AddPackage("UI/Common");
     UIConfig.defaultFont = "siyuan";
     UIConfig.buttonSound = UIPackage.GetItemAsset("Common", "ButtonClick") as NAudioClip;
     AppFacade.getInstance().StartUp(this);
 }
Esempio n. 6
0
    public object GetItemAssetFromResName(string pkgDirectory, string bundleName, string resName)
    {
        CheckAndAddFGUIPackge(PlatformLobby, SharedAssets);//检查添加公共包
        bundleName = RemoveBundleSuffix(bundleName);
        bool b = CheckAndAddFGUIPackge(pkgDirectory, bundleName);

        if (!b)
        {
            return(null);
        }
        return(UIPackage.GetItemAsset(bundleName, resName));
    }
Esempio n. 7
0
    void Start()
    {
#if UNITY_WEBPLAYER || UNITY_WEBGL || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR
        CopyPastePatch.Apply();
#endif

        Application.targetFrameRate = 60;
        GRoot.inst.SetContentScaleFactor(1136, 640);
        Stage.inst.onKeyDown.Add(OnKeyDown);

        UIPackage.AddPackage("UI/Basics");

#if UNITY_5
        //Use the font names directly
        UIConfig.defaultFont = "Droid Sans,Droid Sans Fallback,Microsoft YaHei";
#else
        //Need to put a ttf file into Resources folder. Here is the file name of the ttf file.
        UIConfig.defaultFont = "afont";
#endif

        UIConfig.verticalScrollBar   = UIPackage.GetItemURL("Basics", "ScrollBar_VT");
        UIConfig.horizontalScrollBar = UIPackage.GetItemURL("Basics", "ScrollBar_HZ");
        UIConfig.popupMenu           = UIPackage.GetItemURL("Basics", "PopupMenu");
        UIConfig.buttonSound         = (AudioClip)UIPackage.GetItemAsset("Basics", "click");

        _mainView = UIPackage.CreateObject("Basics", "Main").asCom;
        _mainView.fairyBatching = true;
        _mainView.SetSize(GRoot.inst.width, GRoot.inst.height);
        _mainView.AddRelation(GRoot.inst, RelationType.Size);
        GRoot.inst.AddChild(_mainView);

        _backBtn         = _mainView.GetChild("btn_Back");
        _backBtn.visible = false;
        _backBtn.onClick.Add(onClickBack);

        _demoContainer  = _mainView.GetChild("container").asCom;
        _viewController = _mainView.GetController("c1");

        _demoObjects = new Dictionary <string, GComponent>();

        int cnt = _mainView.numChildren;
        for (int i = 0; i < cnt; i++)
        {
            GObject obj = _mainView.GetChildAt(i);
            if (obj.group != null && obj.group.name == "btns")
            {
                obj.onClick.Add(runDemo);
            }
        }
    }
Esempio n. 8
0
    void Awake()
    {
#if (UNITY_5 || UNITY_5_3_OR_NEWER)
        //Use the font names directly
        UIConfig.defaultFont = "Microsoft YaHei";
#else
        //Need to put a ttf file into Resources folder. Here is the file name of the ttf file.
        UIConfig.defaultFont = "afont";
#endif
        UIPackage.AddPackage("UI/Basics");

        UIConfig.verticalScrollBar   = "ui://Basics/ScrollBar_VT";
        UIConfig.horizontalScrollBar = "ui://Basics/ScrollBar_HZ";
        UIConfig.popupMenu           = "ui://Basics/PopupMenu";
        UIConfig.buttonSound         = (NAudioClip)UIPackage.GetItemAsset("Basics", "click");
    }
Esempio n. 9
0
    void Awake()
    {
#if UNITY_WEBPLAYER || UNITY_WEBGL || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR
        CopyPastePatch.Apply();
#endif

#if (UNITY_5 || UNITY_5_3_OR_NEWER)
        //Use the font names directly
        UIConfig.defaultFont = "Microsoft YaHei";
#else
        //Need to put a ttf file into Resources folder. Here is the file name of the ttf file.
        UIConfig.defaultFont = "afont";
#endif
        UIPackage.AddPackage("UI/Basics");

        UIConfig.verticalScrollBar   = UIPackage.GetItemURL("Basics", "ScrollBar_VT");
        UIConfig.horizontalScrollBar = UIPackage.GetItemURL("Basics", "ScrollBar_HZ");
        UIConfig.popupMenu           = UIPackage.GetItemURL("Basics", "PopupMenu");
        UIConfig.buttonSound         = (AudioClip)UIPackage.GetItemAsset("Basics", "click");
    }
Esempio n. 10
0
        public void Enter(object param)
        {
            BattleManager.Init(( BattleParams )param);

            this._hudManager = new HUDManager();

            this._root = UIPackage.CreateObject("battle", "Main").asCom;
            this._root.displayObject.name = "Battle";
            this._root.enableDrag         = true;
            this._root.onDrag.Add(this.OnDrag);
            this._root.onTouchBegin.Add(this.OnTouchBegin);
            this._root.onTouchEnd.Add(this.OnTouchEnd);
            GRoot.inst.AddChild(this._root);
            this._root.size = GRoot.inst.size;
            this._root.AddRelation(GRoot.inst, RelationType.Size);

            this._gestureStateOne          = new GestureStateOne(this);
            this._gestureStateOne.joystick = ( Joystick )this._root["joystick"];

            this._winCom = this._root["win_com"].asCom;
            this._winCom["n4"].onClick.Add(this.OnQuitBtnClick);

            this._useItemBtn = this._root["n11"].asCom;
            GComponent icon   = this._useItemBtn["icon"].asCom;
            GLoader    loader = icon["loader"].asLoader;

            loader.maskSprite = ( NSprite )UIPackage.GetItemAsset("battle", "item_btn_mask");

            EventCenter.AddListener(UIEventType.COUNT_DOWN, this.HandleCountDown);
            EventCenter.AddListener(UIEventType.WIN, this.HandleWin);
            EventCenter.AddListener(UIEventType.ENTITY_CREATED, this.HandleEntityCreated);
            EventCenter.AddListener(UIEventType.ENTITY_DESTROIED, this.HandleEntityDestroied);
            EventCenter.AddListener(UIEventType.ENTITY_ATTR_CHANGED, this.HandleEntityAttrChanged);
            EventCenter.AddListener(UIEventType.PICK_ITEM, this.HandlePickItem);
            EventCenter.AddListener(UIEventType.ITEM_USED, this.HandleItemUsed);

            if (Env.useNetwork)
            {
                NetModule.instance.AddQCMDListener(Module.BATTLE, Command.QCMD_LEAVE_BATTLE, this.HandleLeaveBattle);
            }
        }
Esempio n. 11
0
    //-------------------------------------------------------------------------
    public void create(EntityMgr entity_mgr)
    {
        mUiMgr    = this;
        EntityMgr = entity_mgr;

        UIConfig.defaultFont = "Microsoft YaHei";

        UIPackage.AddPackage("Ui/Common");
        UIPackage.AddPackage("Ui/Main");
        UIPackage.AddPackage("Ui/Loading");
        UIPackage.AddPackage("Ui/Login");

        UIConfig.buttonSound = (AudioClip)UIPackage.GetItemAsset("Common", "Close");

        //UIConfig.verticalScrollBar = UIPackage.GetItemURL("Common", "ScrollBar_VT");
        //UIConfig.horizontalScrollBar = UIPackage.GetItemURL("Basics", "ScrollBar_HZ");
        //UIConfig.popupMenu = UIPackage.GetItemURL("Basics", "PopupMenu");
        //GRoot.inst.SetContentScaleFactor(1136, 640);

        Stage.inst.onKeyDown.Add(_onKeyDown);
    }
Esempio n. 12
0
    public void PlaySound(string name)
    {
        if (!this.isSound)
        {
            return;
        }
        AudioClip ac;

        if (list.ContainsKey(name))
        {
            ac = list [name];
        }
        else
        {
            string[] names = name.Split(':');
            ac          = (AudioClip)UIPackage.GetItemAsset(names [0], names [1]);
            list [name] = ac;
        }
        sound.loop = false;
        sound.clip = ac;
        sound.Play();
    }
    //-----------------------------
    private void PlayGraph()
    {
        GComponent obj = _demoObjects["Graph"];

        Shape shape;

        shape = obj.GetChild("pie").asGraph.shape;
        EllipseMesh ellipse = shape.graphics.GetMeshFactory <EllipseMesh>();

        ellipse.startDegree = 30;
        ellipse.endDegreee  = 300;
        shape.graphics.SetMeshDirty();

        shape = obj.GetChild("trapezoid").asGraph.shape;
        PolygonMesh trapezoid = shape.graphics.GetMeshFactory <PolygonMesh>();

        trapezoid.usePercentPositions = true;
        trapezoid.points.Clear();
        trapezoid.points.Add(new Vector2(0f, 1f));
        trapezoid.points.Add(new Vector2(0.3f, 0));
        trapezoid.points.Add(new Vector2(0.7f, 0));
        trapezoid.points.Add(new Vector2(1f, 1f));
        trapezoid.texcoords.Clear();
        trapezoid.texcoords.AddRange(VertexBuffer.NormalizedUV);
        shape.graphics.SetMeshDirty();
        shape.graphics.texture = (NTexture)UIPackage.GetItemAsset("Basics", "change");

        shape = obj.GetChild("line").asGraph.shape;
        LineMesh line = shape.graphics.GetMeshFactory <LineMesh>();

        line.lineWidthCurve = AnimationCurve.Linear(0, 25, 1, 10);
        line.roundEdge      = true;
        line.gradient       = lineGradient;
        line.path.Create(new GPathPoint[] {
            new GPathPoint(new Vector3(0, 120, 0)),
            new GPathPoint(new Vector3(20, 120, 0)),
            new GPathPoint(new Vector3(100, 100, 0)),
            new GPathPoint(new Vector3(180, 30, 0)),
            new GPathPoint(new Vector3(100, 0, 0)),
            new GPathPoint(new Vector3(20, 30, 0)),
            new GPathPoint(new Vector3(100, 100, 0)),
            new GPathPoint(new Vector3(180, 120, 0)),
            new GPathPoint(new Vector3(200, 120, 0)),
        });
        shape.graphics.SetMeshDirty();
        GTween.To(0, 1, 5).SetEase(EaseType.Linear).SetTarget(shape.graphics).OnUpdate((GTweener t) =>
        {
            ((NGraphics)t.target).GetMeshFactory <LineMesh>().fillEnd = t.value.x;
            ((NGraphics)t.target).SetMeshDirty();
        });

        shape = obj.GetChild("line2").asGraph.shape;
        LineMesh line2 = shape.graphics.GetMeshFactory <LineMesh>();

        line2.lineWidth = 3;
        line2.roundEdge = true;
        line2.path.Create(new GPathPoint[] {
            new GPathPoint(new Vector3(0, 120, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(60, 30, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(80, 90, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(140, 30, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(160, 90, 0), GPathPoint.CurveType.Straight),
            new GPathPoint(new Vector3(220, 30, 0), GPathPoint.CurveType.Straight)
        });
        shape.graphics.SetMeshDirty();

        GObject  image = obj.GetChild("line3");
        LineMesh line3 = image.displayObject.graphics.GetMeshFactory <LineMesh>();

        line3.lineWidth = 30;
        line3.roundEdge = false;
        line3.path.Create(new GPathPoint[] {
            new GPathPoint(new Vector3(0, 30, 0), new Vector3(50, -30), new Vector3(150, -50)),
            new GPathPoint(new Vector3(200, 30, 0), new Vector3(300, 130)),
            new GPathPoint(new Vector3(400, 30, 0))
        });
        image.displayObject.graphics.SetMeshDirty();
    }