예제 #1
0
    public override void Spread()
    {
        Queue <Vector2Int> openSet   = new Queue <Vector2Int>();
        List <Vector2Int>  closedSet = new List <Vector2Int>();

        openSet.Enqueue(gridPos);

        Direction  wireDirection;
        Vector2Int currPos;

        while (openSet.Count > 0)
        {
            currPos       = openSet.Dequeue();
            wireDirection = SlotGrid.GetWireDirection(currPos.x, currPos.y);
            closedSet.Add(currPos);

            foreach (Vector2Int position in GetConnectedSlotPositions(currPos, wireDirection))
            {
                if (!closedSet.Contains(position))
                {
                    openSet.Enqueue(position);
                }
            }
        }

        foreach (Vector2Int position in closedSet)
        {
            EnergyTrail newTrail = new EnergyTrail(position, energyType, Direction.None, this);
            trails.Add(newTrail);
        }

        SlotGrid.AddEnergyTrails(trails);
    }
예제 #2
0
    public override void Spread()
    {
        int moveX = 0;
        int moveY = 0;

        if (spreadDirection == Direction.Right)
        {
            moveX = 1;
        }
        else if (spreadDirection == Direction.Left)
        {
            moveX = -1;
        }
        else if (spreadDirection == Direction.Down)
        {
            moveY = 1;
        }
        else if (spreadDirection == Direction.Up)
        {
            moveY = -1;
        }

        Vector2Int trailPos = new Vector2Int(gridPos.x, gridPos.y);

        do
        {
            trailPos.x += moveX;
            trailPos.y += moveY;

            EnergyTrail trail = new EnergyTrail(trailPos, EnType.Laser, spreadDirection, this);
            trails.Add(trail);
        } while (!SlotGrid.IsSlotOccupied(trailPos.x, trailPos.y));

        SlotGrid.AddEnergyTrails(trails);
    }
예제 #3
0
    public void MoveStartPos()
    {
        Vector2Int newGridPosStart = gridPosStart + movement;

        if (!SlotGrid.IsSlotOccupied(newGridPosStart.x, newGridPosStart.y))
        {
            EnergyTrail trail = new EnergyTrail(newGridPosStart, creator.energyType, CalculateDirection(gridPosStart, newGridPosStart), creator);
            path.Enqueue(trail);
            SlotGrid.AddEnergyTrail(trail);
            gridPosStart.Set(newGridPosStart.x, newGridPosStart.y);
        }
    }
예제 #4
0
    public void MoveEndPos(ref bool vanished)
    {
        Vector2Int newGridPosEnd = gridPosEnd + movement;

        EnergyTrail s = path.Dequeue();

        SlotGrid.RemoveEnergyTrail(s);

        if (gridPosStart == newGridPosEnd)
        {
            vanished = true;
            return;
        }

        gridPosEnd = newGridPosEnd;
    }
예제 #5
0
파일: Heat.cs 프로젝트: ALOGame/Elpac
    public override void Spread()
    {
        List <EnergyTrail> trails = new List <EnergyTrail>();

        int xPos, yPos;

        for (int i = -power; i <= power; i++)
        {
            for (int j = -power; j <= power; j++)
            {
                xPos = gridPos.x + i;
                yPos = gridPos.y + j;
                if (SlotGrid.PositionInsideGrid(xPos, yPos))
                {
                    EnergyTrail trail = new EnergyTrail(new Vector2Int(xPos, yPos), EnType.Heat, Direction.None, this);
                    this.trails.Add(trail);
                    trails.Add(trail);
                }
            }
        }

        SlotGrid.AddEnergyTrails(trails);
    }
예제 #6
0
 public void RemoveEnergyTrail(EnergyTrail trail)
 {
     energyTrails.Remove(trail);
 }
예제 #7
0
 public void AddEnergyTrail(EnergyTrail trail)
 {
     energyTrails.Add(trail);
 }
예제 #8
0
 public static void RemoveEnergyTrail(EnergyTrail trail)
 {
     instance.slots[trail.gridPos.x, trail.gridPos.y].RemoveEnergyTrail(trail);
     instance.slots[trail.gridPos.x, trail.gridPos.y].UpdateItems(trail.energy);
 }