private void CreateUnitGo(Unit _unit) { UnitSDS sds = _unit.sds as UnitSDS; GameObject go = GameObjectFactory.Instance.GetGameObject(sds.model, null); go.transform.SetParent(unitContainer, false); PublicTools.SetLayer(go, unitContainer.gameObject.layer); // if(_unit.isMine == battle.clientIsMine){ // // go.GetComponent<Renderer> ().material.SetColor ("_Color", Color.blue); // // }else{ // // go.GetComponent<Renderer> ().material.SetColor ("_Color", Color.yellow); // } HeroStateMachine2 hm = go.GetComponent <HeroStateMachine2> (); hm.Init(_unit, this); unitGoDic.Add(_unit.uid, hm); unitGoList.AddLast(_unit.uid); }
public void Init(int _uid, int _id) { uid = _uid; UnitSDS sds = StaticData.GetData <UnitSDS>(_id); nameText.text = sds.name; costText.text = sds.cost.ToString(); }
private void UnitCellClick(object _data) { UnitCellData data = _data as UnitCellData; int money = battle.clientIsMine ? battle.mMoney : battle.oMoney; UnitSDS sds = StaticData.GetData <UnitSDS> (data.id); if (money >= sds.prize) { battle.ClientSendUnitCommand(data.id); } }
public override bool SetData(object _data) { UnitCellData cellData = _data as UnitCellData; UnitSDS sds = StaticData.GetData <UnitSDS> (cellData.id); idTf.text = sds.ID.ToString(); prizeTf.text = sds.prize.ToString(); numTf.text = cellData.num.ToString(); return(base.SetData(_data)); }
//---- public void Init(Action <MemoryStream> _sendDataCallBack, Action _overCallBack) { battle = new Battle(); overCallBack = _overCallBack; battle.ClientInit(_sendDataCallBack, Refresh, SendCommandOK, BattleOver); SuperRaycast.SetIsOpen(true, "1"); SuperRaycast.checkBlockByUi = true; SuperRaycast.SetCamera(battleCamera); Dictionary <int, UnitSDS> tmpDic = StaticData.GetDic <UnitSDS> (); Dictionary <int, UnitSDS> .ValueCollection.Enumerator enumerator = tmpDic.Values.GetEnumerator(); while (enumerator.MoveNext()) { UnitSDS sds = enumerator.Current; if (sds.isHero) { HeroCellData cellData = new HeroCellData(sds.ID, false, 0, true); heroList.Add(cellData); heroDic.Add(sds.ID, cellData); } else { UnitCellData cellData = new UnitCellData(sds.ID, 0); unitList.Add(cellData); unitDic.Add(sds.ID, cellData); } } unitSuperList.SetData(unitList); heroSuperList.SetData(heroList); unitSuperList.CellClickHandle = UnitCellClick; gameObject.SetActive(false); SuperFunction.Instance.AddEventListener <RaycastHit, int> (quad, SuperRaycast.GetMouseClick, QuadClick); }
public void Init(Unit _hero, BattleManager _battleManager) { UnitSDS sds = _hero.sds as UnitSDS; float scale = sds.scale; transform.localScale = new Vector3(scale, scale, scale); transform.localPosition = _battleManager.GetUnitPos(_hero); damageTimes = 0; hero = _hero; battleManager = _battleManager; }
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); }
public override bool SetData(object _data) { HeroCellData cellData = _data as HeroCellData; UnitSDS sds = StaticData.GetData <UnitSDS> (cellData.id); idTf.text = sds.ID.ToString(); prizeTf.text = sds.prize.ToString(); if (cellData.added) { idTf.color = Color.red; } else { idTf.color = Color.black; } if (cellData.cd == 0) { cdImg.gameObject.SetActive(false); } else { cdImg.gameObject.SetActive(true); UnitSDS unitSDS = StaticData.GetData <UnitSDS>(cellData.id); SkillSDS skillSDS = StaticData.GetData <SkillSDS>(unitSDS.skill); cdImg.fillAmount = (float)cellData.cd / skillSDS.cd; } if (selected && !cellData.selectable) { superList.SetSelectedIndex(-1); } return(base.SetData(_data)); }
private void HeroCellClick(int _id, float _x, float _y) { if (heroDic [_id].added) { UnitSDS sds = StaticData.GetData <UnitSDS> (_id); if (sds.skill != 0) { battle.ClientSendSkillCommand(_id, _x, _y); } } else { int money = battle.clientIsMine ? battle.mMoney : battle.oMoney; UnitSDS sds = StaticData.GetData <UnitSDS> (_id); if (money >= sds.prize) { battle.ClientSendHeroCommand(_id, _x, _y); } } }
public static void Init(UnitSDS _csv, BinaryReader _br) { _csv.cd = _br.ReadInt32(); _csv.cost = _br.ReadInt32(); _csv.hp = _br.ReadInt32(); _csv.ID = _br.ReadInt32(); _csv.liveTime = _br.ReadInt32(); int lengthauras = _br.ReadInt32(); _csv.auras = new int[lengthauras]; for (int i = 0; i < lengthauras; i++) { _csv.auras[i] = _br.ReadInt32(); } int lengthpos = _br.ReadInt32(); _csv.pos = new int[lengthpos]; for (int i = 0; i < lengthpos; i++) { _csv.pos[i] = _br.ReadInt32(); } int lengthrow = _br.ReadInt32(); _csv.row = new int[lengthrow]; for (int i = 0; i < lengthrow; i++) { _csv.row[i] = _br.ReadInt32(); } int lengthturrent = _br.ReadInt32(); _csv.turrent = new int[lengthturrent]; for (int i = 0; i < lengthturrent; i++) { _csv.turrent[i] = _br.ReadInt32(); } _csv.name = _br.ReadString(); }
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(); }