// Update is called once per frame void Update() { StoryManager story = StoryManager.GetSingleton(); inHand.text = "$" + story.GetInt("player_money"); inBank.text = "$" + story.GetInt("player_bank_money"); }
public void Buy() { Ink.Runtime.Story story = StoryManager.GetSingleton().GetStory(); story.variablesState["player_money"] = (int)story.variablesState["player_money"] - cost; story.variablesState[savedName] = (int)story.variablesState[savedName] + (multiple ? quantity : 1); }
public bool isEnabled() { Ink.Runtime.Story story = StoryManager.GetSingleton().GetStory(); var storyValue = story.variablesState[savedName]; if (!multiple && storyValue != null && (int)storyValue > 0) { return(false); } if (parsedCondition == null && condition != null && condition != "") { parsedCondition = ConditionParser.parseCondition(condition); } if (cost > (int)story.variablesState["player_money"]) { return(false); } if (parsedCondition == null) { return(true); } else { return(parsedCondition.evaluate(new GameState(story))); } }
public void OnTriggerEnter2D(Collider2D collider) { StoryManager manager = StoryManager.GetSingleton(); manager.SetInt("player_money", manager.GetInt("player_money") + moneyAmount); Destroy(gameObject); }
void Start() { CardGameVariables oponent = GetOponent(CardGameInitializer.playerName); deck = new Deck(oponent.deckSkin ?? deckSkin); players = new PlayerLogic[] { //BuildPlayerLogic(playerHand, playerMoney, oponent, "SmartAI", defaultAIData), new HumanPlayerLogic(0, playerHand, foldButton, guiTransform, bidPreview, multiplier, multiplierShow, multiplierImages, cardSelection, playerMoney), BuildPlayerLogic(oponentHand, oponentMoney, oponent, "SmartAI", defaultAIData), }; var story = StoryManager.GetSingleton().GetStory(); if (story != null) { players[0].AdjustMoney((int)(story.variablesState["player_money"] ?? 1000) - players[0].money); if (oponent.oponentMoneyStore != null) { players[1].AdjustMoney((int)story.variablesState[oponent.oponentMoneyStore] - players[1].money); } } foreach (PlayerLogic logic in players) { logic.hand.UseBack(oponent.deckSkin == null ? deckSkin.back : oponent.deckSkin.back); } StartHand(); }
public void EndGame() { CardGameVariables oponent = GetOponent(CardGameInitializer.playerName); var story = StoryManager.GetSingleton(); story.SetInt("player_money", players[0].money); story.SetInt(oponent.oponentMoneyStore, players[1].money); WorldInitializer.LoadWorld(CardGameInitializer.returnPoint ?? new MapPath("default", "default"), CardGameInitializer.returnKnot); }
public void ShowNumberSpinner(NumberSpinnerParams spinParams) { spinnerParams = spinParams; spinnerInstance = Instantiate(spinnerPrefab); spinnerInstance.rectTransform.SetParent(spinnerPosition.parent, false); spinnerInstance.rectTransform.position = spinnerPosition.position; spinnerInstance.SetDigitCount(spinnerParams.GetValueOrDefault().digitCount); spinnerInstance.SetValue((int)StoryManager.GetSingleton().GetStory().variablesState[spinnerParams.GetValueOrDefault().variableName]); }
public void ResetSpinner() { if (HasSpinner()) { StoryManager.GetSingleton().GetStory().variablesState[spinnerParams.GetValueOrDefault().variableName] = spinnerInstance.GetValue(); Destroy(spinnerInstance.gameObject); spinnerParams = null; } }
public override int GetInt(string name) { object result = StoryManager.GetSingleton().GetStory().variablesState[prefix + name]; if (result == null) { return(0); } return((int)result); }
void OnDie(Damageable damageable) { StoryManager.GetSingleton().SetBoolean("player_is_dead", true); target.CurrentHealth = target.MaxHealth; StartCoroutine(DeathSequence.Start( DarknessOverlay.GetOverlay(), player.animator, playerRenderer, player.GetComponent <Flasher>() )); }
public override bool GetBool(string name) { object result = StoryManager.GetSingleton().GetStory().variablesState[prefix + name]; if (result == null) { return(false); } return((int)result != 0); }
public void UseStore(string name) { playerMoney.text = "$" + StoryManager.GetSingleton().GetInt("player_money").ToString(); currentStore = stores.Length > 0 ? stores[0] : null; for (int i = 0; i < stores.Length; ++i) { if (stores[i].name == name) { currentStore = stores[i]; break; } } activeItems.ForEach((item) => Destroy(item.gameObject)); activeItems.Clear(); Selectable prevItem = null; if (currentStore != null) { for (int i = 0; i < currentStore.inventory.Length; ++i) { StoreItem item = currentStore.inventory[i]; StoreGUIRow row = Instantiate(storeItemPrefab); row.UseItem(item); row.rectTransform.position = itemStart.position; row.rectTransform.Translate(new Vector3(0.0f, -itemStart.rect.height * i, 0.0f)); row.rectTransform.parent = itemStart.parent; row.rectTransform.localScale = Vector3.one; Navigation buttonNav = row.button.navigation; buttonNav.selectOnUp = prevItem; row.button.navigation = buttonNav; if (prevItem != null) { Navigation prevNav = prevItem.navigation; prevNav.selectOnDown = row.button; prevItem.navigation = prevNav; } row.onEnterEvents.Add(() => DescribeItem(item)); row.button.onClick.AddListener(() => BuyItem(item)); activeItems.Add(row); } } }
public void Start() { if (followCamera != null && followCamera.target == null) { followCamera.target = player.transform; } if (story != null) { StoryManager.GetSingleton().SetStory(story); StoryManager.GetSingleton().currentBindings = storyFunctionBindings; } if (WorldInitializer.location != null) { Goto(WorldInitializer.location); } else if (startingLocation != null) { Goto(startingLocation); } }
public void OnTriggerEnter2D(Collider2D collision) { StoryManager.GetSingleton().SetBoolean("player_is_dead", false); GameObject.FindGameObjectWithTag("GameController").GetComponent <WorldController>().SwitchTo(MapDirections.Living); }
public void Start() { if (condition == "" || ConditionParser.parseCondition(condition).evaluate(new GameState(StoryManager.GetSingleton().GetStory()))) { GameObject instance = Instantiate(toSpawn, transform.position + transform.TransformDirection(size), transform.rotation) as GameObject; instance.transform.parent = transform.parent; if (properties.Count > 0) { PrefabProperties prefabProperties = instance.GetComponent <PrefabProperties>(); if (prefabProperties == null) { prefabProperties = instance.AddComponent <PrefabProperties>(); } prefabProperties.properties = properties; } } }
public override void SetInt(string name, int value) { StoryManager.GetSingleton().GetStory().variablesState[prefix + name] = value; }
public IState CommonMovement(float deltaTime, float speed) { if (deltaTime == 0.0f) { return(null); } float horz = Input.GetAxisRaw("Horizontal"); float vert = Input.GetAxisRaw("Vertical"); movement.TargetVelocity = new Vector2(horz, vert).normalized *speed; State maybeResult = inventory.checkUseItems(); if (maybeResult != null) { return(maybeResult); } if (Input.GetButtonDown("Fire2")) { return(new DoCoroutine(SwingSword(), this)); } if (inventory.HasAGun() && Input.GetButtonDown("Reload")) { return(reload); } if (Input.GetButtonDown("CycleWeapon") && inventory.HasAGun()) { inventory.NextGun(); } if (!inventory.HasAGun()) { animator.SetInteger("GunType", 0); } else { GunStats stats = inventory.GetCurrentGun(); animator.SetInteger("GunType", stats.animationIndex); } if (Input.GetButtonDown("DeathJump")) { bool isDead = StoryManager.GetSingleton().GetBoolean("player_is_dead"); StartCoroutine(DeathSequence.FlashTransition(isDead ? MapDirections.Living : MapDirections.Dead, darkness)); StoryManager.GetSingleton().SetBoolean("player_is_dead", !isDead); } if (Input.GetButtonDown("Submit")) { var overlaps = Physics2D.OverlapCircleAll(direction.TransformPoint(Vector3.right * interactDistance), interactRadius); ScriptInteraction interaction = overlaps.Select(collider => collider.gameObject.GetComponent <ScriptInteraction>()) .Where(value => value != null) .FirstOrDefault(x => true); if (interaction != null) { return(new Interact(this, interaction.interact())); } } return(null); }
public override void SetBool(string name, bool value) { StoryManager.GetSingleton().GetStory().variablesState[prefix + name] = value ? 1 : 0; }
public IEnumerator interact(string storyEntryPoint) { TimePause.ScaleTime(0.0f); Time.timeScale = 0.0f; prefabInstance = Instantiate <TextDialog>(textPrefab); Story story = StoryManager.GetSingleton().GetStory(); story.ChoosePathString(storyEntryPoint, new string[] { }); do { string storyText = story.Continue(); List <Choice> choices = story.currentChoices; string[] parts = prefabInstance.SplitSections(storyText, choices.Count + (spinnerParams != null ? 1 : 0)); if (delayTime > 0.0f && timeoutKnot != null) { yield return(new WaitForSecondsRealtime(delayTime)); delayTime = 0.0f; } prefabInstance.Reset(); if (storyText.Trim() == "[...]") { continue; } foreach (string part in parts) { prefabInstance.text.text = part; if (part == parts[parts.Length - 1] && spinnerParams != null) { prefabInstance.ShowNumberSpinner(spinnerParams.GetValueOrDefault()); spinnerParams = null; } if (choices.Count > 0 && part != parts[parts.Length - 1] || choices.Count == 0) { while (!Input.GetButtonDown("Submit")) { yield return(null); } while (!Input.GetButtonUp("Submit")) { yield return(null); } } } if (choices.Count > 0) { prefabInstance.ShowOptions(choices); int currentSelection = 0; while (!Input.GetButtonDown("Submit")) { if (Input.GetButtonDown("Next") && currentSelection < choices.Count - 1) { currentSelection++; } if (Input.GetButtonDown("Previous") && currentSelection > 0) { currentSelection--; } prefabInstance.Select(currentSelection); yield return(null); } if (currentSelection < choices.Count) { story.ChooseChoiceIndex(choices[currentSelection].index); if (story.canContinue) { story.Continue(); } } while (!Input.GetButtonUp("Submit")) { yield return(null); } } prefabInstance.ResetSpinner(); }while (story.canContinue); Destroy(prefabInstance.gameObject); TimePause.UnscaleTime(0.0f); Time.timeScale = 1.0f; if (timeoutKnot != null) { string toKnot = timeoutKnot; timeoutKnot = null; yield return(interact(toKnot)); } CardGameInitializer.Commit(); }