protected void Swap()
        {
            if (GlobalSave.IsFalse("control_swap"))
            {
                GlobalSave.Put("control_swap", true);
                Entity.GetComponent <DialogComponent>().Close();
            }

            var component = AtBack ? Entity.GetComponent <ActiveWeaponComponent>() : Entity.GetComponent <WeaponComponent>();

            if (!Send(new WeaponSwappedEvent {
                Who = (Player)Entity,
                Old = Item,
                Current = component.Item
            }))
            {
                // Swap the items
                var tmp = component.Item;
                component.Item = Item;
                Item           = tmp;

                if (!AtBack)
                {
                    component.Item?.PutAway();
                    Item?.TakeOut();

                    Audio.PlaySfx(Item == null ? "swap" : Item.Data.WeaponType.GetSwapSfx());
                }
                else
                {
                    Log.Error("Swap is called from not active weapon component");
                }
            }
        }
        public override bool HandleEvent(Event e)
        {
            if (e is ItemAddedEvent ev)
            {
                if (!Disabled && ev.Component == this)
                {
                    ev.Old?.Drop();
                    ev.Item?.Pickup();

                    if (ev.Item != null && ev.Old == null && AtBack)
                    {
                        if (GlobalSave.IsTrue("control_swap"))
                        {
                            Entity.GetComponent <ActiveWeaponComponent>().requestSwap = InGameState.Ready;
                        }
                        else
                        {
                            var dialog = GetComponent <DialogComponent>();

                            dialog.Dialog.Str.ClearIcons();
                            dialog.Dialog.Str.AddIcon(CommonAse.Ui.GetSlice(Controls.FindSlice(Controls.Swap, false)));

                            if (GamepadComponent.Current != null && GamepadComponent.Current.Attached)
                            {
                                dialog.Dialog.Str.AddIcon(CommonAse.Ui.GetSlice(Controls.FindSlice(Controls.Swap, true)));
                            }

                            dialog.StartAndClose("control_5", 5);
                        }
                    }
                }
            }

            return(base.HandleEvent(e));
        }
        public void RecalculatePrice()
        {
            if (Item == null)
            {
                return;
            }

            if (GlobalSave.IsTrue(Item.Id))
            {
                price = 0;
            }
            else
            {
                price = Item.Data.UnlockPrice;
                var player = LocalPlayer.Locate(Area);

                if (player != null && player.GetComponent <HatComponent>().Item?.Id == "bk:dunce_hat")
                {
                    price++;
                }

                priceString = $"{price}";
                priceWidth  = Font.Small.MeasureString(priceString).Width;
                priceX      = (Width - priceWidth - 2 - emerald.Width) / 2f;
            }
        }
            public override void Init()
            {
                base.Init();

                var bkDialog     = Self.GetComponent <DialogComponent>();
                var playerDialog = Self.Target.GetComponent <DialogComponent>();

                Start(bkDialog, "bkw_0", Self.Target, () => {
                    Start(bkDialog, "bkw_1", Self.Target, () => {
                        bkDialog.Close();

                        Start(playerDialog, "bkw_2", Self.Target, () => {
                            playerDialog.Close();

                            Start(bkDialog, "bkw_3", Self.Target, () => {
                                Become <FollowState>();
                                bkDialog.OnEnd();
                                GlobalSave.Put("bk_who", true);

                                Self.Target.GetComponent <HealthComponent>().Unhittable = false;
                            });
                        });
                    });
                });
            }
 void IAppPayResult(string result)
 {
     Debug.Log("iapppay success" + result);
     if (result == "0")
     {
         // 购买成功
         GlobalSave.SetIAppPayOrder(m_curOrder.strOder, m_curOrder.goodId, m_curOrder.productID);
         Debug.Log("varify iapp pay");
         BeginVarify();
     }
     else
     {
         if (result == "1")
         {
             FinishPay(false, PurchaseTip.TIP_VARIFYFAIL);
         }
         else if (result == "2")
         {
             FinishPay(false, PurchaseTip.TIP_PAYCANCEL);
         }
         else if (result == "3")
         {
             FinishPay(false, PurchaseTip.TIP_BUYFAIL);
         }
         else
         {
             FinishPay(false, PurchaseTip.TIP_UNKNOWERROR);
         }
     }
 }
        private Item PickItem()
        {
            var items = new List <ItemData>();

            foreach (var i in Items.Datas.Values)
            {
                if (i.Lockable && i.UnlockPrice > 0 && ApproveItem(i) && !AlreadyOnStand.Contains(i.Id) &&
                    (ShowUnlocked || GlobalSave.IsFalse(i.Id)))
                {
                    items.Add(i);
                }
            }

            if (items.Count == 0)
            {
                return(null);
            }

            items.Sort((a, b) => a.UnlockPrice.CompareTo(b.UnlockPrice));

            var id = items[0].Id;

            AlreadyOnStand.Add(id);

            return(Items.CreateAndAdd(id, Area));
        }
Beispiel #7
0
        public override void Paint(Level level)
        {
            Painter.Fill(level, this, 1, Tile.Chasm);
            Painter.Fill(level, this, (int)(Math.Min(GetWidth(), GetHeight()) / 2f) - 1, Tiles.RandomFloor());

            foreach (var d in Connected.Values)
            {
                Painter.Fill(level, d.X - 1, d.Y - 1, 3, 3, Tiles.RandomFloor());
            }

            for (var i = 0; i < Rnd.Int(1, 5); i++)
            {
                var item = Items.CreateAndAdd(Items.Generate(ItemPool.Consumable), level.Area);
                item.Center = GetCenter() * 16 + new Vector2(Rnd.Float(-4, 4), Rnd.Float(-4, 4));
            }

            if (GlobalSave.IsTrue("saved_npc"))
            {
                for (var i = 0; i < Rnd.Int(1, Run.Depth); i++)
                {
                    var item = Items.CreateAndAdd("bk:emerald", level.Area);
                    item.Center = GetCenter() * 16 + new Vector2(Rnd.Float(-4, 4), Rnd.Float(-4, 4));
                }
            }
        }
    public GlobalSave.SOrder CheckOrder()
    {
        GlobalSave.SOrder leftOrder = null;
        if (DeviceHelper.IAPStyle() == (int)IAPStyle.PAY_APPSTORE)
        {
            leftOrder = GlobalSave.GetAppStoreOrder();
            return(leftOrder);
        }
        else if (DeviceHelper.IAPStyle() == (int)IAPStyle.PAY_IAPPPAY)
        {
            leftOrder = GlobalSave.GetIAppPayOrder();
            return(leftOrder);
        }
        else if (DeviceHelper.IAPStyle() == (int)IAPStyle.PAY_PP)
        {
            leftOrder = GlobalSave.GetPPPayOrder();
            return(leftOrder);
        }
#if UNITY_ANDROID
        else if (DeviceHelper.IAPStyle() == (int)IAPStyle.PAY_CHANGYOU)
        {
            GlobalSave.GetCyouStoreOrder();
        }
        else if (DeviceHelper.IAPStyle() == (int)IAPStyle.PAY_THIRD)
        {
            GlobalSave.GetCyouStoreOrder();
        }
        else if (DeviceHelper.IAPStyle() == (int)IAPStyle.PAY_GooglePay)
        {
            GlobalSave.GetCyouStoreOrder();
        }
#endif
        return(null);
    }
Beispiel #9
0
        private Item PickItem()
        {
            var items = new List <ItemData>();

            foreach (var i in Items.Datas.Values)
            {
                if (i.Type == ItemType.Hat && GlobalSave.GetString("hat") != i.Id && (i.Id == "bk:no_hat" || GlobalSave.IsTrue(i.Id)) && !AlreadyOnStand.Contains(i.Id))
                {
                    items.Add(i);
                }
            }

            if (items.Count == 0)
            {
                return(null);
            }

            items.Sort((a, b) => a.UnlockPrice.CompareTo(b.UnlockPrice));

            var id = items[0].Id;

            AlreadyOnStand.Add(id);

            return(Items.CreateAndAdd(id, Area));
        }
Beispiel #10
0
        static TwitchNpc()
        {
            Dialogs.RegisterCallback("twitch_0", (d, c) => {
                try {
                    var id = GlobalSave.GetString("twitch_username");

                    if (id != null)
                    {
                        c.Dialog.Str.SetVariable("username", id);
                    }

                    return(Dialogs.Get($"twitch_{(id == null ? 1 : 5)}"));
                } catch (Exception e) {
                    Log.Error(e);
                }

                return(null);
            });

            Dialogs.RegisterCallback("twitch_2", (d, c) => {
                var a = ((AnswerDialog)d).Answer;

                Log.Info($"Twitch username is set the seed to {a}");
                GlobalSave.Put("twitch_username", a);
                c.Dialog.Str.SetVariable("username", a);

                return(null);
            });
        }
Beispiel #11
0
        private bool Interact(Entity e)
        {
            var p = $"top_{(int) id}";

            if (!GlobalSave.Exists(p) || GlobalSave.GetString($"{p}_data") == null)
            {
                GetComponent <DialogComponent>().StartAndClose("no_score_yet", 3);
                return(true);
            }

            try {
                GlobalSave.GetJson($"{p}_data");
            } catch (Exception ex) {
                GetComponent <DialogComponent>().StartAndClose("no_score_yet", 3);
                return(true);
            }

            var s = (InGameState)Engine.Instance.State;

            s.InStats = true;
            s.Paused  = true;

            s.ReturnFromStats = () => {
                s.Paused  = false;
                s.InStats = false;
            };

            s.ShowStats(id, p);
            return(true);
        }
Beispiel #12
0
        private void TurnOn(Entity entity)
        {
            if (!TwitchBridge.On)
            {
                entity.RemoveComponent <PlayerInputComponent>();
                var id = TwitchBridge.TwitchUsername;

                sign.GetComponent <DialogComponent>().Start("logging_in");

                new Thread(() => {
                    TwitchBridge.TurnOn(GlobalSave.GetString("twitch_username"), (ok) => {
                        if (ok)
                        {
                            base.Interact(entity);
                        }
                        else
                        {
                            sign.GetComponent <DialogComponent>().StartAndClose($"{Locale.Get("failed_to_login")}\n[cl purple]{id}[cl]", 3);
                            entity.AddComponent(new PlayerInputComponent());
                        }
                    });
                }).Start();
            }
            else
            {
                base.Interact(entity);
            }
        }
Beispiel #13
0
        public static void CheckHats()
        {
            if (Achievements.Get("bk:fashion_matters2").Unlocked)
            {
                return;
            }

            var total    = 0;
            var progress = 0;

            foreach (var i in Items.Datas.Values)
            {
                if (i.Type == ItemType.Hat && i.Id != "bk:no_hat")
                {
                    total++;

                    if (GlobalSave.IsTrue(i.Id))
                    {
                        progress++;
                    }
                }
            }

            if (progress > 0)
            {
                Achievements.Unlock("bk:fancy_hat");
            }

            Log.Info($"Fashion matters progress: {progress}/{total}");
            Achievements.SetProgress("bk:fashion_matters2", progress, total);
        }
        protected override void OnItemSet(Item previous)
        {
            base.OnItemSet(previous);

            if (Run.Depth > 0 && GlobalSave.IsFalse("control_active") && GetComponent <DialogComponent>().Dialog?.Str != null)
            {
                var dialog = GetComponent <DialogComponent>();

                dialog.Dialog.Str.ClearIcons();
                dialog.Dialog.Str.AddIcon(CommonAse.Ui.GetSlice(Controls.FindSlice(Controls.Active, false)));

                if (GamepadComponent.Current != null && GamepadComponent.Current.Attached)
                {
                    dialog.Dialog.Str.AddIcon(CommonAse.Ui.GetSlice(Controls.FindSlice(Controls.Active, true)));
                }

                dialog.StartAndClose("control_6", 5);
            }

            if (Item.Id == "bk:snow_bucket" && !(Run.Level.Biome is IceBiome))
            {
                Timer.Add(() => {
                    var i = Item;

                    Drop();
                    i.Done = true;

                    Entity.GetComponent <InventoryComponent>().Pickup(Items.CreateAndAdd("bk:water_bucket", Entity.Area));
                }, 3f);
            }
        }
Beispiel #15
0
    private void GenerateBar()
    {
        double     number = 1;
        GlobalSave save   = SaveSystem.LoadGlobal();

        if (save == null)
        {
            GlobalInfo.MaxLvl = 1;
            SaveSystem.SaveGlobal();
        }
        else
        {
            number = save.maxLvl == 0 ? 1 : save.maxLvl;
        }

        Vector3 init = new Vector3(-600, 380, 0);

        for (int i = 0; i < number; i++)
        {
            if (i > 4)
            {
                init = new Vector3(0, 380, 0);
            }

            if (i > 9)
            {
                init = new Vector3(600, 380, 0);
            }

            Transform o = Instantiate(lvl, init + new Vector3(0, -140 * (i % 5), 0), Quaternion.identity, transform);

            o.name       = text[i];
            o.localScale = Vector3.one / 2;
        }
    }
Beispiel #16
0
        public override void AddComponents()
        {
            base.AddComponents();

            AddComponent(new ItemComponent {
                DontSave = true
            });

            var i = GetComponent <InteractableComponent>();

            i.CanInteract = e => e.GetComponent <ActiveWeaponComponent>().Item != null && !e.GetComponent <ActiveWeaponComponent>().Item.Scourged;
            i.OnStart     = e => AddFx();

            try {
                var id = GlobalSave.GetString("proto_chest", LevelSave.MeleeOnly ? "bk:ancient_sword" : "bk:ancient_revolver");

                if (id != null)
                {
                    var item = Items.CreateAndAdd(id, Area);
                    GetComponent <ItemComponent>().Set(item, false);
                    itemRegion = item.Region;
                }
            } catch (Exception e) {
                Log.Error(e);
            }
        }
Beispiel #17
0
        public static void Lock(string id)
        {
            var a = Get(id);

            if (a == null)
            {
                Log.Error($"Unknown achievement {id}!");
                return;
            }

            if (!a.Unlocked)
            {
                return;
            }

            a.Unlocked = false;
            GlobalSave.Put($"ach_{a.Id}", false);

            Log.Info($"Achievement {id} was locked!");

            var e = new Achievement.LockedEvent {
                Achievement = a
            };

            Engine.Instance.State.Area.EventListener.Handle(e);
            Engine.Instance.State.Ui.EventListener.Handle(e);

            try {
                LockedCallback?.Invoke(id);
            } catch (Exception ex) {
                Log.Error(ex);
            }
        }
    void Awake()
    {
        ///*



        //*/
        Debug.Log("login awake");
        AccountManager.IsUseAccount = (DeviceHelper.CHANNEL_PP != DeviceHelper.GetChannelID());

        controllers = new Dictionary <ChildIndex, GameObject>();
        GuideManager.Instance.resetRootPanel();
        if (needResetLogin)
        {
            resetLoginWindow();
        }

        if (IsNeedInitPlatform)
        {
            DeviceHelper.InitState();
            IsNeedInitPlatform = false;
        }

        if (GlobalSave.IsFirstSetup())
        {
            DeviceHelper.SetupAnalytics();
            GlobalSave.SetFirstSetup();
        }

        //fb初始化,如果这里初始化失败,会在登陆时再次初始化;
        FbHelper.CallFBInit();
    }
        protected virtual void RemoveStands()
        {
            var rm = GetComponent <RoomComponent>().Room;

            if (rm == null)
            {
                return;
            }

            GlobalSave.Put("item_stolen", true);
            var it = rm.Tagged[Tags.Item].ToArray();             // Copy it to prevent exceptions while modifying it

            foreach (var s in it)
            {
                if (s is SingleChoiceStand ist)
                {
                    if (s is HealChoiceStand)
                    {
                        AnimationUtil.Poof(ist.Center);
                        ist.Done = true;
                    }
                    else if (ist.Item != null)
                    {
                        var i = ist.Item;
                        ist.SetItem(null, this);
                        i.Done = true;
                        AnimationUtil.Poof(ist.Center);
                    }
                }
            }

            Camera.Instance.Shake(10);
        }
Beispiel #20
0
        public override void AddComponents()
        {
            base.AddComponents();

            Width  = 7;
            Height = 17;

            AddComponent(new SensorBodyComponent(-Npc.Padding, -Npc.Padding, Width + Npc.Padding * 2, Height + Npc.Padding * 2, BodyType.Static));

            cost = Math.Min(99, Run.Depth * 15);
            paid = GlobalSave.GetInt("builder_paid", 0);

            AddComponent(new AnimationComponent("builder"));
            // GetComponent<DialogComponent>().Dialog.Voice = 15;

            var dl = GetComponent <DialogComponent>();

            dl.InitCallback = () => {
                dl.Dialog.Str.AddIcon(CommonAse.Ui.GetSlice("coin"));
                dl.Dialog.Str.SetVariable("need", GetPrice());
            };

            AddComponent(new InteractableComponent(e => {
                dl.Start("builder_0", e);
                return(true);
            })
            {
                CanInteract = e => !shouldDissappear
            });

            Dialogs.RegisterCallback("builder_0", (d, c) => {
                if (((ChoiceDialog)d).Choice == 0)
                {
                    if (!c.To.TryGetComponent <ConsumablesComponent>(out var component) || component.Coins == 0)
                    {
                        // Bro, you have no money!
                        return(Dialogs.Get("builder_1"));
                    }

                    var amount = Math.Min(GetPrice(), component.Coins);

                    paid            += amount;
                    component.Coins -= amount;
                    dl.Dialog.Str.SetVariable("need", GetPrice());

                    if (paid >= cost)
                    {
                        GlobalSave.Put("builder_paid", 0);
                        GlobalSave.Put($"shortcut_{Run.Depth}", true);

                        return(Dialogs.Get("builder_3"));
                    }
                    else
                    {
                        GlobalSave.Put("builder_paid", paid);
                    }

                    return(Dialogs.Get("builder_2"));
                }
Beispiel #21
0
 public static void LoadState()
 {
     foreach (var a in Defined.Values)
     {
         a.Unlocked       = GlobalSave.IsTrue($"ach_{a.Id}");
         a.CompletionDate = GlobalSave.GetString($"ach_{a.Id}_date", "???");
     }
 }
    void OnOrderRet(string strMsg)
    {
        int    nStatus      = -1;
        int    nTradeStatus = -1;
        string strSpsn      = new string('\0', 5);

        StrParse(strMsg, out nStatus, out nTradeStatus, out strSpsn);

        //TODO
        Debug.Log("------OnOrderRet strMsg=" + strMsg + " strSpsn=" + strSpsn);

        /*
         * //畅游支付,存单
         * {
         *  string strAccountid, strgpg;
         *  GlobalSave.GetCyouStoreLossGoodInfoTemp(out strAccountid, out strgpg);
         *  if( strAccountid != null &&
         *      strgpg  != null
         *      )
         *  {
         *      Debug.Log("pllog_Cyou_strAccountid:"+strAccountid);
         *      Debug.Log("pllog_Cyou_strgpg:"+strgpg);
         *
         *      int s32Accountid        = Convert.ToInt32(strAccountid);
         *      int s32SelfAccountid    = Convert.ToInt32(Obj_MyselfPlayer.GetMe().accountID);
         *
         *      if(s32Accountid == s32SelfAccountid)
         *      {
         *          string[] info_gid_pid_gprice = strgpg.Split('|');
         *          string gid = info_gid_pid_gprice[0];
         *          string pid = info_gid_pid_gprice[1];
         *          string gprice = info_gid_pid_gprice[2];
         *
         *          Debug.Log("pllog_Cyou_gid:"+gid);
         *          Debug.Log("pllog_Cyou_pid:"+pid);
         *          Debug.Log("pllog_Cyou_gprice:"+gprice);
         *
         *          JsonData cydata     = new JsonData();
         *          cydata["ACC"]       = Obj_MyselfPlayer.GetMe().accountID;
         *          cydata["OID"]       = strSpsn;//畅游渠道的订单号是由sdk自己生成的,在这里第一次从java中传出
         *          cydata["GID"]       = gid;
         *          cydata["PID"]       = pid;
         *          cydata["PPRICE"]    = gprice;
         *          cydata["PNAME"]     = "CYProduct";
         *
         *          WebMediator.SavePayLog(cydata.ToJson());
         *          Debug.Log("pllog_Cyou_SavePayLog:"+cydata.ToJson());
         *      }
         *
         *  }
         *  GlobalSave.SOrder order = PurchaseHelper.Instance().CheckOrder();
         * }
         */
        // 订单记录
        PurchaseHelper.Instance().AddCyouOrder(strSpsn);
        //GlobalSave.AddCyouStoreLossOrder(strSpsn, Obj_MyselfPlayer.GetMe().accountID); // 这里先行设置如果掉单,的单号
        GlobalSave.SetCyouStoreLossGoodInfoTempToReal(strSpsn, Obj_MyselfPlayer.GetMe().accountID); // 将保存的临时信息转成正式信息
    }
Beispiel #23
0
        public override void PostInit()
        {
            if (!Engine.EditingLevel && GlobalSave.IsFalse($"shortcut_{id}"))
            {
                broken = true;
            }

            base.PostInit();
        }
Beispiel #24
0
        public static void SetProgress(string id, int progress, int max = -1)
        {
            if (Assets.DataModified)
            {
                return;
            }

            if (progress == 0)
            {
                return;
            }

            var a = Get(id);

            if (a == null)
            {
                Log.Error($"Unknown achievement {id}!");
                return;
            }

            if (a.Unlocked)
            {
                return;
            }

            if (max == -1)
            {
                Log.Info($"Reading max as {a.Max} for {id}");
                max = a.Max;
            }

            if (max == 0)
            {
                Log.Error($"Max for {id} is 0");
                return;
            }

            var idt = $"ach_{a.Id}";

            if (progress < max)
            {
                GlobalSave.Put(idt, progress);
            }

            try {
                ProgressSetCallback?.Invoke(id, progress, max);
            } catch (Exception e) {
                Log.Error(e);
            }

            if (progress >= max)
            {
                Log.Info($"Progress {progress} is >= than {max} for {id}");
                ReallyUnlock(id, a);
            }
        }
Beispiel #25
0
        public override void Init()
        {
            base.Init();

            disk = GlobalSave.GetInt("disk");

            top    = CommonAse.Props.GetSlice("player_top");
            bottom = CommonAse.Props.GetSlice("player");
            tdisk  = CommonAse.Props.GetSlice("disk");
        }
    private void pplog_update()
    {
        JsonData jd = GlobalSave.GetOrderTable();

        if (jd != null)
        {
            int num = jd.Count;
            Debug.Log("pllog_update num=" + num);
            Debug.Log("pllog_update begin LastSendIdx=" + LastSendIdx);

            if (LastSendIdx >= num)
            {
                LastSendIdx = 0;
            }
            for (int i = LastSendIdx; i < num; i++)
            {
                if (jd[i] != null)
                {
                    if (jd[i]["accountID"] != null)
                    {
                        string orderacc     = (string)jd[i]["accountID"];
                        int    orderaccint  = Convert.ToInt32(orderacc);
                        int    accountIDint = Convert.ToInt32(Obj_MyselfPlayer.GetMe().accountID);

                        if (orderaccint != accountIDint)
                        {
                            Debug.Log("pllog_Not_Self");
                            //不是自己的单
                            continue;
                        }
                        else
                        {
                            Debug.Log("pllog_Update_SendVarify :" + JsonMapper.ToJson(jd[i]));
                            // 补提订单.处理丢单情况
                            PurchaseHelper.Instance().VarifyJavaOrder((string)jd[i]["gid"],
                                                                      (string)jd[i]["pid"],
                                                                      (string)jd[i]["goodsPrice"],
                                                                      (string)jd[i]["orderId"]
                                                                      );
                            LastSendIdx++;
                            Debug.Log("pllog_update mid LastSendIdx=" + LastSendIdx);

                            if (LastSendIdx >= num)
                            {
                                LastSendIdx = 0;
                            }
                            Debug.Log("pllog_update end LastSendIdx=" + LastSendIdx);
                            //晕,一个逻辑帧只发一个包,在收到反馈包之前不能发第二个,所以发包不能太快。
                            break;
                        }
                    }
                }
            }
        }
    }
Beispiel #27
0
        public static bool ShouldAppear(ItemData t)
        {
            if (LevelSave.MeleeOnly && t.Type == ItemType.Weapon && t.WeaponType != WeaponType.Melee)
            {
                return(false);
            }

            return((Run.Type == RunType.Daily || !t.Lockable || GlobalSave.IsTrue(t.Id)) && (!t.Single || Run.Statistics == null ||
                                                                                             (!Run.Statistics.Items.Contains(t.Id) &&
                                                                                              !Run.Statistics.Banned.Contains(t.Id))) && t.Id != "bk:the_sword");
        }
Beispiel #28
0
        public AmbianceViewModel()
        {
            var globalSavePath = Path.Combine(Directory.GetCurrentDirectory(), "Save.dat");

            _globalSave = GetGlobalSave(globalSavePath);

            CurrentCampaign   = FileHandler.ReadFromXmlFile <Campaign>(_globalSave.LastOpenedCampaignPath);
            CampaignViewModel = new CampaignViewModel(CurrentCampaign);

            MenuViewModel = new MenuViewModel(this);
        }
Beispiel #29
0
    public static GlobalSave Load()
    {
        string path = Application.persistentDataPath + "/saves/";

        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Open(path + "save.txt", FileMode.Open);

        GlobalSave save = (GlobalSave)bf.Deserialize(file);

        Debug.Log(save);
        return(save);
    }
    public void Load()
    {
        LoadSave.CharacterName = characterName;
        GlobalSave save = LoadSave.Load();

        foreach (WeaponSave weaponSave in save.weaponSaves)
        {
            Weapon weapon = GameManager.instance.WeaponDatabase.GetWeaponByID(weaponSave.id);
            weapon.LoadFromSave(weaponSave);
            CharacterInventory.instance.PickupWeaponNoInventory(weapon, false);
        }
    }