Example #1
0
    public void setEntity(Entity entity)
    {
        removeEntity();
        if (entity != null)
        {
            entity.getCurrentTile().setEntity(null);
            entity.setCurrentTile(this);
        }
        this.entityPresent = entity;

    }
Example #2
0
    public override bool ValidateSelection(Entity entity)
    {
        if (character.GetActionPoints() <= 0) return false;
        switch (targetType)
        {
            case TargetType.Character:
                if (entity.GetEntityType() != "SlideCharacter")
                {
                    return false;
                }

                SlideCharacter ch = entity as SlideCharacter;

                switch (targetFilter)
                {
                    case TargetFilter.Enemy:
                        if (ch.Team == character.Team) return false;
                        break;
                    case TargetFilter.Freindly:
                        if (ch.Team != character.Team) return false;
                        break;
                    default:

                        break;
                }

                break;
            case TargetType.Tile:
                if (entity.GetEntityType() != "Tile") return false;
                break;
            case TargetType.Either:
                if (entity.GetEntityType() != "Tile" && entity.GetEntityType() != "SlideCharacter") return false;
                break;
            case TargetType.Self:
                if (entity != character) return false;
                break;
            default:
                return false;
        }

        var tile = entity.getCurrentTile();
        int xDif = Mathf.Abs(tile.X - character.currentTile.X);
        if (xDif > range)
        {
            return false;
        }
        int yDif = Mathf.Abs(tile.Y - character.currentTile.Y);
        if (yDif > range)
        {
            return false;
        }
        int total = xDif + yDif;
        if (targetRange == TargetRange.Melee)
        {
            if (total > 2)
            {
                return false;
            }
        }
        else
        {
            if (total > (range * 2))
            {
                return false;
            }
        }
        return true;
    }