Example #1
0
        public void SetChildScene(SceneID parent, SceneID id, bool enabled)
        {
            SceneData data = Save.Find(id);

            if (data != null)
            {
                if (string.IsNullOrEmpty(id.Name))
                {
                    data.WriteFloat(0, enabled ? 100f : 0f);
                    data[4] = 1;
                }
                else if (id.Name.IndexOf("Activator") >= 0)
                {
                    data[0] = (byte)(enabled ? 1 : 0);
                }
                else if (id.Name.IndexOf("Deactivate") >= 0)
                {
                    data[0] = (byte)(enabled ? 0 : 1);
                }
                else if (id.Name.IndexOf("Animator") >= 0)
                {
                    data.WriteFloat(1, enabled ? 100f : 0f);
                }
            }
            else if (!enabled)
            {
                SceneCollection collection = Save.Insert(parent);
                data = collection.Add(id);

                if (string.IsNullOrEmpty(id.Name))
                {
                    data.Data = new byte[6];
                    data[4]   = 1;
                }
                else if (id.Name.IndexOf("Activator") >= 0)
                {
                    data.Data = new byte[1];
                }
                else if (id.Name.IndexOf("Deactivate") >= 0)
                {
                    data.Data = new byte[1];
                    data[0]   = 1;
                }
                else if (id.Name.IndexOf("Animator") >= 0)
                {
                    data.Data = new byte[5];
                }
            }
        }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try {
                SceneData data = Save.Master[MasterAssets.SeinLevel];
                data.WriteInt((int)LevelInfo.CurrentLevel, int.Parse(txtLvl.Text));
                data.WriteInt((int)LevelInfo.Experience, int.Parse(txtXP.Text));
                data.WriteInt((int)LevelInfo.AbilityPoints, int.Parse(txtAP.Text));

                data = Save.Master[MasterAssets.SeinEnergyInfo];
                data.WriteFloat((int)SeinEnergy.Current, float.Parse(txtEN.Text));
                data.WriteFloat((int)SeinEnergy.Max, int.Parse(txtENMax.Text));
                Save.Energy    = (int)float.Parse(txtEN.Text);
                Save.MaxEnergy = int.Parse(txtENMax.Text);

                data = Save.Master[MasterAssets.SeinHealthInfo];
                data.WriteFloat((int)SeinHealthController.Amount, float.Parse(txtHP.Text) * 4f);
                data.WriteInt((int)SeinHealthController.MaxHealth, int.Parse(txtHPMax.Text) * 4);
                Save.Health    = (int)float.Parse(txtHP.Text);
                Save.MaxHealth = int.Parse(txtHPMax.Text);

                data = Save.Master[MasterAssets.PlatformMovement];
                IntFloat trueValue = default(IntFloat);
                trueValue.FloatVal = float.Parse(txtPosX.Text);
                data.WriteInt((int)SaveInfo.PosX, trueValue.IntVal);
                trueValue.FloatVal = float.Parse(txtPosY.Text);
                data.WriteInt((int)SaveInfo.PosY, trueValue.IntVal);
                trueValue.FloatVal = float.Parse(txtVelocityX.Text);
                data.WriteInt((int)SaveInfo.SpeedX, trueValue.IntVal);
                trueValue.FloatVal = float.Parse(txtVelocityY.Text);
                data.WriteInt((int)SaveInfo.SpeedY, trueValue.IntVal);

                data = Save.Master[MasterAssets.ScenesManager];
                trueValue.FloatVal = float.Parse(txtPosX.Text);
                data.WriteInt(0, trueValue.IntVal);
                trueValue.FloatVal = float.Parse(txtPosY.Text);
                data.WriteInt(4, trueValue.IntVal);

                //data = Save.Find(MasterAssets.BashTimeLine);
                //data.WriteFloat(1, 8.416667f);

                data = Save.Master[MasterAssets.PlayerAbilities];
                data[(int)Abilities.AbilityMarkers] = (byte)(chkAbilityMarkers.Checked ? 1 : 0);
                data[(int)Abilities.AirDash]        = (byte)(chkAirDash.Checked ? 1 : 0);
                data[(int)Abilities.Bash]           = (byte)(chkBash.Checked ? 1 : 0);
                //data[(int)Abilities.BashBuff] = (byte)(chkBashBuff.Checked ? 1 : 0);
                data[(int)Abilities.ChargeDash]            = (byte)(chkChargeDash.Checked ? 1 : 0);
                data[(int)Abilities.ChargeFlame]           = (byte)(chkChargeFlame.Checked ? 1 : 0);
                data[(int)Abilities.ChargeFlameBlast]      = (byte)(chkChargeFlameBlast.Checked ? 1 : 0);
                data[(int)Abilities.ChargeFlameBurn]       = (byte)(chkChargeFlameBurn.Checked ? 1 : 0);
                data[(int)Abilities.ChargeFlameEfficiency] = (byte)(chkChargeFlameEfficiency.Checked ? 1 : 0);
                data[(int)Abilities.ChargeJump]            = (byte)(chkChargeJump.Checked ? 1 : 0);
                data[(int)Abilities.CinderFlame]           = (byte)(chkCinderFlame.Checked ? 1 : 0);
                data[(int)Abilities.Climb]            = (byte)(chkClimb.Checked ? 1 : 0);
                data[(int)Abilities.Dash]             = (byte)(chkDash.Checked ? 1 : 0);
                data[(int)Abilities.DoubleJump]       = (byte)(chkDoubleJump.Checked ? 1 : 0);
                data[(int)Abilities.EnergyEfficiency] = (byte)(chkEnergyEfficiency.Checked ? 1 : 0);
                data[(int)Abilities.EnergyMarkers]    = (byte)(chkEnergyMarkers.Checked ? 1 : 0);
                data[(int)Abilities.Glide]            = (byte)(chkGlide.Checked ? 1 : 0);
                data[(int)Abilities.Grenade]          = (byte)(chkGrenade.Checked ? 1 : 0);
                //data[(int)Abilities.GrenadeEfficency] = (byte)(chkGrenadeEfficiency.Checked ? 1 : 0);
                data[(int)Abilities.HealthEfficiency]    = (byte)(chkLifeEfficiency.Checked ? 1 : 0);
                data[(int)Abilities.HealthMarkers]       = (byte)(chkLifeMarkers.Checked ? 1 : 0);
                data[(int)Abilities.Magnet]              = (byte)(chkMagnet.Checked ? 1 : 0);
                data[(int)Abilities.MapMarkers]          = (byte)(chkMapMarkers.Checked ? 1 : 0);
                data[(int)Abilities.QuickFlame]          = (byte)(chkQuickFlame.Checked ? 1 : 0);
                data[(int)Abilities.RapidFire]           = (byte)(chkRapidFlame.Checked ? 1 : 0);
                data[(int)Abilities.Regroup]             = (byte)(chkRegroup.Checked ? 1 : 0);
                data[(int)Abilities.Rekindle]            = (byte)(chkRekindle.Checked ? 1 : 0);
                data[(int)Abilities.Sense]               = (byte)(chkSense.Checked ? 1 : 0);
                data[(int)Abilities.SoulEfficiency]      = (byte)(chkSpiritEfficiency.Checked ? 1 : 0);
                data[(int)Abilities.SparkFlame]          = (byte)(chkSparkFlame.Checked ? 1 : 0);
                data[(int)Abilities.SoulFlameEfficiency] = (byte)(chkSoulLinkEfficiency.Checked ? 1 : 0);
                data[(int)Abilities.SpiritFlame]         = (byte)(chkSpiritFlame.Checked ? 1 : 0);
                data[(int)Abilities.SplitFlameUpgrade]   = (byte)(chkSplitFlame.Checked ? 1 : 0);
                data[(int)Abilities.Stomp]               = (byte)(chkStomp.Checked ? 1 : 0);
                data[(int)Abilities.DoubleJumpUpgrade]   = (byte)(chkTripleJump.Checked ? 1 : 0);
                data[(int)Abilities.UltraDefense]        = (byte)(chkUltraDefense.Checked ? 1 : 0);
                data[(int)Abilities.GrenadeUpgrade]      = (byte)(chkUltraLightBurst.Checked ? 1 : 0);
                data[(int)Abilities.UltraMagnet]         = (byte)(chkUltraMagnet.Checked ? 1 : 0);
                data[(int)Abilities.UltraSoulFlame]      = (byte)(chkUltraSoulLink.Checked ? 1 : 0);
                data[(int)Abilities.UltraSplitFlame]     = (byte)(chkUltraSplitFlame.Checked ? 1 : 0);
                data[(int)Abilities.StompUpgrade]        = (byte)(chkUltraStomp.Checked ? 1 : 0);
                data[(int)Abilities.WallJump]            = (byte)(chkWallJump.Checked ? 1 : 0);
                data[(int)Abilities.WaterBreath]         = (byte)(chkWaterBreath.Checked ? 1 : 0);

                int pointsUsed = (chkQuickFlame.Checked ? 1 : 0) + (chkSparkFlame.Checked ? 1 : 0) + (chkChargeFlameBurn.Checked ? 1 : 0) + (chkSplitFlame.Checked ? 1 : 0) +
                                 (chkUltraLightBurst.Checked ? 2 : 0) + (chkCinderFlame.Checked ? 2 : 0) + (chkUltraStomp.Checked ? 2 : 0) + (chkRapidFlame.Checked ? 2 : 0) +
                                 (chkChargeFlameBlast.Checked ? 3 : 0) + (chkUltraSplitFlame.Checked ? 3 : 0) + (chkMagnet.Checked ? 1 : 0) + (chkMapMarkers.Checked ? 1 : 0) +
                                 (chkLifeEfficiency.Checked ? 1 : 0) + (chkUltraMagnet.Checked ? 1 : 0) + (chkEnergyEfficiency.Checked ? 2 : 0) + (chkAbilityMarkers.Checked ? 2 : 0) +
                                 (chkSpiritEfficiency.Checked ? 2 : 0) + (chkLifeMarkers.Checked ? 2 : 0) + (chkEnergyMarkers.Checked ? 2 : 0) + (chkSense.Checked ? 3 : 0) +
                                 (chkRekindle.Checked ? 1 : 0) + (chkRegroup.Checked ? 1 : 0) + (chkChargeFlameEfficiency.Checked ? 1 : 0) + (chkAirDash.Checked ? 2 : 0) +
                                 (chkUltraSoulLink.Checked ? 2 : 0) + (chkChargeDash.Checked ? 2 : 0) + (chkWaterBreath.Checked ? 2 : 0) + (chkSoulLinkEfficiency.Checked ? 2 : 0) +
                                 (chkTripleJump.Checked ? 3 : 0) + (chkUltraDefense.Checked ? 3 : 0);
                data = Save.Master[MasterAssets.SeinInventory];
                data.WriteInt((int)InventoryInfo.Keystones, int.Parse(txtKeystones.Text));
                data.WriteInt((int)InventoryInfo.Mapstones, int.Parse(txtMapstones.Text));
                data.WriteInt((int)InventoryInfo.SkillpointsPickedUp, pointsUsed - int.Parse(txtLvl.Text) + int.Parse(txtAP.Text));

                data = Save.Master[MasterAssets.SeinSoulFlame];
                bool hasSoulFlame = !string.IsNullOrEmpty(txtSoulX.Text);
                if (hasSoulFlame)
                {
                    if (data.Data.Length <= 31)
                    {
                        byte[] newData = new byte[43];
                        Array.Copy(data.Data, newData, 31);
                        data.Data = newData;
                    }
                    data[(int)SoulFlameInfo.HasSoulFlame] = 1;

                    trueValue.FloatVal = float.Parse(txtSoulX.Text);
                    data.WriteInt((int)SoulFlameInfo.SoulX, trueValue.IntVal);
                    trueValue.FloatVal = float.Parse(txtSoulY.Text);
                    data.WriteInt((int)SoulFlameInfo.SoulY, trueValue.IntVal);
                }
                else
                {
                    if (data.Data.Length > 31)
                    {
                        byte[] newData = new byte[31];
                        Array.Copy(data.Data, newData, 31);
                        data.Data = newData;
                    }
                    data[(int)SoulFlameInfo.HasSoulFlame] = 0;
                }

                data = Save.Master[MasterAssets.SeinDeathCounter];
                int deaths = int.Parse(txtDeaths.Text);
                data.WriteInt(0, deaths);
                if (Save.Difficulty == DifficultyMode.OneLife)
                {
                    Save.WasKilled = deaths > 0;
                }

                string currentArea = string.Empty;
                switch (cboArea.Text)
                {
                case "Ginso": currentArea = "ginsoTree"; break;

                case "Glades": currentArea = "sunkenGlades"; break;

                case "Grove": currentArea = "hollowGrove"; break;

                case "Grotto": currentArea = "moonGrotto"; break;

                case "Swamp": currentArea = "thornfeltSwamp"; break;

                case "Blackroot": currentArea = "mangrove"; break;

                case "Misty": currentArea = "mistyWoods"; break;

                case "Sorrow": currentArea = "sorrowPass"; break;

                case "Forlorn": currentArea = "forlornRuins"; break;

                case "Horu": currentArea = "mountHoru"; break;

                case "Valley": currentArea = "valleyOfTheWind"; break;
                }
                if (!string.IsNullOrEmpty(currentArea))
                {
                    Save.AreaName = currentArea;
                }

                float totalSeconds = float.Parse(txtTime.Text);
                int   totalSecs    = (int)totalSeconds;
                Save.Hours   = totalSecs / 3600;
                Save.Minutes = (totalSecs - Save.Hours * 3600) / 60;
                Save.Seconds = (totalSecs - Save.Hours * 3600 - Save.Minutes * 60);

                data = Save.Master[MasterAssets.GameTimer];
                data.WriteFloat(0, totalSeconds);

                Save.DebugOn = true;

                data = Save.Master[MasterAssets.SavePedestals];
                data[(int)Pedestals.BlackRoot]    = (byte)(chkBlackRoot.Checked ? 1 : 0);
                data[(int)Pedestals.Forlorn]      = (byte)(chkForlornRuins.Checked ? 1 : 0);
                data[(int)Pedestals.GinsoTree]    = (byte)(chkGinso.Checked ? 1 : 0);
                data[(int)Pedestals.Grotto]       = (byte)(chkGrotto.Checked ? 1 : 0);
                data[(int)Pedestals.HollowGrove]  = (byte)(chkHollowGrove.Checked ? 1 : 0);
                data[(int)Pedestals.HoruFields]   = (byte)(chkHoruFields.Checked ? 1 : 0);
                data[(int)Pedestals.LostGrove]    = (byte)(chkLostGrove.Checked ? 1 : 0);
                data[(int)Pedestals.MountHoru]    = (byte)(chkMountHoru.Checked ? 1 : 0);
                data[(int)Pedestals.SorrowPass]   = (byte)(chkSorrowPass.Checked ? 1 : 0);
                data[(int)Pedestals.SunkenGlades] = (byte)(chkSunkenGlades.Checked ? 1 : 0);
                data[(int)Pedestals.Swamp]        = (byte)(chkSwamp.Checked ? 1 : 0);
                data[(int)Pedestals.Valley]       = (byte)(chkValleyOfTheWind.Checked ? 1 : 0);

                data = Save.Master[MasterAssets.WorldEvents];
                data[(int)WorldEvents.CleanWater]        = (byte)(chkCleanWater.Checked ? 1 : 0);
                data[(int)WorldEvents.DarknessLifted]    = (byte)(chkDarknessLifted.Checked ? 1 : 0);
                data[(int)WorldEvents.ForlornRuinsKey]   = (byte)(chkForlornKey.Checked ? 1 : 0);
                data[(int)WorldEvents.GinsoTreeEntered]  = (byte)(chkGinsoEntered.Checked ? 1 : 0);
                data[(int)WorldEvents.GinsoTreeKey]      = (byte)(chkGinsoKey.Checked ? 1 : 0);
                data[(int)WorldEvents.GravityActivated]  = (byte)(chkGravityActivated.Checked ? 1 : 0);
                data[(int)WorldEvents.GumoFree]          = (byte)(chkGumoFree.Checked ? 1 : 0);
                data[(int)WorldEvents.MistLifted]        = (byte)(chkMistLifted.Checked ? 1 : 0);
                data[(int)WorldEvents.MountHoruKey]      = (byte)(chkHoruKey.Checked ? 1 : 0);
                data[(int)WorldEvents.SpiritTreeReached] = (byte)(chkSpiritTree.Checked ? 1 : 0);
                data[(int)WorldEvents.WarmthReturned]    = (byte)(chkWarmth.Checked ? 1 : 0);
                data[(int)WorldEvents.WindRestored]      = (byte)(chkWindRestored.Checked ? 1 : 0);

                for (int j = 0; j < modifiedNodes.Count; j++)
                {
                    TreeNode child      = modifiedNodes[j];
                    SceneID  sceneValue = (SceneID)child.Tag;
                    string   fieldName  = child.Text;

                    data = Save.Find(sceneValue);
                    bool enableDisable = !child.Checked;

                    if (data != null)
                    {
                        if (fieldName.IndexOf("Animator") >= 0)
                        {
                            data.WriteFloat(0, child.Checked ? 0 : 100f);
                            data[4] = 1;
                        }
                        else if (fieldName.IndexOf("Trigger") >= 0 || fieldName.IndexOf("Restrict") >= 0)
                        {
                            data[0] = (byte)(child.Checked ? 1 : 0);
                        }
                        else if (fieldName.IndexOf("Torch") >= 0)
                        {
                            data[0] = (byte)(child.Checked ? 0 : 1);
                        }
                        else if (fieldName.IndexOf("Lever") >= 0)
                        {
                            data.Data = new byte[4];
                            data.WriteInt(0, (int)(fieldName.IndexOf("GoesLeft") >= 0 ? (child.Checked ? LeverDirections.Right : LeverDirections.Left) : (child.Checked ? LeverDirections.Left : LeverDirections.Right)));
                        }
                        else if (fieldName.IndexOf("Creep") >= 0 || fieldName.IndexOf("Wall") >= 0 || fieldName.IndexOf("Stompable") >= 0 || fieldName.IndexOf("Bulb") >= 0 ||
                                 fieldName.IndexOf("Bombable") >= 0 || fieldName.IndexOf("Breakable") >= 0 || fieldName.IndexOf("PetrifiedPlant") >= 0)
                        {
                            float currentHP = data.GetFloat((int)EntityDamage.Health);
                            data.WriteFloat((int)EntityDamage.Health, child.Checked ? (currentHP > 0 ? currentHP : data.GetFloat((int)EntityDamage.MaxHealth)) : -1f);
                        }
                        else if (fieldName.IndexOf("Keystone") >= 0 || fieldName.IndexOf("Mapstone") >= 0 || fieldName.IndexOf("Pickup") >= 0)
                        {
                            data[(int)Pickup.Collected] = (byte)(child.Checked ? 0 : 1);
                        }
                        else if (fieldName.IndexOf("AbilityCell") >= 0 || fieldName.IndexOf("HealthCell") >= 0 || fieldName.IndexOf("EnergyCell") >= 0 || fieldName.IndexOf("ExpOrb") >= 0)
                        {
                            data[(int)Collectible.Collected] = (byte)(child.Checked ? 0 : 1);
                        }
                        else if (fieldName.IndexOf("DoorWith") >= 0 || fieldName.IndexOf("EnergyDoor") >= 0)
                        {
                            int currentState = data.GetInt((int)Door.CurrentState);
                            data.WriteInt((int)Door.CurrentState, child.Checked ? 0 : (currentState == 0 ? 2 : currentState));
                            if (child.Checked)
                            {
                                data.WriteInt((int)Door.SlotsPending, 0);
                                data.WriteInt((int)Door.SlotsFilled, 0);
                                data.WriteInt((int)Door.AmountOfItemsUsed, 0);
                            }
                        }
                    }
                    else if (!child.Checked)
                    {
                        SceneCollection collection = Save.Insert(sceneValue.Parent);
                        data = collection.Add(sceneValue);

                        if (fieldName.IndexOf("Animator") >= 0)
                        {
                            data.Data = new byte[6];
                            data.WriteFloat(0, 100f);
                            data[4] = 1;
                        }
                        else if (fieldName.IndexOf("Trigger") >= 0 || fieldName.IndexOf("Restrict") >= 0)
                        {
                            data.Data = new byte[1];
                            data[0]   = 0;
                        }
                        else if (fieldName.IndexOf("Torch") >= 0)
                        {
                            data.Data = new byte[1];
                            data[0]   = 1;
                        }
                        else if (fieldName.IndexOf("Lever") >= 0)
                        {
                            data.Data = new byte[4];
                            data.WriteInt(0, (int)(fieldName.IndexOf("GoesLeft") >= 0 ? LeverDirections.Left : LeverDirections.Right));
                        }
                        else if (fieldName.IndexOf("Creep") >= 0 || fieldName.IndexOf("Wall") >= 0 || fieldName.IndexOf("Stompable") >= 0 || fieldName.IndexOf("Bulb") >= 0 ||
                                 fieldName.IndexOf("Bombable") >= 0 || fieldName.IndexOf("Breakable") >= 0 || fieldName.IndexOf("PetrifiedPlant") >= 0)
                        {
                            data.Data = new byte[8];

                            if (fieldName.IndexOf("PetrifiedPlant") >= 0)
                            {
                                data.WriteFloat((int)EntityDamage.Health, -1);
                                data.WriteFloat((int)EntityDamage.MaxHealth, 5);
                            }
                            else if (fieldName.IndexOf("Stompable") >= 0 || fieldName.IndexOf("Bombable") >= 0 || fieldName.IndexOf("Breakable") >= 0 || fieldName.IndexOf("Wall") >= 0)
                            {
                                data.WriteFloat((int)EntityDamage.Health, -5);
                                data.WriteFloat((int)EntityDamage.MaxHealth, 10);
                            }
                            else if (fieldName.IndexOf("Creep") >= 0 || fieldName.IndexOf("Bulb") >= 0)
                            {
                                data.WriteFloat((int)EntityDamage.Health, -1);
                                data.WriteFloat((int)EntityDamage.MaxHealth, 4);
                            }
                        }
                        else if (fieldName.IndexOf("Keystone") >= 0 || fieldName.IndexOf("Mapstone") >= 0 || fieldName.IndexOf("Pickup") >= 0)
                        {
                            data.Data = new byte[5];
                            data[(int)Pickup.Collected] = 1;
                        }
                        else if (fieldName.IndexOf("AbilityCell") >= 0 || fieldName.IndexOf("HealthCell") >= 0 || fieldName.IndexOf("EnergyCell") >= 0 || fieldName.IndexOf("ExpOrb") >= 0)
                        {
                            data.Data = new byte[1];
                            data[(int)Collectible.Collected] = 1;
                        }
                        else if (fieldName.IndexOf("DoorWith") >= 0 || fieldName.IndexOf("EnergyDoor") >= 0)
                        {
                            data.Data = new byte[16];
                            data.WriteInt((int)Door.CurrentState, 2);
                            data.WriteInt((int)Door.AmountOfItemsUsed, fieldName.IndexOf("Two") >= 0 ? 2 : 4);
                        }
                    }

                    if (sceneValue.Children != null)
                    {
                        foreach (SceneID extra in sceneValue.Children)
                        {
                            SetChildScene(sceneValue.Parent, extra, enableDisable);
                        }
                    }
                }

                Save.Save(Save.FilePath);
                this.Close();
            } catch (Exception ex) {
                MessageBox.Show(this, "Failed to save file: " + ex.ToString());
            }
        }