public BattleCharactersManager(CBattlefield controller, MBaseMap model, VBaseMap view) { cBattlefield = controller; mBaseMap = model; vBaseMap = view; baseMapMaster = BaseMapCacher.Instance.Get(mBaseMap.MapId); }
/// <summary> /// 点击地图块儿 /// </summary> /// <param name="index">地图块儿索引</param> public virtual void OnClickTile(int index) { App.Model.Master.MBaseMap topMapMaster = BaseMapCacher.Instance.Get(mBaseMap.MapId); Vector2 coordinate = topMapMaster.GetCoordinateFromIndex(index); App.Model.MTile tile = System.Array.Find(mBaseMap.Tiles, _ => _.x == coordinate.x && _.y == coordinate.y); OnClickTile(tile); }
protected override void InitMap() { MUser mUser = App.Util.Global.SUser.self; //地图需要判断是否变化,所以另准备一个Model mBaseMap = new MTopMap(); mBaseMap.MapId = mUser.MapId; mBaseMap.Tiles = mUser.TopMap.Clone() as App.Model.MTile[]; base.InitMap(); System.Array.Sort(mUser.characters, (a, b) => { App.Model.Master.MCharacter aMaster = a.Master; App.Model.Master.MCharacter bMaster = b.Master; if (bMaster.qualification != aMaster.qualification) { return(bMaster.qualification - aMaster.qualification); } if (b.Star != a.Star) { return(b.Star - a.Star); } return(b.Level - a.Level); }); App.Model.Master.MBaseMap topMapMaster = BaseMapCacher.Instance.Get(mBaseMap.MapId); int x = Mathf.FloorToInt(topMapMaster.width * 0.5f); int y = Mathf.FloorToInt(topMapMaster.height * 0.5f); int[][] vecs = new int[][] { new int[] { 0, 0 }, new int[] { -1, 3 }, new int[] { 1, 2 }, new int[] { -1, -2 }, new int[] { 1, -3 } }; //MCharacter[] characters = new MCharacter[5]; //System.Array.Copy(mUser.characters, characters, 5); //int i = 0; List <MCharacter> characters = new List <MCharacter>(); foreach (MCharacter character in mUser.characters) { int[] vec = vecs[characters.Count]; character.CoordinateX = x + vec[0]; character.CoordinateY = y + vec[1]; character.StatusInit(); characters.Add(character); if (characters.Count >= vecs.Length) { break; } } mBaseMap.Characters = characters.ToArray(); vBaseMap.BindingContext = mBaseMap.ViewModel; vBaseMap.UpdateView(); vBaseMap.transform.parent.localScale = Vector3.one; vBaseMap.MoveToPosition(); charactersContent.UpdateView(mUser.characters); }
public TileMap(MBaseMap model, VBaseMap view) { mBaseMap = model; vBaseMap = view; if (mBaseMap.MapId > 0) { baseMapMaster = BaseMapCacher.Instance.Get(mBaseMap.MapId); } }
public void ResetAll(App.Model.Master.MBaseMap baseMapMaster = null) { if (baseMapMaster == null) { Debug.LogError("ViewModel.MapId.Value = " + ViewModel.MapId.Value); baseMapMaster = BaseMapCacher.Instance.Get(ViewModel.MapId.Value); } int widthCount = 0; int heightCount = 0; int i = 0; VTile obj = null; foreach (VTile tile in tileUnits) { tile.gameObject.SetActive(false); } if (baseMapMaster.tiles != null && baseMapMaster.tiles.Count > 0) { foreach (App.Model.Master.MTile tile in baseMapMaster.tiles) { i = heightCount * mapWidth + widthCount; obj = tileUnits[i]; obj.gameObject.SetActive(true); App.Model.MTile building = System.Array.Find(ViewModel.Tiles.Value, _ => _.x == widthCount && _.y == heightCount); //if(building != null)Debug.LogError(widthCount + ","+heightCount + ", " + building.Master); string name = ""; if (building != null) { if (building is App.Model.Master.MWorld) { name = (building as App.Model.Master.MWorld).build_name; }/*else if (building is App.Model.Master.MArea) * { * name = (building as App.Model.Master.MArea).build_name; * }*/ } obj.SetData(heightCount * baseMapMaster.width + widthCount, widthCount, heightCount, tile.id, building != null ? building.Master.id : 0, name); widthCount++; if (widthCount >= baseMapMaster.width) { widthCount = 0; heightCount++; } if (heightCount >= baseMapMaster.height) { break; } } } BoxCollider collider = this.GetComponent <BoxCollider>(); collider.size = new Vector3(baseMapMaster.width * tileWidth + 0.345f, baseMapMaster.height * tileHeight + 0.2f, 0f); collider.center = new Vector3(collider.size.x * 0.5f - 0.345f, -collider.size.y * 0.5f + 0.4f, 0f); mousePosition.x = int.MinValue; dragPosition.x = int.MinValue; }
public BreadthFirst(App.Controller.Common.CBaseMap controller, MBaseMap model, VBaseMap view) { cBaseMap = controller; mBaseMap = model; vBaseMap = view; if (cBaseMap is App.Controller.Battle.CBattlefield) { cBattlefield = cBaseMap as App.Controller.Battle.CBattlefield; } baseMapMaster = BaseMapCacher.Instance.Get(mBaseMap.MapId); }
public override void OnClickTile(int index) { App.Model.Master.MBaseMap topMapMaster = BaseMapCacher.Instance.Get(mBaseMap.MapId); Vector2 coordinate = topMapMaster.GetCoordinateFromIndex(index); List <VCharacter> vCharacters = vBaseMap.Characters; VCharacter vCharacter = vBaseMap.Characters.Find(_ => _.ViewModel.CoordinateX.Value == coordinate.x && _.ViewModel.CoordinateY.Value == coordinate.y); if (vCharacter != null) { App.Util.LSharp.LSharpScript.Instance.Analysis(new List <string> { string.Format("Call.characterclick_{0}();", vCharacter.ViewModel.Id.Value) }); } }
private IEnumerator Build(int buildId, VBaseMap vBaseMap, App.Model.Master.MBuilding buildingMaster) { App.Model.Master.MBaseMap topMapMaster = BaseMapCacher.Instance.Get(vBaseMap.ViewModel.MapId.Value); Vector2 coordinate = topMapMaster.GetCoordinateFromIndex(tileIndex); SShop sShop = new SShop(); yield return(StartCoroutine(sShop.RequestBuyBuild(buildId, (int)coordinate.x, (int)coordinate.y))); App.Model.MTile currentTile = App.Model.MTile.Create(buildingMaster.tile_id, (int)coordinate.x, (int)coordinate.y); List <App.Model.MTile> tileList = vBaseMap.ViewModel.Tiles.Value.ToList(); tileList.Add(currentTile); vBaseMap.ViewModel.Tiles.Value = tileList.ToArray(); this.Close(); }
public override void OnClickTile(int index) { App.Model.Master.MBaseMap topMapMaster = BaseMapCacher.Instance.Get(mBaseMap.MapId); Vector2 coordinate = topMapMaster.GetCoordinateFromIndex(index); App.Model.MTile tile = System.Array.Find(mBaseMap.Tiles, _ => _.x == coordinate.x && _.y == coordinate.y); if (tile == null) { buildingMenu.currentIndex = index; OpenMenu(buildingMenu); } else { OpenMenu(strengthenMenu); } }
public void MoveToPosition(int x = int.MinValue, int y = 0, App.Model.Master.MBaseMap baseMapMaster = null) { if (baseMapMaster == null) { baseMapMaster = BaseMapCacher.Instance.Get(ViewModel.MapId.Value); } if (x == int.MinValue) { x = Mathf.FloorToInt(baseMapMaster.width / 2f); y = Mathf.FloorToInt(baseMapMaster.height / 2f); } int i = y * mapWidth + x; VTile obj = tileUnits[i]; Camera3dToPosition(obj.transform.position.x, obj.transform.position.y - 9f); obj = tileUnits[0]; minPosition = new Vector2(obj.transform.position.x, obj.transform.position.y - 9f); i = (baseMapMaster.height - 1) * mapWidth + baseMapMaster.width - 1; obj = tileUnits[i]; maxPosition = new Vector2(obj.transform.position.x, obj.transform.position.y - 9f); }
private void MapIdChanged(int oldvalue, int newvalue) { App.Model.Master.MBaseMap baseMapMaster = BaseMapCacher.Instance.Get(newvalue); ResetAll(baseMapMaster); }