//各种其他攻击方法 private void LightMagicGrid(Pair UV) { if (!InChessborad(UV)) { return; } GameObject gridObject = grids[UV]; if (gridObject.GetComponent <GridAttribute>().isObstacle) { return; } GridAttribute attribute = gridObject.GetComponent <GridAttribute>(); attribute.PreGridMaterial = gridObject.GetComponent <MeshRenderer>().material; attribute.PreActive = gridObject.activeSelf; if (attribute.isUnit) { UVStack.Push(UV); } if (!attribute.isUnit || FindUnitByUV(UV).GetComponent <UnitControler>().Ascription == turnControler.Ascription) { gridObject.GetComponent <MeshRenderer>().material = gridMagic; } if (!gridObject.activeSelf) { gridObject.SetActive(true); } }
public GridModel(GridAttribute gridAtt, ModelMetadata modelMetadata, IEnumerable dataSource, ViewContext viewContext) { this.GridAttribute = gridAtt; this.ModelMetadata = modelMetadata; DataSource = dataSource; this.ViewContext = viewContext; Initialize(); }
private bool WeakGrid(Pair UV, int lenth, Pair p) //激活格子同时预设路径 { if (!InChessborad(UV)) { return(false); } GameObject gridObject = grids[UV]; GridAttribute attribute = gridObject.GetComponent <GridAttribute>(); if (attribute.isObstacle) { return(false); } if (attribute.isUnit) { if (!attackFlag && lenth == turnControler.CountLenth - 1 && FindUnitByUV(UV).GetComponent <UnitControler>().Ascription != turnControler.Ascription) { attackFlag = true; } if (attackFlag && FindUnitByUV(UV).GetComponent <UnitControler>().Ascription != turnControler.Ascription) { gridObject.SetActive(true); gridObject.GetComponent <GridAttribute>().isActive = true; gridObject.GetComponent <MeshRenderer>().material = gridAttack; weakGrids.Push(UV); return(true); } return(false); } if (attribute.CountLenth >= 0) { if (lenth >= attribute.CountLenth && (p.First == UV.First || p.Second == UV.Second)) //期望走直线 { attribute.ParentUV = p; } return(false); } gridObject.SetActive(true); gridObject.GetComponent <GridAttribute>().isActive = true; attribute.CountLenth = lenth; attribute.ParentUV = p; //存储父节点 weakGrids.Push(UV); if (lenth > 0) { gridQueue.Enqueue(UV); } return(true); }
//创造障碍物 public void CreatObstacle() { Pair UV = new Pair(3, 4); GameObject obstacleObject = Instantiate(obstacle); GridAttribute attribute = grids[UV].GetComponent <GridAttribute>(); obstacleObject.transform.position = grids[UV].transform.position; attribute.isObstacle = true; UV = new Pair(4, 5); obstacleObject = Instantiate(obstacle); attribute = grids[UV].GetComponent <GridAttribute>(); obstacleObject.transform.position = grids[UV].transform.position; attribute.isObstacle = true; UV = new Pair(2, 3); obstacleObject = Instantiate(obstacle); attribute = grids[UV].GetComponent <GridAttribute>(); obstacleObject.transform.position = grids[UV].transform.position; attribute.isObstacle = true; }