Пример #1
0
        /* Load prop data */
        public static bool LoadData()
        {
            if (!File.Exists(FilePaths.PathToPropSaveFile))
            {
                return(false);
            }
            propData.Clear();
            BinaryReader reader     = new BinaryReader(File.OpenRead(FilePaths.PathToPropSaveFile));
            int          versionNum = reader.ReadInt32();

            if (versionNum != CURRENT_VERSION)
            {
                reader.Close();
                return(false);
            }
            int typeCount = reader.ReadInt32();

            for (int i = 0; i < typeCount; i++)
            {
                PropData thisData = new PropData();
                thisData.propID     = reader.ReadInt32();
                thisData.propName   = reader.ReadString();
                thisData.propDesc   = reader.ReadString();
                thisData.isWaypoint = reader.ReadBoolean();
                if (thisData.isWaypoint)
                {
                    thisData.waypointFor  = reader.ReadInt16();
                    thisData.waypointType = reader.ReadInt16();
                }
                thisData.isEventSpawn = reader.ReadBoolean();
                if (thisData.isEventSpawn)
                {
                    thisData.eventType = reader.ReadString();
                }
                thisData.isPOI = reader.ReadBoolean();
                if (thisData.isPOI)
                {
                    thisData.poiType      = reader.ReadInt16();
                    thisData.poiGoonCount = reader.ReadInt32();
                }
                thisData.isInside            = reader.ReadBoolean();
                thisData.makesTileUnpathable = reader.ReadBoolean();
                thisData.hideInEditor        = reader.ReadBoolean();
                thisData.zBias = reader.ReadInt16();
                propData.Add(thisData);
            }
            reader.Close();
            return(true);
        }
Пример #2
0
        /* On editor launch */
        public PropEditor(int _propIndex)
        {
            InitializeComponent();

            for (int i = 0; i < PropParams.waypointTypes.Length; i++)
            {
                waypointFor.Items.Add(PropParams.waypointTypes[i]);
            }
            for (int i = 0; i < PropParams.poiTypes.Length; i++)
            {
                poiType.Items.Add(PropParams.poiTypes[i]);
            }

            //If in editor, setup pre-existing data
            if (_propIndex == -1)
            {
                return;
            }
            thisProp  = PropFileInterface.GetData()[_propIndex];
            propIndex = _propIndex;

            propName.Text      = thisProp.propName;
            propDesc.Text      = thisProp.propDesc;
            isWaypoint.Checked = thisProp.isWaypoint;
            WaypointCheckChange();
            isStartPoint.Checked       = (thisProp.waypointType == 0);
            isMidPoint.Checked         = (thisProp.waypointType == 1);
            isEndPoint.Checked         = (thisProp.waypointType == 2);
            waypointFor.SelectedIndex  = thisProp.waypointFor;
            isEvent.Checked            = thisProp.isEventSpawn;
            eventScriptName.Text       = thisProp.eventType;
            isPOI.Checked              = thisProp.isPOI;
            poiType.SelectedIndex      = thisProp.poiType;
            poiGoonCount.Value         = thisProp.poiGoonCount;
            useageInterior.Checked     = thisProp.isInside;
            useageExterior.Checked     = !thisProp.isInside;
            makeTileUnpathable.Checked = thisProp.makesTileUnpathable;
            hideInEditor.Checked       = thisProp.hideInEditor;
            zBias.Value = thisProp.zBias;

            string formattedPropName = propName.Text.Trim().ToUpper().Replace(' ', '_');

            propSprites.Front = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityPropResources + formattedPropName + "/FRONT_FACING.png";
            LoadSavedSprite(tilePreviewFrontFacing, propSprites.Front);
            frontSpriteInUse.Checked = !(tilePreviewFrontFacing.Image == null);
            propSprites.Left         = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityPropResources + formattedPropName + "/LEFT_FACING.png";
            LoadSavedSprite(tilePreviewLeftFacing, propSprites.Left);
            leftSpriteInUse.Checked = !(tilePreviewLeftFacing.Image == null);
            propSprites.Right       = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityPropResources + formattedPropName + "/RIGHT_FACING.png";
            LoadSavedSprite(tilePreviewRightFacing, propSprites.Right);
            rightSpriteInUse.Checked = !(tilePreviewRightFacing.Image == null);
            propSprites.Back         = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityPropResources + formattedPropName + "/BACK_FACING.png";
            LoadSavedSprite(tilePreviewBackFacing, propSprites.Back);
            backSpriteInUse.Checked = !(tilePreviewBackFacing.Image == null);
            propSprites.EditorUI    = Environment.CurrentDirectory + "/" + FilePaths.PathToUnityPropResources + formattedPropName + "/EDITOR_UI.png";
            LoadSavedSprite(tilePreviewIconUI, propSprites.EditorUI);

            if (frontSpriteInUse.Checked)
            {
                NESW_CalculateFromSprite(tilePreviewFrontFacing, frontNorthCoverage, frontEastCoverage, frontSouthCoverage, frontWestCoverage, true, "FRONT_FACING");
            }
            if (leftSpriteInUse.Checked)
            {
                NESW_CalculateFromSprite(tilePreviewLeftFacing, leftNorthCoverage, leftEastCoverage, leftSouthCoverage, leftWestCoverage, true, "LEFT_FACING");
            }
            if (backSpriteInUse.Checked)
            {
                NESW_CalculateFromSprite(tilePreviewBackFacing, backNorthCoverage, backEastCoverage, backSouthCoverage, backWestCoverage, true, "BACK_FACING");
            }
            if (rightSpriteInUse.Checked)
            {
                NESW_CalculateFromSprite(tilePreviewRightFacing, rightNorthCoverage, rightEastCoverage, rightSouthCoverage, rightWestCoverage, true, "RIGHT_FACING");
            }

            propName.ReadOnly = true;
        }