public void AddLink(Tile t) { if (currSize >= maxSize) { return; } GameUnitLink newLink = null; if (links.Count > 0) { newLink = (GameUnitLink)Instantiate(links.Last.Value); GameMap.Instance.RegisterUnit(newLink); } else { newLink = CharacterBuilder.Instance.CreateLink(linkColor); } newLink.name = _head.name + "." + links.Count; newLink.head = _head; newLink.SetTile(t); links.AddFirst(newLink); }
public void RemoveTail() { GameUnitLink link = links.Last.Value; GameMap.Instance.RemoveUnit(link); links.RemoveLast(); }
/// <summary> /// Assumes that a unit exists at the tile, and selects it. /// </summary> public void SelectTile(Tile t) { selectedCharacter = null; selectedUnit = t.currUnit; tileHighlighter.ClearHighlightedTiles(); switch (selectedUnit.unitType) { case UnitType.Character: selectedCharacter = (GameCharacter)selectedUnit; if (!selectedCharacter.finished) { tileHighlighter.HighlightTilesInPathingRange(t, selectedCharacter.move.movesLeft, Color.white, true); } break; case UnitType.Link: GameUnitLink temp = (GameUnitLink)selectedUnit; SelectTile(temp.head.currTile); return; } tileHighlighter.HighlightTile(t, HighlightStyle.Border, Color.green); unitCard.UpdateCard(selectedUnit, true); }
public bool CanCastOnTarget(SpellData spell, Tile target) { ValidTargets validTargets = spell.validTargets; if (target.currUnit != null) { UnitType type = target.currUnit.unitType; switch (type) { case UnitType.Character: GameCharacter targetCharacter = (GameCharacter)target.currUnit; if (targetCharacter != caster) { if (targetCharacter.owningPlayer != caster.owningPlayer) { if ((validTargets & ValidTargets.Enemy) == ValidTargets.Enemy) { return(true); } } else if ((validTargets & ValidTargets.Ally) == ValidTargets.Ally) { return(true); } } else if ((validTargets & ValidTargets.Self) == ValidTargets.Self) { return(true); } break; case UnitType.Link: GameUnitLink targetLink = (GameUnitLink)target.currUnit; if (targetLink.head.owningPlayer != caster.owningPlayer) { if ((validTargets & ValidTargets.Enemy) == ValidTargets.Enemy) { return(true); } } else if ((validTargets & ValidTargets.Ally) == ValidTargets.Ally) { return(true); } break; } } else if ((validTargets & ValidTargets.Tile) == ValidTargets.Tile) { return(true); } return(false); }
public GameUnitLink CreateLink(Color c) { GameUnitLink link = (GameUnitLink)Instantiate(baseLink); SpriteRenderer renderer = link.GetComponent <SpriteRenderer>(); renderer.color = c; GameMap.Instance.RegisterUnit(link); return(link); }
public override void Activate(GameCharacter self, Tile target = null, SpellEffectFinishedDelegate finishedCallback = null) { switch (target.currUnit.unitType) { case UnitType.Character: GameCharacter targetChar = (GameCharacter)target.currUnit; targetChar.Damage(99, self, () => { finishedCallback(); }); break; case UnitType.Link: GameUnitLink targetLink = (GameUnitLink)target.currUnit; targetLink.head.Damage(99, self, () => { finishedCallback(); }); break; } }
public override void Activate(GameCharacter self, Tile target = null, SpellEffectFinishedDelegate finishedCallback = null) { // get unit adjacent tail // transport to target if (!GameMap.Instance.IsTileValid(target)) { return; } GameUnitLink tail = self.health.tail; this.self = self; List <Tile> allyTiles = GameMap.Instance.ComputeTilesInRange(tail.GetTile(), 1, IsTileAlly); Tile allyTile = allyTiles.FirstOrDefault(); if (allyTile != null) { GameCharacter ally = (GameCharacter)allyTile.currUnit; ally.health.SetSize(1); ally.SetTile(target); } }