public void MovePlayer(int from, int to, float counter = 0.25f)
    {
        tilePos = to;
        xPos    = tilePos % 40;
        yPos    = tilePos / 40;

        Player.name = "Player" + to.ToString();

        AnimaUnit animaUnit = new AnimaUnit();

        animaUnit.MoveUnit(Player, from, to, counter);

        Tile.passable[from] = true;
        Tile.passable[to]   = false;

        PlayerStat playerStat = new PlayerStat();

        playerStat.GainRage(-1);

        if (Artifact.titles[to] != Artifact.Title.None)
        {
            Artifact.Title title = Artifact.titles[to];

            Artifact artifact = new Artifact();
            artifact.Destroy(to);

            AbilityEffect ability = new AbilityEffect();
            ability.GainArtifact(title);
        }

        Turn.currentTurn = Turn.CurrentTurn.PlayerNeutral;
    }
Example #2
0
    public void MoveEnemy(GameObject prefab, int from, int to)
    {
        if (to != from)
        {
            enemies[to] = new EnemyUnit();

            enemies[to].tilePos = to;
            enemies[to].xPos    = to % 40;
            enemies[to].yPos    = to / 40;

            enemies[to].title    = enemies[from].title;
            enemies[to].health   = enemies[from].health;
            enemies[to].range    = enemies[from].range;
            enemies[to].damage   = enemies[from].damage;
            enemies[to].cooldown = enemies[from].cooldown;

            enemies[to].preparing  = enemies[from].preparing;
            enemies[to].cantAttack = enemies[from].cantAttack;
            enemies[to].cantMove   = enemies[from].cantMove;

            enemies[to].boss           = enemies[from].boss;
            enemies[to].keyKeeper      = enemies[from].keyKeeper;
            enemies[to].artifactKeeper = enemies[from].artifactKeeper;


            GameObject.Find("Enemy" + from.ToString()).name = "Enemy" + to.ToString();

            occupied[from]      = false;
            Tile.passable[from] = true;
            Tile.passable[to]   = false;
            occupied[to]        = true;
            enemies[from]       = null;
        }

        AnimaUnit animaUnit = new AnimaUnit();

        animaUnit.MoveUnit(prefab, from, to);
    }
    public bool MoveUnit(Unit unit)
    {
        int moveTo = unit.tile;

        if (unit.ally)
        {
            for (int i = unit.tile + 3; i <= unit.tile + (unit.speed * 3); i += 3)
            {
                if (i > 29)
                {
                    break;
                }
                Tile       tile  = new Tile();
                List <int> tiles = tile.GetInFront(i - 3, unit.ally);
                for (int j = 0; j < tiles.Count; j++)
                {
                    if (Bf.occupied[tiles[j]])
                    {
                        if (!Bf.units[tiles[j]].ally)
                        {
                            goto OutOfLoop;
                        }
                    }
                }
                if (!Bf.occupied[i])
                {
                    moveTo = i;
                }
            }
        }
        else
        {
            for (int i = unit.tile - 3; i >= unit.tile - (unit.speed * 3); i -= 3)
            {
                if (i < 0)
                {
                    break;
                }
                Tile       tile  = new Tile();
                List <int> tiles = tile.GetInFront(i + 3, unit.ally);
                for (int j = 0; j < tiles.Count; j++)
                {
                    if (Bf.occupied[tiles[j]])
                    {
                        if (Bf.units[tiles[j]].ally)
                        {
                            goto OutOfLoop;
                        }
                    }
                }
                if (!Bf.occupied[i])
                {
                    moveTo = i;
                }
            }
        }

OutOfLoop:

        if (unit.tile != moveTo)
        {
            AnimaUnit animaUnit = new AnimaUnit();
            animaUnit.MoveUnit(unit.tile, moveTo);
            Bf bf = new Bf();
            bf.Destroy(unit.tile);
            unit.tile = moveTo;
            return(true);
        }
        return(false);
    }