Beispiel #1
0
 static Caches()
 {
     Account = new AccountCache();
     User    = new UserCache();
     Match   = new MatchCache();
     Fight   = new FightCache();
 }
Beispiel #2
0
        void HandleMonsterRefresh(FightRegion fr)
        {
            //send fight region
            bundle.region = fr;

            LvInfo lvInfo = LvInfoSQL.instance.GetValueByK(fr.scId);

            if (lvInfo != null)
            {
                //Fight g_Fight = JsonConvert.DeserializeObject<Fight>(lvInfo.scInfoJson);
                GameMonster[] gameMonsters = lvInfo.fight.gameMonsters[fr.index];
                bundle.gameMonsters = new GameMonster[gameMonsters.Length];
                for (int i = 0; i < gameMonsters.Length; i++)
                {
                    bundle.gameMonsters[i] = new GameMonster();
                    Tool.Copy(bundle.gameMonsters[i], gameMonsters[i]);
                }
            }

            Dictionary <string, GameMonster> gmDict = new Dictionary <string, GameMonster>();

            foreach (GameMonster gm in bundle.gameMonsters)
            {
                gmDict.Add(gm.id, gm);
            }
            FightCache cache = FightInstance.instance.GetFightCache(this.marsPeer.Role.roleId.ToString(), gmDict);

            this.marsPeer.fightCache = cache;
        }
Beispiel #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="id">is fightCache's id</param>
    /// <param name="msId">is gameMonster,s id</param>
    public void RemoveMS(string id, string msId)
    {
        FightCache fightCache = GetFightCache(id, null);

        if (fightCache != null)
        {
            fightCache.Remove(msId);
        }
    }
Beispiel #4
0
    /// <summary>
    /// Get a fightcache, if exist, get,  else new......
    /// fightcache's id is teamid...
    /// </summary>
    /// <param name="id">is team id</param>
    /// <param name="gameMonsters"></param>
    /// <returns></returns>
    public FightCache GetFightCache(string id, Dictionary <string, GameMonster> gameMonsters)
    {
        FightCache fightCache = null;

        if (Fights.TryGetValue(id, out fightCache) == false)
        {
            fightCache = new FightCache(id, gameMonsters);
            Fights.Add(fightCache);
        }
        else if (gameMonsters != null)
        {
            fightCache.AddRandge(gameMonsters);
        }
        return(fightCache);
    }
Beispiel #5
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="gm"></param>
    public void UpdateMonsters(string id, Dictionary <string, GameMonster> gameMonsters)
    {
        FightCache fightCache = GetFightCache(id, null);

        foreach (GameMonster gm in gameMonsters.Values)
        {
            if (fightCache != null)
            {
                GameMonster g_gm = fightCache.gameMonsters[gm.id];
                g_gm.x      = gm.x;
                g_gm.z      = gm.z;
                g_gm.xRo    = gm.xRo;
                g_gm.zRo    = gm.zRo;
                g_gm.action = gm.action;
                g_gm.state  = gm.state;
                if (g_gm.state == 1)
                {
                    g_gm.target_x = gm.target_x;
                    g_gm.target_y = gm.target_y;
                    g_gm.target_z = gm.target_z;
                }
            }
        }
    }
Beispiel #6
0
 /// <summary>
 /// Remove this fightCahe
 /// </summary>
 /// <param name="fightCache"></param>
 public void Remove(FightCache fightCache)
 {
     Debug.Log("**********" + Fights.Count);
     Fights.Remove(fightCache);
     Debug.Log("**********" + Fights.Count);
 }