Пример #1
0
    public static void Init(TurrentSDS _csv, BinaryReader _br)
    {
        _csv.canAttackBase      = _br.ReadBoolean();
        _csv.attackDamage       = _br.ReadInt32();
        _csv.attackDamageAdd    = _br.ReadInt32();
        _csv.attackDamageAddGap = _br.ReadInt32();
        _csv.attackDamageAddMax = _br.ReadInt32();
        _csv.attackDamageType   = _br.ReadInt32();
        _csv.attackGap          = _br.ReadInt32();
        _csv.ID         = _br.ReadInt32();
        _csv.updateType = _br.ReadInt32();
        _csv.icon       = _br.ReadString();
        int lengthattackSplashPos = _br.ReadInt32();

        _csv.attackSplashPos = new string[lengthattackSplashPos];
        for (int i = 0; i < lengthattackSplashPos; i++)
        {
            _csv.attackSplashPos[i] = _br.ReadString();
        }
        int lengthattackTargetPos = _br.ReadInt32();

        _csv.attackTargetPos = new string[lengthattackTargetPos];
        for (int i = 0; i < lengthattackTargetPos; i++)
        {
            _csv.attackTargetPos[i] = _br.ReadString();
        }
    }
Пример #2
0
    public static Dictionary <Type, IDictionary> Init(byte[] _bytes)
    {
        MemoryStream ms = new MemoryStream(_bytes);
        BinaryReader br = new BinaryReader(ms);
        Dictionary <Type, IDictionary> dic        = new Dictionary <Type, IDictionary>();
        Dictionary <int, AuraSDS>      AuraSDSDic = new Dictionary <int, AuraSDS>();
        int lengthAuraSDS = br.ReadInt32();

        for (int i = 0; i < lengthAuraSDS; i++)
        {
            AuraSDS unit = new AuraSDS();
            AuraSDS_c.Init(unit, br);
            unit.Fix();
            AuraSDSDic.Add(unit.ID, unit);
        }
        dic.Add(typeof(AuraSDS), AuraSDSDic);
        Dictionary <int, TurrentSDS> TurrentSDSDic = new Dictionary <int, TurrentSDS>();
        int lengthTurrentSDS = br.ReadInt32();

        for (int i = 0; i < lengthTurrentSDS; i++)
        {
            TurrentSDS unit = new TurrentSDS();
            TurrentSDS_c.Init(unit, br);
            unit.Fix();
            TurrentSDSDic.Add(unit.ID, unit);
        }
        dic.Add(typeof(TurrentSDS), TurrentSDSDic);
        Dictionary <int, UnitSDS> UnitSDSDic = new Dictionary <int, UnitSDS>();
        int lengthUnitSDS = br.ReadInt32();

        for (int i = 0; i < lengthUnitSDS; i++)
        {
            UnitSDS unit = new UnitSDS();
            UnitSDS_c.Init(unit, br);
            unit.Fix();
            UnitSDSDic.Add(unit.ID, unit);
        }
        dic.Add(typeof(UnitSDS), UnitSDSDic);
        br.Close();
        ms.Close();
        ms.Dispose();
        return(dic);
    }
Пример #3
0
    public void Init(BattleManager _battleManager, bool _isMine, Unit _unit, int _pos)
    {
        battleManager = _battleManager;

        isMine = _isMine;

        unit = _unit;

        sds = unit.sds as UnitSDS;

        text.text = sds.name;

        int unitWidth = 0;

        int unitHeight = 0;

        for (int i = 0; i < sds.pos.Length; i++)
        {
            int pos = sds.pos[i];

            int nowX = pos % BattleConst.MAP_WIDTH;

            int nowY = pos / BattleConst.MAP_WIDTH;

            if (nowX > unitWidth)
            {
                unitWidth = nowX;
            }

            if (nowY > unitHeight)
            {
                unitHeight = nowY;
            }
        }

        unitWidth += 1;

        unitHeight += 1;

        float screenWidth = (transform.root as RectTransform).sizeDelta.x;

        float width = screenWidth / BattleConst.MAP_WIDTH;

        bgWidth = width * unitWidth - sizeFix;

        container.sizeDelta = new Vector2(bgWidth, width * unitHeight - sizeFix);

        if (isMine)
        {
            container.anchoredPosition = new Vector2(width * unitWidth * 0.5f - 0.5f * width, -(width * unitHeight * 0.5f - 0.5f * width));
        }
        else
        {
            container.anchoredPosition = new Vector2(-(width * unitWidth * 0.5f - 0.5f * width), width * unitHeight * 0.5f - 0.5f * width);
        }

        for (int i = 0; i < sds.turrent.Length; i++)
        {
            int turrentID = sds.turrent[i];

            TurrentSDS turrentSDS = StaticData.GetData <TurrentSDS>(turrentID);

            BattleTurrent turrent;

            if (turrentList.Count == i)
            {
                turrent = Instantiate(turrentRes);

                turrent.transform.SetParent(turrentContainer, false);

                turrentList.Add(turrent);
            }
            else
            {
                turrent = turrentList[i];
            }

            int pos = sds.pos[i];

            turrent.transform.position = battleManager.GetPos(isMine, _pos + pos);

            turrent.gameObject.SetActive(!string.IsNullOrEmpty(turrentSDS.icon));
        }

        while (turrentList.Count > sds.turrent.Length)
        {
            Destroy(turrentList[turrentList.Count - 1].gameObject);

            turrentList.RemoveAt(turrentList.Count - 1);
        }

        Refresh();
    }