Exemplo n.º 1
0
    private void UpdateLevelObject()
    {
        if (IsOccuppied() && !gridObject.IsUnit())
        {
            Dictionary <ObjectType, Variant> dict = gridCreator.editorParams.objVariants;
            EditorLevelObject obj = (EditorLevelObject)gridObject;

            if (obj.Type != gridCreator.editorParams.obj)
            {
                if (dict.ContainsKey(obj.Type))
                {
                    obj.UpdateLevelObject(gridCreator.editorParams.obj);
                }
                obj.UpdateLevelObject(gridCreator.editorParams.obj);
            }
            else if (dict.ContainsKey(obj.Type) && obj.Variant != dict[obj.Type].variant)
            {
                obj.SetVariant(dict[obj.Type].variant);
            }
        }
        else
        {
            gridCreator.AddLevelHazard(this);
        }
    }
Exemplo n.º 2
0
    /// <summary>Adds hazard to the given tile.</summary>
    /// <param name="tile">Tile that the hazard will be spawned at.</param>
    public void AddLevelHazard(EditorTile tile)
    {
        if (tile.IsOccuppied() && !tile.GridObject.IsUnit())
        {
            ObjectType type = ((EditorLevelObject)tile.GridObject).Type;
            if (type == editorParams.obj)
            {
                return;
            }
        }

        if (tile.Type != TileType.UnbreakableWall)
        {
            //Grid has change and file is no longer consistant with grid
            if (currentGridFile != null)
            {
                currentGridFile = null;
            }

            int variant = 0;
            if (editorParams.objVariants.ContainsKey(editorParams.obj))
            {
                variant = editorParams.objVariants[editorParams.obj].variant;
            }

            EditorLevelObject hazard = new EditorLevelObject(editorParams.obj, tile, variant);
            tile.AddGridObject(hazard);

            if (levelObjects == null)
            {
                levelObjects = new List <EditorLevelObject>();
            }
            levelObjects.Add(hazard);
        }
    }
Exemplo n.º 3
0
 /// <summary>Removes character spawn from the grid.</summary>
 /// <param name="info">Editor character that is being removed.</param>
 public void RemoveLevelHazard(EditorLevelObject hazardObject)
 {
     if (levelObjects != null && levelObjects.Contains(hazardObject))
     {
         levelObjects.Remove(hazardObject);
     }
 }
Exemplo n.º 4
0
    /// <summary>Adds level objects to the level (only used for loading grids).</summary>
    /// <param name="levelObjectInfo">List of hazard info to be added to the grid.</param>
    public void AddLevelObjects(List <LevelObjectInfo> levelObjectInfo)
    {
        if (levelObjectInfo != null && levelObjectInfo.Count > 0)
        {
            levelObjects = new List <EditorLevelObject>();
            foreach (LevelObjectInfo info in levelObjectInfo)
            {
                if (!CheckTilePosition(info.GetPosition()))
                {
                    continue;
                }

                Vector2Int        position = info.GetPosition();
                EditorTile        tile     = grid[position.x].Get(position.y);
                ObjectType        type     = info.GetInfoType();
                EditorLevelObject hazard   = new EditorLevelObject(type, tile, info.GetVariant());

                tile.AddGridObject(hazard);
                levelObjects.Add(hazard);
            }
        }
    }