private void SetConfig(PlayerConfig config) { _selected = config; Name.text = config.name; Description.text = config.Description; Doll.sprite = config.Doll; }
private void GenerateButton(PlayerConfig config) { GameObject prefab = Instantiate(ButtonPrefab, this.transform, false); Vector3 localXform = prefab.transform.localPosition; localXform.y = _btnHeight * transform.childCount; prefab.transform.localPosition = localXform; prefab.GetComponent <Text>().text = config.name; prefab.GetComponent <Image>().sprite = config.Portrait; prefab.GetComponent <Button>().onClick.AddListener(delegate { SetConfig(config); }); }
public void Execute(string playerID) { PlayerConfig config = Resources.Load <PlayerConfig>(Filepath.PLAYERS + playerID); if (config != null) { InventoryModel inventory = AmbitionApp.Inventory; AmbitionApp.Execute <RestorePlayerCmd, PlayerConfig>(config); AmbitionApp.Game.Livre = config.Livre; foreach (ItemConfig def in config.Inventory) { inventory.Inventory.Add(inventory.Instantiate(def.name)); } } }
public void Show() { //App.Service<AssetBundleSvc>().Load(PLAYER_BUNDLE); _characters = Resources.LoadAll <PlayerConfig>(PLAYER_BUNDLE); if (_characters.Length > 1) { gameObject.SetActive(true); _btnHeight = ButtonPrefab.GetComponent <RectTransform>().rect.height; Array.ForEach(_characters, GenerateButton); } else { _selected = _characters[0]; PickCharacter(); } }
public override void OnOpen() { _selected = Characters[0]; Submit(); }
public void Execute(string savedGameData) { GameModel game = AmbitionApp.Game; if (!game.Initialized) { AmbitionApp.Execute <InitGameCmd>(); } UFlowSvc uflow = AmbitionApp.GetService <UFlowSvc>(); CalendarModel calendar = AmbitionApp.GetModel <CalendarModel>(); IncidentModel story = AmbitionApp.Story; ParisModel paris = AmbitionApp.Paris; PartyModel partyModel = AmbitionApp.GetModel <PartyModel>(); AmbitionApp.GetService <ModelSvc>().Restore(savedGameData); PlayerConfig config = Resources.Load <PlayerConfig>(Filepath.PLAYERS + game.playerID); AmbitionApp.Execute <RestorePlayerCmd, PlayerConfig>(config); LocationVO location = paris.GetLocation(paris.Location); AmbitionApp.CloseAllDialogs(); AmbitionApp.SendMessage(AudioMessages.STOP_AMBIENT); AmbitionApp.SendMessage(AudioMessages.STOP_MUSIC); uflow.Reset(); story.RestoreIncident(); foreach (string tutorialID in game.Tutorials) { AmbitionApp.Execute <TutorialReward, CommodityVO>(new CommodityVO() { Type = CommodityType.Tutorial, ID = tutorialID }); } UMachine flow = calendar.Day == 0 ? uflow.Instantiate(FlowConsts.GAME_CONTROLLER) : uflow.Instantiate(FlowConsts.DAY_FLOW_CONTROLLER); string sceneID = null; switch (game.Activity) { case ActivityType.Estate: if (story.Moment == null) { flow = RestoreEstate(flow, out sceneID); } else { flow = Restore(flow, MORNING_INCIDENT); } break; case ActivityType.Party: flow = Restore(flow, PARTY_STATE); if (story.Moment == null) { if (partyModel.TurnsLeft > 0) { Restore(flow, PARTY_MAP); sceneID = SceneConsts.MAP_SCENE; } else { Restore(flow, AFTER_PARTY); sceneID = SceneConsts.AFTER_PARTY_SCENE; } } else if (partyModel.Turn < 0) { flow = Restore(flow, PARTY_INTRO); } else if (partyModel.TurnsLeft > 0) { flow = Restore(flow, PARTY_ROOM); } else { flow = Restore(flow, PARTY_OUTTRO); } break; case ActivityType.Evening: flow = Restore(flow, EVENING_STATE); break; case ActivityType.Paris: flow = Restore(flow, PARIS_STATE); if (story.Moment != null) { flow = Restore(flow, PARIS_INCIDENT); } else { sceneID = location?.SceneID ?? SceneConsts.PARIS_SCENE; Restore(flow, sceneID == SceneConsts.PARIS_SCENE ? PARIS_STATE : PARIS_SCENE); } break; case ActivityType.Rendezvous: flow = Restore(flow, RENDEZVOUS_STATE); flow = Restore(flow, RENDEZVOUS_INCIDENT); break; } if (story.Moment != null) { Restore(flow, MOMENT); sceneID = SceneConsts.INCIDENT_SCENE; } if (!string.IsNullOrEmpty(sceneID)) { AmbitionApp.SendMessage(GameMessages.LOAD_SCENE, sceneID); } uflow.Execute(); AmbitionApp.SendMessage(GameMessages.GAME_LOADED); }