Example #1
0
    private static void ReadXmlObstacleDatas(XmlReader reader)
    {
        int       uniqueID;
        string    identifier;
        int       x, z;
        Direction orientation;
        CellData  cellData;

        if (reader.ReadToDescendant(PStrings.obstacleData) == true)
        {
            do
            {
                x           = int.Parse(reader.GetAttribute(PStrings.xCoordinate));
                z           = int.Parse(reader.GetAttribute(PStrings.zCoordinate));
                orientation = (Direction)int.Parse(reader.GetAttribute(PStrings.orientation));

                identifier = reader.GetAttribute(PStrings.identifier);

                uniqueID = int.Parse(reader.GetAttribute(PStrings.uniqueID));

                cellData = GetCellAt(new Coordinates(x, z));

                ObstacleData.Instantiate(GetObstaclePrototype(identifier), cellData, orientation, uniqueID);
                cellData.obstacle.ReadXml(reader);
            } while (reader.ReadToNextSibling(PStrings.obstacleData));
        }
    }
Example #2
0
    private void CreateAt(CellData cell)
    {
        if (creationMode == CreationMode.Null)
        {
            //////////////////////////////////////////////////////////////////////////////////////
            /// This should never happen but if it does nothing should be created or destroyed ///
            //////////////////////////////////////////////////////////////////////////////////////
        }
        else if (creationMode == CreationMode.Foundation)
        {
            if (inputMode == InputMode.Null)
            {
                //////////////////////////////////////////////////////////////////////////////////////
                /// This should never happen but if it does nothing should be created or destroyed ///
                //////////////////////////////////////////////////////////////////////////////////////
            }
            else if (inputMode == InputMode.Constructive)
            {
                if (activeFoundation.Validation(cell) == false)
                {
                    return;
                }

                if (editMesh == true)
                {
                    GridData.InstantiateFoundation(activeFoundation, cell);
                }
                if (editMaterial == true)
                {
                    cell.foundation.materialIndex = activeMegaMaterial;
                }
                if (editColor == true)
                {
                    cell.foundation.colorIndex = activeColor;
                }
                if (editElevation == true)
                {
                    cell.elevation = activeElevation;
                }

                string activeID = cell.foundation.instructionSetID;

                if (activeID == PStrings.pit || activeID == PStrings.pitGrate)
                {
                    cell.foundation.effectColorIndex = (int)ColI.Red;
                }
                else if (activeID == PStrings.pool || activeID == PStrings.poolGrate)
                {
                    cell.foundation.effectColorIndex = (int)ColI.Blue;
                }
                else if (activeID == PStrings.groundGrass)
                {
                    cell.foundation.effectColorIndex = (int)ColI.Green;
                }
            }
            else if (inputMode == InputMode.Destructive)
            {
                if (editMesh == true)
                {
                    GridData.InstantiateFoundation(defaultFoundation, cell);
                }
                if (editMaterial == true)
                {
                    cell.foundation.materialIndex = defaultMegaMaterial;
                }
                if (editColor == true)
                {
                    cell.foundation.colorIndex = defaultMegaColor;
                }
                if (editElevation == true)
                {
                    cell.elevation = defaultElevation;
                }
            }
        }
        else if (creationMode == CreationMode.Structure)
        {
            if (inputMode == InputMode.Null)
            {
                //////////////////////////////////////////////////////////////////////////////////////
                /// This should never happen but if it does nothing should be created or destroyed ///
                //////////////////////////////////////////////////////////////////////////////////////
            }
            else if (inputMode == InputMode.Constructive)
            {
                if (activeStructure.Validation(cell) == false)
                {
                    return;
                }

                if (editMesh == true)
                {
                    GridData.InstantiateStructure(activeStructure, cell);
                }
                if (editMaterial == true)
                {
                    cell.structure.materialIndex = activeMegaMaterial;
                }
                if (editColor == true)
                {
                    cell.structure.colorIndex = activeColor;
                }
                if (editElevation == true)
                {
                    cell.elevation = activeElevation;
                }
            }
            else if (inputMode == InputMode.Destructive)
            {
                if (editMesh == true)
                {
                    GridData.InstantiateStructure(null, cell);
                }
                if (editElevation == true)
                {
                    cell.elevation = defaultElevation;
                }

                if (cell.structure == null)
                {
                    return;
                }

                if (editMaterial == true)
                {
                    cell.structure.materialIndex = defaultMegaMaterial;
                }
                if (editColor == true)
                {
                    cell.structure.colorIndex = defaultMegaColor;
                }
            }
        }
        else if (creationMode == CreationMode.Ceiling)
        {
            if (inputMode == InputMode.Null)
            {
                //////////////////////////////////////////////////////////////////////////////////////
                /// This should never happen but if it does nothing should be created or destroyed ///
                //////////////////////////////////////////////////////////////////////////////////////
            }
            else if (inputMode == InputMode.Constructive)
            {
                if (activeCeiling.Validation(cell) == false)
                {
                    return;
                }

                if (editMesh == true)
                {
                    GridData.InstantiateCeiling(activeCeiling, cell);
                }
                if (editMaterial == true)
                {
                    cell.ceiling.materialIndex = activeMegaMaterial;
                }
                if (editColor == true)
                {
                    cell.ceiling.colorIndex = activeColor;
                }
                if (editElevation == true)
                {
                    cell.elevation = activeElevation;
                }
            }
            else if (inputMode == InputMode.Destructive)
            {
                if (editMesh == true)
                {
                    GridData.InstantiateCeiling(null, cell);
                }
                if (editElevation == true)
                {
                    cell.elevation = defaultElevation;
                }

                if (cell.ceiling == null)
                {
                    return;
                }

                if (editMaterial == true)
                {
                    cell.ceiling.materialIndex = defaultMegaMaterial;
                }
                if (editColor == true)
                {
                    cell.ceiling.colorIndex = defaultMegaColor;
                }
            }
        }
        else if (creationMode == CreationMode.Obstacle)
        {
            if (inputMode == InputMode.Null)
            {
                //////////////////////////////////////////////////////////////////////////////////////
                /// This should never happen but if it does nothing should be created or destroyed ///
                //////////////////////////////////////////////////////////////////////////////////////
            }
            else if (inputMode == InputMode.Constructive)
            {
                if (activeObstacle.Validation(cell, activeDirection) == false)
                {
                    return;
                }

                Metrics.uniqueID++;
                ObstacleData.Instantiate(activeObstacle, cell, activeDirection, Metrics.uniqueID);
            }
            else if (inputMode == InputMode.Destructive)
            {
                ObstacleData.Instantiate(null, cell, activeDirection, -1);
            }
        }
        else if (creationMode == CreationMode.Item)
        {
            if (inputMode == InputMode.Null)
            {
                //////////////////////////////////////////////////////////////////////////////////////
                /// This should never happen but if it does nothing should be created or destroyed ///
                //////////////////////////////////////////////////////////////////////////////////////
            }
            else if (inputMode == InputMode.Constructive)
            {
                if (activeItem.Validation(cell) == false)
                {
                    return;
                }

                Metrics.uniqueID++;
                ItemData.Instantiate(activeItem, cell, Metrics.uniqueID);
            }
            else if (inputMode == InputMode.Destructive)
            {
                ItemData.Instantiate(null, cell, -1);
            }
        }
        else if (creationMode == CreationMode.Entity)
        {
            if (inputMode == InputMode.Null)
            {
                //////////////////////////////////////////////////////////////////////////////////////
                /// This should never happen but if it does nothing should be created or destroyed ///
                //////////////////////////////////////////////////////////////////////////////////////
            }
            else if (inputMode == InputMode.Constructive)
            {
                if (activeEntity.Validation(cell) == false)
                {
                    return;
                }

                Metrics.uniqueID++;
                EntityData.Instantiate(activeEntity, cell, activeDirection, Metrics.uniqueID);
            }
            else if (inputMode == InputMode.Destructive)
            {
                EntityData.Instantiate(null, cell, activeDirection, -1);
            }
        }
    }