Exemple #1
0
 /// <summary>
 /// Apply the color to the path selected.
 /// </summary>
 /// <param name="boardPath">A matrix representif the new path for ennemies.</param>
 public void colorSelectedCellOnPath(BoardPath boardPath)
 {
     for (int x = boardPath.Start.x; x <= boardPath.End.x; x++)
     {
         for (int y = boardPath.Start.y; y <= boardPath.End.y; y++)
         {
             BoardCell cell = BoardManager.GetCellAt(new Vector2Int(x, y));
             Debug.Log(cell);
             if (cell != null)
             {
                 Debug.Log(cell);
                 cell.SelectCell();
             }
         }
     }
 }
Exemple #2
0
    public void ValidateStep221()
    {
        if (_selectedCell == null)
        {
            return;
        }

        _currentEnemyPath.End = _selectedCell.GetPosition();
        ResetSelectedCell();

        if (_currentEnemyPath.Start.x >= _currentEnemyPath.End.x &&
            _currentEnemyPath.Start.y >= _currentEnemyPath.End.y)
        {
            Vector2Int buf = new Vector2Int(_currentEnemyPath.Start.x, _currentEnemyPath.Start.y);
            _currentEnemyPath.Start.x = _currentEnemyPath.End.x;
            _currentEnemyPath.Start.y = _currentEnemyPath.End.y;
            _currentEnemyPath.End.x   = buf.x;
            _currentEnemyPath.End.y   = buf.y;
        }

        Debug.Log("Validating Step 221");
        BoardPath clone = (BoardPath)_currentEnemyPath.Clone();

        BoardManager.Paths.Add(clone);
        colorSelectedCellOnPath(clone);
        //BoardManager.CreateBoardEnemyPaths();

        _enemyPaths.Add(clone);

        foreach (BoardPath boardPath in BoardManager.Paths)
        {
            Debug.Log(boardPath);
        }

        Step220.SetActive(true);
        Step221.SetActive(false);
        _currentStep = 220;
    }
Exemple #3
0
    /// <summary>
    /// Use this for initialization of the level editor.
    /// </summary>
    public void Start()
    {
        // Level data
        _levelData = new JSONObject();
        _levelData.AddField("Name", "");
        _levelData.AddField("FunFact", "");

        // Board
        _levelData.AddField("Board", new JSONObject());
        _levelData["Board"].AddField("Size", new JSONObject());
        _levelData["Board"]["Size"].AddField("X", 0);
        _levelData["Board"]["Size"].AddField("Y", 0);
        _levelData["Board"].AddField("CellSize", 4);
        _levelData["Board"].AddField("CellOffset", 1);
        _levelData["Board"].AddField("SpawnPoint", new JSONObject());
        _levelData["Board"]["SpawnPoint"].AddField("X", 0);
        _levelData["Board"]["SpawnPoint"].AddField("Y", 0);
        _levelData["Board"].AddField("Paths", new JSONObject(JSONObject.Type.ARRAY));
        _levelData["Board"].AddField("EndPoint", new JSONObject());
        _levelData["Board"]["EndPoint"].AddField("X", 0);
        _levelData["Board"]["EndPoint"].AddField("Y", 0);

        // Inventory
        _levelData.AddField("Inventory", new JSONObject());
        _levelData["Inventory"].AddField("Mirrors", 0);
        _levelData["Inventory"].AddField("MirrorFilters", 0);
        _levelData["Inventory"].AddField("Prisms", 0);
        _levelData["Inventory"].AddField("Filters", 0);
        _levelData["Inventory"].AddField("StandardTurret", 0);
        _levelData["Inventory"].AddField("MissileTurret", 0);
        _levelData["Inventory"].AddField("LaserTurret", 0);
        _levelData["Inventory"].AddField("Obstacles", 0);

        // Entities
        _levelData.AddField("Entities", new JSONObject(JSONObject.Type.ARRAY));

        // Waves
        _levelData.AddField("Waves", new JSONObject(JSONObject.Type.ARRAY));

        // Info
        _levelData.AddField("Info", new JSONObject());
        _levelData["Info"].AddField("Lives", 10);
        _levelData["Info"].AddField("DefaultSpawnInterval", 5.0f);
        _levelData["Info"].AddField("DefaultHitpoints", 100);
        _levelData["Info"].AddField("DefaultSpeed", 10.0f);
        _levelData["Info"].AddField("DefaultColor", "white");
        _levelData["Info"].AddField("SpawnInterval", 5);

        // Private variables initialization
        _currentStep = 10;

        Step10.SetActive(true);
        _enemyPaths       = new List <BoardPath>();
        _currentEnemyPath = new BoardPath(0, 0, 0, 0);
        _currentWave      = new JSONObject();
        _currentWave.AddField("Enemies", new JSONObject(JSONObject.Type.ARRAY));
        _waves           = new JSONObject(JSONObject.Type.ARRAY);
        _colorOptions    = new RayColor[8];
        _colorOptions[0] = RayColor.NONE;
        _colorOptions[1] = RayColor.WHITE;
        _colorOptions[2] = RayColor.BLUE;
        _colorOptions[3] = RayColor.GREEN;
        _colorOptions[4] = RayColor.RED;
        _colorOptions[5] = RayColor.YELLOW;
        _colorOptions[6] = RayColor.CYAN;
        _colorOptions[7] = RayColor.MAGENTA;

        UpdateBoardHeight();
        UpdateBoardWidth();
        UpdateLives();
        UpdateDefaultSpawnInterval();
        UpdateDefaultHitpoints();
        UpdateDefaultSpeed();
        UpdateMirror();
        UpdatePrism();
        UpdateFilterMirror();
        UpdateStandardTurret();
        UpdateMissileTurret();
        UpdateLaserTurret();
        UpdateObstacle();
    }