示例#1
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);
        }
    }
示例#2
0
    /// <summary>Adds character spawn to the given tile.</summary>
    /// <param name="tile">Tile that the character will be spawned at.</param>
    public void AddCharacterSpawn(EditorTile tile)
    {
        bool isWall = false;

        if (tile.IsOccuppied())
        {
            if (tile.GridObject.IsUnit())
            {
                UnitType type = ((EditorUnit)tile.GridObject).Type;
                if (type == editorParams.unit)
                {
                    return;
                }
            }
            else
            {
                isWall = ((EditorLevelObject)tile.GridObject).Type == ObjectType.Wall;
            }
        }

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

            EditorUnit character = new EditorUnit(editorParams.unit, tile);
            tile.AddGridObject(character);

            switch (editorParams.unit)
            {
            case UnitType.Player:
            {
                if (player != null)
                {
                    player.Tile.RemoveGridObject();
                }
                player = character;
                break;
            }

            case UnitType.DecoyBot:
            {
                if (decoyBotSpawns == null)
                {
                    decoyBotSpawns = new List <EditorUnit>();
                }
                decoyBotSpawns.Add(character);
                break;
            }

            default:
            {
                if (enemySpawns == null)
                {
                    enemySpawns = new List <EditorUnit>();
                }
                enemySpawns.Add(character);
                break;
            }
            }
        }
    }