示例#1
0
    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);
    }
示例#2
0
    public void RemoveTail()
    {
        GameUnitLink link = links.Last.Value;

        GameMap.Instance.RemoveUnit(link);
        links.RemoveLast();
    }
示例#3
0
    /// <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);
    }
示例#4
0
    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);
    }
示例#5
0
    public GameUnitLink CreateLink(Color c)
    {
        GameUnitLink link = (GameUnitLink)Instantiate(baseLink);

        SpriteRenderer renderer = link.GetComponent <SpriteRenderer>();

        renderer.color = c;

        GameMap.Instance.RegisterUnit(link);

        return(link);
    }
示例#6
0
    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;
        }
    }
示例#7
0
    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);
        }
    }