Example #1
0
    public Immovable PlaceImmovable(string objectType, Tile t)
    {
        if (immovablesPrototypes.ContainsKey(objectType) == false)
        {
            Debug.LogError("immovablesPrototypes doesnt contain an prototype for key " + objectType);
            return(null);
        }

        Immovable imvb = Immovable.PlaceInstance(immovablesPrototypes [objectType], t);

        if (imvb == null)
        {
            // Failed to place object -- most likely there was already something there.
            return(null);
        }

        immovables.Add(imvb);
        //in this stage, an immovable already exists in the tile, but it not yet assigned a visual gameobject
        if (cbImmovableCreated != null)
        {
            cbImmovableCreated(imvb);
            InvalidateTileGraph();

            // removing the path of all zombies, making them recalculate the path.
            foreach (Zombie zom in zombies)
            {
                zom.pathAStar = null;
            }
        }

        return(imvb);
    }