public void HighlightSelectedAdv(UnitProxyEditor inRangeUnit, List <TileEditorProxy> visitable, List <TileEditorProxy> attackable) { bool canAtk = inRangeUnit.GetData().GetTurnActions().CanAttack(); bool canMv = inRangeUnit.GetData().GetTurnActions().CanMove(); if (BoardEditProxy.instance.GetTileAtPosition(inRangeUnit.GetPosition()) == this) { if (!canAtk && !canMv) { GetComponent <Renderer>().material.color = MOVE; } return; } if (canAtk) { if (attackable.Contains(this)) { if (HasUnit() && inRangeUnit.GetData().GetTeam() != GetUnit().GetData().GetTeam()) { GetComponent <Renderer>().material.color = ATK_ACTIVE; } } } if (canMv) { if (visitable.Contains(this)) { if (!(HasUnit() && canAtk)) { GetComponent <Renderer>().material.color = MOVE; } } } }
private void HighlightTiles(UnitProxyEditor obj) { foreach (var tile in allTiles) { tile.HighlightSelectedAdv(obj, visitableTiles, attackableTiles); } }
public Path <TileEditorProxy> GetPath(TileEditorProxy from, TileEditorProxy to, UnitProxyEditor thingToMove, bool allTiles = false) { return(PathGenerator.FindPath(from, to, GetDistanceFunction(thingToMove, allTiles), GetEstimationFunction(to, thingToMove)));//might not want to use a list }
public List <TileEditorProxy> GetAllVisitableNodes(UnitProxyEditor thingToMove, int rng, bool allTiles = false) { var startNode = GetTileAtPosition(thingToMove.GetPosition()); return(PathGenerator.FindAllVisitableNodes(startNode, rng, GetDistanceFunction(thingToMove, allTiles)) .ToList()); }
public void CreateUnitOnTile(UnitProxyEditor unt, int team) { UnitProxyEditor newEditable = Instantiate(unt, BoardEditProxy.instance.transform); UnitEdit cMeta = new UnitEdit(); cMeta.SetTeam(team); newEditable.PutData(cMeta); newEditable.Init(); newEditable.SetPosition(GetPosition()); ReceiveGridObjectProxy(newEditable); newEditable.SnapToCurrentPosition(); }
//public void SummonAtPosition(Vector3Int pos, int team, int val){ // UnitProxyEditor unit = glossary.GetComponent<Glossary>().summonedSkeleton; // PopulateAtPos(pos, unit, team, val); //} public void PopulateAtPos(Vector3Int pos, UnitProxyEditor unit, int team, int val) { TileEditorProxy tl = tiles[pos.x, pos.y]; //if (!tl.HasUnit()) { UnitProxyEditor newUnit = Instantiate(unit, transform); newUnit.Init(); newUnit.PutData(newUnit.GetData().SummonedData(team, val)); newUnit.GetData().SetSummoned(true); tl.ReceiveGridObjectProxy(newUnit); newUnit.SnapToCurrentPosition(); //} }
Func <TileEditorProxy, TileEditorProxy, double> GetDistanceFunction(UnitProxyEditor thingToMove, bool allTiles = false) { return((t1, t2) => { if (t2.CanReceive(thingToMove)) { return 1; } //else if (!t2.HasObstacle()) //{ // return allTiles ? 1 : int.MaxValue; //} //return int.MaxValue; return allTiles ? 1 : int.MaxValue; }); }
//public void ResetAtThis() //{ // StartCoroutine(ResetTiles()); //} public override void OnUnitSelected(UnitProxyEditor obj) { if (!UnitMoving) { if (currentUnit == null) { toAttack = null; UnHighlightTiles(); currentUnit = obj; //The maximum range in which a player has actions allTiles = BoardEditProxy.instance.GetAllVisitableNodes(obj, obj.GetMoveSpeed() > obj.GetAttackRange() ? obj.GetMoveSpeed() : obj.GetAttackRange(), true); //The attackable tiles attackableTiles = BoardEditProxy.instance.GetAllVisitableNodes(obj, obj.GetAttackRange(), true); //The visitable tiles visitableTiles = BoardEditProxy.instance.GetAllVisitableNodes(obj, obj.GetMoveSpeed()); HighlightTiles(obj); //PanelControllerNew.SwitchChar(obj); } } }
public void OnUnitSelected(UnitProxyEditor unit) { _currentMode.OnUnitSelected(unit); }
public abstract void OnUnitSelected(UnitProxyEditor unit);
public override void OnClear(TileEditorProxy tile) { tile.UnHighlight(); currentUnit = null; }
public void OnDisable() { UnHighlightTiles(); currentUnit = null; }
public override void OnUnitSelected(UnitProxyEditor unit) { //if in default mode, if a unit is selected, enter unit mode //InteractivityManagerEditor.instance.EnterUnitSelectedMode(); //InteractivityManagerEditor.instance.OnUnitSelected(unit);//forward the event to the new mode }
Func <TileEditorProxy, double> GetEstimationFunction(TileEditorProxy destination, UnitProxyEditor thingToMove) { return((t) => { Vector3Int t1Pos = t.GetPosition(); Vector3Int t2Pos = destination.GetPosition(); int xdiff = Mathf.Abs(t1Pos.x - t2Pos.x); int ydiff = Mathf.Abs(t1Pos.y - t2Pos.y); return xdiff + ydiff; }); }