Beispiel #1
0
 void UpdateBeam(int index)
 {
     if (beamsOn[index])
     {
         if (beams[index] == null)
         {
             beams[index] = ObjectPools.Spawn <BeamDevice>(BEAM_POOL, BeamAttach.position, BeamAttach);
             beams[index].SetTile(TileX, TileY);
             beams[index].SetDirectionAndLayer(
                 (index == 0) ? 1 : ((index == 1) ? -1 : 0),
                 (index == 2) ? -1 : ((index == 3) ? 1 : 0),
                 beamLayerOffsets[index]
                 );
         }
         else
         {
             beams[index].Tick();
         }
     }
     else if (beams[index] != null)
     {
         ObjectPools.Despawn(beams[index]);
         beams[index] = null;
     }
 }
Beispiel #2
0
    public bool ApplyTool(string toolName, int x, int y)
    {
        if (GameState.Mode != GameMode.Playing)
        {
            return(false);
        }

        if (toolName == GameState.EDITOR_DELETE)
        {
            if (GameState.Devices[y, x] != null && GameState.Devices[y, x].CanDelete)
            {
                GameState.Parts[GameState.Devices[y, x].PartName]++;
                ObjectPools.Despawn(GameState.Devices[y, x]);
                GameState.Devices[y, x] = null;
                ToolPanel.Current.Refresh();
                SoundBoard.Play(SOUND_DELETE);
                return(true);
            }
        }
        else if (toolName != null)
        {
            if (GameState.Devices[y, x] == null && GameState.Parts.ContainsKey(toolName) && GameState.Parts[toolName] > 0)
            {
                CreateDevice(toolName, x, y);
                GameState.Devices[y, x].PartName = toolName;
                GameState.Parts[toolName]--;
                ToolPanel.Current.Refresh();
                SoundBoard.Play(SOUND_ADD);
                return(true);
            }
        }

        return(false);
    }
Beispiel #3
0
 void ClearSprites()
 {
     foreach (var key in sprites.Keys)
     {
         while (sprites[key].Count > 0)
         {
             ObjectPools.Despawn(sprites[key][0].gameObject);
             sprites[key].RemoveAt(0);
         }
     }
 }
    public void ClearBlock(int row, int col)
    {
        if (Blocks[row, col] == null)
        {
            return;
        }

        Blocks[row, col].Despawn();
        ObjectPools.Despawn(Blocks[row, col].gameObject);
        Blocks[row, col] = null;
    }
Beispiel #5
0
 public override void Disable()
 {
     base.Disable();
     for (int i = 0; i < beams.Length; i++)
     {
         beamsOn[i] = false;
         if (beams[i] != null)
         {
             ObjectPools.Despawn(beams[i]);
             beams[i] = null;
         }
     }
 }
Beispiel #6
0
 void ClearOldLevel()
 {
     if (GameState.Tiles != null)
     {
         int height = GameState.Tiles.GetLength(0);
         int width  = GameState.Tiles.GetLength(1);
         for (int y = 0; y < height; y++)
         {
             for (int x = 0; x < width; x++)
             {
                 if (GameState.Tiles[y, x] != null)
                 {
                     ObjectPools.Despawn(GameState.Tiles[y, x]);
                     GameState.Tiles[y, x] = null;
                 }
                 if (GameState.Devices[y, x] != null)
                 {
                     ObjectPools.Despawn(GameState.Devices[y, x]);
                     GameState.Devices[y, x] = null;
                 }
             }
         }
     }
 }