Ejemplo n.º 1
0
    public void InitPlayers()
    {
        var aps = this.GetAllPlayers();
        Dictionary <int, int> playerPosDic = new Dictionary <int, int>();

        var poses = new TNet.List <int>();

        foreach (var m in _cellStyleDic)
        {
            var style = (MapStyle)m.Value;
            if (style == MapStyle.CANYON || style == MapStyle.HILL)
            {
                continue;
            }

            poses.Add(m.Key);
        }

        foreach (var p in aps)
        {
            var idx = Random.Range(0, poses.Count);

            playerPosDic.Add(p.id, poses[idx]);
            poses.Remove(idx);
        }

        tno.Send("RFC_SyncPlayersPosInfoAndCreatePlayer", Target.All, playerPosDic.ToJsonString());
    }
Ejemplo n.º 2
0
    private void InitMapByHoset()
    {
        // Let's not try to create objects unless we are in this channel
        if (TNManager.isConnected && !TNManager.IsInChannel(GameCtr.Instance.ChannelID))
        {
            return;
        }
        if (!TNManager.isHosting)
        {
            return;
        }

        var aps         = this.GetAllPlayers();
        var mapStyleDic = new Dictionary <int, int> ();

        var poses = new TNet.List <int>();

        for (int i = 0; i < MapMgr.Instance.MapCellCount; i++)
        {
            poses.Add(i);
        }

        for (int i = 0; i < aps.Count; i++)
        {
            var posIdx = Random.Range(0, poses.Count);
            mapStyleDic.Add(posIdx, (int)MapStyle.PLAIN);
            poses.Remove(posIdx);
        }

        foreach (var p in poses)
        {
            mapStyleDic.Add(p, Random.Range(0, System.Enum.GetNames(typeof(MapStyle)).Length));
        }

        tno.Send("RFC_InitMap", Target.All, mapStyleDic.ToJsonString());
    }