Esempio n. 1
0
    void Start()
    {
        GameUpdate.Instance.Init();

        //AssetTool.Instance.Init();
        AssetBundle.UnloadAllAssetBundles(true);
        Debug.Log(GameConst.GetInstance().m_AssetLoaderMode);
        AssetManager.GetInstance().InitLoader(
            GameConst.GetInstance().m_AssetLoaderMode,
            AssetPathMode.Address,
            GameConst.m_MaxLoadCount,
            GameConst.GetInstance().m_AssetBundlePath,
            (isSuccess) =>
        {
            if (isSuccess)
            {
                GameLoader.Instance.Init();
                Debug.Log("重启AssetManager");
                AssetManager.GetInstance().LoadSceneAsync("Assets/Scenes/GameMain.unity", (address, scene, userData) =>
                {
                    Debug.Log("加载游戏");
                    AssetManager.GetInstance().LoadAssetAsync(AssetAddressKey.PREFABS_CUBE,
                                                              (address1, uobj, userData1) =>
                    {
                        GameObject go = uobj as GameObject;
                        Debug.Log("chenggong" + go);
                        GameObject.Instantiate(go);
                    });
                }, null);
            }
        });
    }
Esempio n. 2
0
 /// <summary>
 /// 把Dictionary序列化为byte数据
 /// Saves the table data.
 /// </summary>
 /// <param name="dic">Dic.</param>
 /// <param name="tablename">Tablename.</param>
 public static void SaveTableData(List <object> list, string tablename)
 {
     byte[] data     = GameCommon.SerializeObject(list);
     byte[] gzipData = GameCommon.CompressGZip(data);
     //WriteByteToFile(gzipData,tablename);
     GameCommon.WriteByteToFile(gzipData, GameConst.SaveConfigFilePath(tablename));
 }
Esempio n. 3
0
 public static void ToggleEditorMode()
 {
     if (GameConst.GetInstance().m_AssetLoaderMode == AssetLoaderMode.AssetBundle)
     {
         EditorPrefs.SetString(kEditorMode, "true");
     }
 }
Esempio n. 4
0
 public static void ToggleSimulateMode()
 {
     if (GameConst.GetInstance().m_AssetLoaderMode == AssetLoaderMode.AssetDatabase)
     {
         EditorPrefs.SetString(kEditorMode, "false");
     }
 }
Esempio n. 5
0
    void RefreshSave()
    {
        HSUnityTools.DestroyChildren(SaveParent_RectTransform);

        for (int i = 0; i < GameConst.SAVE_COUNT; i++)
        {
            var btn = Instantiate(SaveItem_Button);
            btn.transform.SetParent(SaveParent_RectTransform);
            btn.transform.localScale = Vector3.one;
            btn.name = i.ToString();
            Text title = btn.transform.Find("Title").GetComponent <Text>();
            title.text = "´æµµ" + GameConst.GetUPNumber(i + 1);

            var txt            = btn.transform.Find("SummaryText").GetComponent <Text>();
            var summaryInfoKey = GameRuntimeData.ARCHIVE_SUMMARY_PREFIX + i;
            if (PlayerPrefs.HasKey(summaryInfoKey))
            {
                txt.text = PlayerPrefs.GetString(summaryInfoKey);
            }
            else
            {
                txt.text = "¿Õ´æµµÎ»";
            }

            BindListener(btn, () =>
            {
                OnSaveItemClick(btn);
            });
        }
    }
Esempio n. 6
0
    public void ShowCastSkill(Army army, Skill skill, SkillState state)
    {
        if (GameConst.CanShowText() == false)
        {
            return;
        }


        string temp = "";

        switch (state)
        {
        case SkillState.READY_1:
            temp = "<color=" + GameConst.Color.greenColor + "【" + army.name + "】</color>的战法【" + skill.name + "】开始准备!";
            break;

        case SkillState.INSTANT_CAST:
            if (skill.name.Equals("") == false)
            {
                temp = "<color=" + army.color + "【" + army.name + "】</color>发动【" + skill.name + "】!";
            }
            else
            {
                return;
            }
            break;

        case SkillState.DAMAGE:
            temp = "\t\t造成了" + "百分之" + skill.curDamge + "的伤害(" + skill.curTrunTargetCount + "个目标)";
            break;
        }

        Append(temp);
    }
Esempio n. 7
0
    IEnumerator ReadConfigFile(string filename)
    {
        //GameConst.GetStoryLevelFilePath(mapid+".lmd")
        string filepath;//= GameConst.GetConfigFilePath(filename);

        filepath = GameConst.GetLevelDataFilePath2(filename);
        Debug.Log(filepath);

        filepath += ".lmd";
        WWW www = new WWW(filepath);

        yield return(www);

        while (www.isDone == false)
        {
            yield return(null);
        }
        if (www.error == null)
        {
            byte[]     gzipdata   = www.bytes;
            byte[]     levelData  = GameCommon.UnGZip(gzipdata);
            DataStream datastream = new DataStream(levelData, true);
            md.Deserialize(datastream);
            InitGame();
        }
        else
        {
            //GameLogTools.SetText("wwwError<<" + www.error + "<<" + filepath);
            Debug.Log("wwwError<<" + www.error + "<<" + filepath);
            (new EventChangeScene(GameSceneManager.SceneTag.Menu)).Send();
        }
    }
Esempio n. 8
0
    public void ShowHitBuff(Army army, BuffClass buff, int type)
    {
        if (GameConst.CanShowText() == false)
        {
            return;
        }
        string temp = "";

        switch (type)
        {
        case 0:
            temp = "\t\t" + "<color=" + GameConst.Color.redColor + "【" + army.name + "】</color>的" + "<color=" + GameConst.Color.yellowColor +
                   buff.effectName + "</color>" + "效果无法施加,存在一个相同或更强的效果";
            break;

        case 1:
            temp = "\t\t" + "<color=" + GameConst.Color.redColor + "【" + army.name + "】</color>的" + "<color=" + GameConst.Color.yellowColor +
                   buff.effectName + "</color>" + "效果已施加 (来自 " + buff.skill.name + " )";
            break;

        case 2:
            temp = "\t\t" + "<color=" + GameConst.Color.redColor + "【" + army.name + "】</color>的" + "<color=" + GameConst.Color.yellowColor +
                   buff.effectName + "</color>" + "效果被刷新了! (来自 " + buff.skill.name + " )";
            break;

        case 3:

            break;
        }



        Append(temp);
    }
Esempio n. 9
0
 public static string FillUIResPath(string fileName)
 {
     if (fileName.StartsWith("Assets/"))
     {
         return(fileName);
     }
     return(GameConst.GetUIResPath() + "/" + fileName);
 }
Esempio n. 10
0
    // 在空格处放上表情动画
    private GameObject ReplaceEmojiWithPicture(string faceName)
    {
        GameObject        sprite;
        UISprite          spFace;
        UISpriteAnimation spaFace;
        AnimationVO       aniConfig = GameConst.GetAnimationConfigByIndex(faceName);

        sprite  = GameObject.Instantiate(faceTemplate);
        spFace  = sprite.GetComponent <UISprite>();
        spaFace = sprite.GetComponent <UISpriteAnimation>();

        spFace.GetComponent <UIWidget>().width  = (int)(cellLength * aniConfig.spaceNum * 0.5f);
        spFace.GetComponent <UIWidget>().height = (int)cellLength * aniConfig.rowNum;

        sprite.transform.parent = emojiContainer;
        spFace.spriteName       = faceName + "_1";
        spaFace.namePrefix      = faceName + "_";

        if (aniConfig != null)
        {
            if (aniConfig.isNotPlay)
            {
                StopAudioAnimation(spaFace);
                if (aniConfig.isAudio)
                {
                    RegistUIButton(gameObject, (go) => {
                        if (chatData == null || chatData.voiceData == null)
                        {
                            return;
                        }
                        Byte[] wavData = SevenZipCompress.Decompress(chatData.voiceData);
                        _microPhoneInput.PlayClipData(wavData);
                        spaFace.Play();
                        Director.GetInstance().scheduler.SetTimeOut(chatData.time, () => {
                            StopAudioAnimation(spaFace);
                        });
                    });
                }
            }
            spaFace.framesPerSecond = aniConfig.rate;
        }
        if (!aniConfig.isAudio)
        {
            sprite.GetComponent <Collider>().enabled = false;
        }
        Vector3 tmpPos;

        sprite.transform.localScale = Vector3.one;
        tmpPos   = picIndex;
        tmpPos.y = picIndex.y + cellLength * (aniConfig.rowNum - 1);

        sprite.transform.localPosition = tmpPos;
        sprite.name = faceName;
        sprite.SetActive(true);
        spFace.ResizeCollider();

        return(sprite);
    }
Esempio n. 11
0
    public void LoadLevel(string fileName)
    {
        byte[]     levelGzipData = GameCommon.ReadByteToFile(GameConst.GetLevelDataFilePath(fileName + ".lmd"));
        byte[]     levelData     = GameCommon.UnGZip(levelGzipData);
        DataStream datastream    = new DataStream(levelData, true);

        ReloadScene(datastream);
        Closeed();
    }
Esempio n. 12
0
    public void ShowTrun(int num)
    {
        if (GameConst.CanShowText() == false)
        {
            return;
        }
        string temp = "\n\t\t\t<color=" + GameConst.Color.lightColor + "__________第 " + num + " 回合__________</color>";

        Append(temp);
    }
Esempio n. 13
0
    public void BattleBegin(int num)
    {
        if (GameConst.CanShowText() == false)
        {
            return;
        }
        string temp = "\n<color=" + GameConst.Color.lightColor + "############第 " + num + " 场战斗开始#############</color>\n";

        Append(temp);
    }
Esempio n. 14
0
    public void BattleEnd(int num)
    {
        if (GameConst.CanShowText() == false)
        {
            return;
        }
        string temp = "\n<color=" + GameConst.Color.lightColor + "____________________第 " + num + " 场战斗结束____________________</color>\n";

        Append(temp);
    }
Esempio n. 15
0
    public void SaveData()
    {
        UserDataMode userdatamode = new UserDataMode();

        userdatamode.SetData(userData);

        byte[] data     = GameCommon.SerializeObject(userdatamode);
        byte[] gzipData = GameCommon.CompressGZip(data);
        GameCommon.WriteByteToFile(gzipData, GameConst.GetPersistentDataPath(GameConst.userDataFileName));
    }
Esempio n. 16
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="gameTime">時間</param>
        public void Update(GameTime gameTime)
        {
            if (inputState.WasDown(Keys.I))
            {
                Parameter.IsDebug = !Parameter.IsDebug;
            }

            if (isEnd)
            {
                return;
            }
            if (inputState.WasDown(Keys.P))
            {
                TaskManager.ChangePause();
                isPause = !isPause;
            }
            if (isPause)
            {
                return;
            }

            if (GameConst.IsEnding)
            {
                GameConst.Initialize();
                stageCreator.CreatPlayer();
                player = EntityManager.FindWithName("Player")[0];
                player.transform.Position = new Vector2(stageLoader.GetCheckPoint() * 10000 + 500, 500);

                return;
            }
            if (player.transform.Position.X >= Parameter.StageSize.X - 500)
            {
                GameConst.SetClear();
            }
            if (GameConst.IsClear)
            {
                stageNo++;
                Shutdown();
                Initialize();
                return;
            }

            int playerX = (int)player.transform.Position.X;

            if (playerX % 10000 <= 30)
            {
                stageLoader.SetPoint(playerX / 10000);
            }

            if (EntityManager.GetEntityCount() > 0)
            {
                Camera2D.Update(player.transform.Position);
            }
            Sound.PlayBGM("GamePlay");
        }
Esempio n. 17
0
 void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 18
0
    public void SaveData(params BaseUserData[] datas)
    {
        for (int i = 0; i < datas.Length; i++)
        {
            DataStream stream = new DataStream(true);
            datas[i].Serialize(stream);

            byte[] gzipData = GameCommon.CompressGZip(stream.ToByteArray());
            GameCommon.WriteByteToFile(gzipData, GameConst.GetPersistentDataPath(datas[i].GetDataType() + ""));
        }
    }
Esempio n. 19
0
    public void NextBattle()
    {
        if (GameConst.CanShowText() == false)
        {
            return;
        }

        showStringList.Add(showString);
        GameConst.curShowTextConut = showStringList.Count;
        showString = null;
    }
Esempio n. 20
0
    public void ShowHurt(Army army, float damage)
    {
        if (GameConst.CanShowText() == false)
        {
            return;
        }

        string temp = "\t\t" + "<color=" + army.color + "【" + army.name + "】</color>损失了" + "<color=" + GameConst.Color.yellowColor + damage.ToString("0.0") + "</color>" + "兵力 (" + army.getCount().ToString("0") + ")";

        Append(temp);
    }
Esempio n. 21
0
    public void ShowAttack(Army attacker, Army defender)
    {
        if (GameConst.CanShowText() == false)
        {
            return;
        }

        string temp = "" + "<color=" + attacker.color + "【" + attacker.name + "】</color>对" + "<color=" + defender.color + "【" + defender.name + "】</color>" + "发动普通攻击";

        Append(temp);
    }
Esempio n. 22
0
    static void WriteDataToFile(LevelOption od, DataStream data)
    {
        string filePath = GameConst.GetLevelDataFilePath(od.levelName + ".bytes");

        byte[] objData     = data.ToByteArray();
        byte[] objGzipData = GameCommon.CompressGZip(objData);
        GameCommon.WriteByteToFile(objGzipData, filePath);

        Debug.Log("save path : " + filePath);
        EditorUtility.DisplayDialog("导出关卡" + od.levelName + "成功!", filePath, "确定");
    }
Esempio n. 23
0
    public float SetText(string text)
    {
        if (_microPhoneInput == null)
        {
            _microPhoneInput = NGUITools.FindInParents <MicroPhoneInput>(gameObject);
            emojiContainer   = transform.Find("emojis");
            faceTemplate     = transform.Find("Sprite").gameObject;
            faceTemplate.SetActive(false);
            _lblChatInfo = transform.GetComponent <UILabelCustom>();
            if (!isColorSet)
            {
                curColor   = _lblChatInfo.color;
                isColorSet = true;
            }
            if (_lblChatInfo.gameObject.GetComponent <BoxCollider>() == null)
            {
                _lblChatInfo.gameObject.AddComponent <BoxCollider>();
            }
        }

        emojiContainer.DestroyChildren();

        _lblChatInfo.color = Color.white;
        text = NGUIText.EncodeColor(text, curColor);
        _lblChatInfo.ProcessText();
        _lblChatInfo.UpdateNGUIText();
        cellLength = _lblChatInfo.fontSize + _lblChatInfo.floatSpacingY;

        _lblChatInfo.text = SetEmoji(text, (faceName) => {
            AnimationVO aniConfig;
            aniConfig = GameConst.GetAnimationConfigByIndex(faceName);
            //根据文本算出表情的初步坐标(如果后面添加了更高的表情需要重新调整位置)
            GameObject sprite = ReplaceEmojiWithPicture(faceName);
            Vector3 temPos;
            sprites.Add(sprite);

            //对齐同一行的表情
            float vetY = sprite.transform.localPosition.y - cellLength * (aniConfig.rowNum - 1);
            for (int i = 0; i < sprites.Count; i++)
            {
                aniConfig = GameConst.GetAnimationConfigByIndex(sprites[i].name);
                temPos    = sprites[i].transform.localPosition;
                temPos.y  = vetY + (aniConfig.rowNum - 1) * cellLength;
                sprites[i].transform.localPosition = temPos;
            }
        });
        _lblChatInfo.ResizeCollider();
        isUseUrl = _isUseUrl;
        return(rowDict[rowList[0]] * cellLength);
    }
Esempio n. 24
0
 protected override eStateTrans UpdateAction(Entity entity, ref IState <Entity> nextState)
 {
     entity.GetDrawComponent("C_DrawAnimetion").alpha -= 0.05f;
     if (entity.GetDrawComponent("C_DrawAnimetion").alpha <= 0)
     {
         if (entity.GetName() == "Player")
         {
             GameConst.SetEnding();
         }
         entity.DeActive();
     }
     nextState = this;
     return(eStateTrans.ToThis);
 }
Esempio n. 25
0
    /* private Coroutine PlayerSwipeLeft;
     * private Coroutine PlayerSwipeRight;
     *
     * private Coroutine BlockSwipeLeft;
     * private Coroutine BlockSwipeRight;
     *
     * private Coroutine ChildBlockSwipeLeft;
     * private Coroutine ChildBlockSwipeRight;*/

    public void Awake()
    {
        Application.targetFrameRate = 60;

        if (instance == null)
        {
            //Debug.Log("game created");
            instance = this;
        }
        else
        {
            //Debug.LogError("New game destroyed");
            Destroy(this.gameObject);
        }

        Time.timeScale = 0f;
        isGameOn       = false;

        if (PlayerPrefs.HasKey("PlayedTime"))
        {
            playedTime = PlayerPrefs.GetInt("PlayedTime");
        }
        else
        {
            playedTime = 0;
            PlayerPrefs.SetInt("PlayedTime", playedTime);
        }

        gameMode = DataScript.isGameModeEndless;

        if (gameMode == 0)
        {
            //PlayerPrefs.SetInt("PlayerLevel",30);
            Level = PlayerPrefs.GetInt("PlayerLevel");
            DataScript.ThemeIndex = (Level - 1) % DataScript.Themes.Count;
            Debug.LogWarning("Game mode is Level ");
        }
        else if (gameMode == 1)
        {
            DataScript.ThemeIndex = 0;
            Level = 1;
        }
        else
        {
            Debug.LogError("Non existing game mode");
            Debug.LogWarning("Game mode is Endless");
        }
        Debug.LogWarning("Level is : " + Level);
    }
Esempio n. 26
0
        /// <summary>
        /// 初期化
        /// </summary>
        public void Initialize()
        {
            isEnd   = false;
            isPause = false;
            GameConst.Initialize();

            stageLoader.SetStage(stageNo);

            //Entity初期化
            stageCreator.CreateStage(stageNo);
            player = EntityManager.FindWithName("Player")[0];

            //Debug用
            DebugInitialize();
        }
Esempio n. 27
0
 static int GetRelativePath(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         string arg0 = ToLua.CheckString(L, 1);
         string arg1 = ToLua.CheckString(L, 2);
         string o    = GameConst.GetRelativePath(arg0, arg1);
         LuaDLL.lua_pushstring(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 28
0
    void Attack()
    {
        currentAttackCount = 0;
        int row = GameConst.getRow(playerBox.Center.y);
        int col = GameConst.getCol(playerBox.Center.x);

        AttackFirst(row, col);
        if (currentAttackCount < AttackCount)
        {
            AttackSecond(row, col);
            if (currentAttackCount < AttackCount)
            {
                AttackThird(row, col);
            }
        }
    }
Esempio n. 29
0
 public void LoadAsset(string path, Action <UnityObject> callback)
 {
     m_State = AssetLoaderState.Loading;
     if (GameConst.GetInstance().m_AssetLoaderMode == AssetLoaderMode.AssetDatabase)
     {
         UnityObject obj = LoadAssetFromLocal(path, callback);
         m_State    = AssetLoaderState.Complete;
         m_Progress = 1;
         callback(obj);
     }
     else
     {
         m_asyncOperation = LoadAssetFromBuild(path, callback);
         m_State          = AssetLoaderState.Complete;
         m_Progress       = m_asyncOperation.progress;
     }
 }
Esempio n. 30
0
 public bool addToList(ref List <Vector2> list, int row, int col)
 {
     if (row < 0 || row >= GameConst.height)
     {
         return(false);
     }
     if (col < 0 || col >= GameConst.width)
     {
         return(false);
     }
     if (GameConst.hasObstacleOrBubble(row, col))
     {
         return(false);
     }
     list.Add(new Vector2(col, row));
     return(true);
 }