public void Cast() { oldterm = proposal.readTerm(); evalmode.val = true; onApply.Invoke(); effectAudioEvent.Invoke(7); //Cast Spell Sound List <Term> args = Enumerable.Range(0, arity) .Select(i => Term.Leaf(Sum <Combinator, Variable> .Inr((Variable)i))).ToList(); proposal.Append(args); LayoutTracker arg_paren = variable_symbols_here.GetComponentInChildren <LayoutTracker>(); List <Transform> ts = new List <Transform>(); for (int i = 0; i < arg_paren.transform.childCount; i++) { ts.Add(arg_paren.transform.GetChild(i)); } foreach (Transform variable in ts) { variable.GetComponent <LayoutTracker>().root = proposal.skeletonRoot; variable.SetParent(proposal.GetComponentInChildren <LayoutTracker>().transform, true); } term = proposal.readTerm(); button.onClick.RemoveListener(Cast); button.onClick.AddListener(Step); button.GetComponent <Image>().sprite = stepSymbol; SkipButton.gameObject.SetActive(true); SkipBackButton.gameObject.SetActive(true); StepBackButton.gameObject.SetActive(true); StopButton.gameObject.SetActive(true); refreshButtons(); LayoutRebuilder.MarkLayoutForRebuild(transform.parent.GetComponent <RectTransform>()); if (target.goal.Equal(term)) { Success.Invoke(); } Debug.Log(arg_paren); Destroy(arg_paren); variable_symbols_here.gameObject.SetActive(false); foreach (var canvas in FindObjectsOfType <Canvas>()) { LayoutRebuilder.MarkLayoutForRebuild(canvas.GetComponent <RectTransform>()); } }
// Update is called once per frame void Update() { if (Input.GetKey(k)) { hook.Invoke(); } }
public void CheckSuccess() { print("checking"); if (isFinished()) { success.Invoke(); } }
private void SetSelectedUnit(Unit unit, bool forceEvent = false) { if (unit != selectedUnit || forceEvent) { selectedUnit = unit; OnSelectedUnitChanged.Invoke(selectedUnit); } }
/* * decreases the Unit's HP by dmg. Destroys the unit if HP <= 0 */ public void TakeDamage(float dmg) { HP -= dmg; if (HP <= 0) { unitDead.Invoke(this); Instantiate(Explosion, transform.position, transform.rotation); Destroy(gameObject); } }
public void AcknowledgeUnitDied(string id) { units.TryGetValue(id, out Core.Unit unit); if (unit == null) { return; } OnUnitDies.Invoke(unit); units.Remove(unit.ID); }
// Update is called once per frame void Update() { //Transforms the text upward in the UI rect.transform.position += transform.up * textObject.scrollSpeed * Time.deltaTime; //Goes over a certain position if (rect.transform.position.y > 125) { goesOverBounds.Invoke(); } }
private void TryFindAttackTarget( ) { Unit newOponent = UnitsManager.Instance.FindOpponent(side, Center, attackRange); // No current target if (!currentOpponent) { // We lost target if (inAttackRange) { if (CheatAndDebug.Instance.ShowDebugInfo) { Debug.Log($"{name} lost friendly target"); } onEnemyInRange.Invoke(null); inAttackRange = false; } // New target found if (newOponent) { onEnemyInRange.Invoke(newOponent); inAttackRange = true; if (!nonMovable) { animator.SetTrigger("Idle"); } return; } if (!nonMovable) { animator.SetTrigger("Moving"); } return; } }
public void Invoke() { if (!toggle) { start.Invoke(); } else { stop.Invoke(); } toggle = !toggle; }
IEnumerator run() { yield return(new WaitUntil(() => Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.RightArrow))); KeyCode nextKey = Input.GetKeyDown(KeyCode.LeftArrow) ? KeyCode.RightArrow : KeyCode.LeftArrow; while (gameObject.activeInHierarchy) { run_forward.Invoke(); yield return(new WaitUntil(() => Input.GetKeyDown(nextKey))); nextKey = nextKey == KeyCode.LeftArrow ? KeyCode.RightArrow : KeyCode.LeftArrow; } }
public void UnCast() { evalmode.val = false; variable_symbols_here.gameObject.SetActive(true); onUnapply.Invoke(); button.onClick.RemoveListener(Step); button.onClick.AddListener(Cast); button.image.sprite = castSymbol; button.image.enabled = true; SkipButton.gameObject.SetActive(false); SkipBackButton.gameObject.SetActive(false); StepBackButton.gameObject.SetActive(false); StopButton.gameObject.SetActive(false); LayoutRebuilder.MarkLayoutForRebuild(transform.parent.GetComponent <RectTransform>()); }
private void OnDestroy() { OnDestroyEvent.Invoke(this); OnTargetChangedEvent.RemoveAllListeners(); OnDestroyEvent.RemoveAllListeners(); }
IEnumerator ReadDialogue() { yield return(null); currentFrame.val.Enter(); dialogueIn.Invoke(); print($"entering current frame: {currentFrame.val}"); string temp_string; screens.SetActive(true); yield return(null); foreach (line_of_dialogue line in currentFrame.val.lines) { if (Score.val <= line.lowestScoreAllowed && line.lowestScoreAllowed != 0) { continue; } if (Score.val >= line.highestScoreAllowed && line.highestScoreAllowed != 0) { continue; } background.sprite = line.bg; if (characterAnimator != null) { characterAnimator.SetTrigger(line.animationTrigger); } Color tempColor; switch (line.speaker) { case Character.date: tempColor = dateColor; break; case Character.dog: tempColor = dogColor; break; case Character.player: tempColor = playerColor; break; default: tempColor = Color.clear; break; } yield return(StartCoroutine(readText(line.line, tempColor, line.speaker, line.voiceLine, nop(), line.bg != blank))); } currentFrame.val.Exit(); if (!currentFrame.val.noBoard) { beginListening(); } else //no board { if (currentFrame.val.visible_choices.Count == 1) { changeFrame(0); } else { if (Score.val >= 2) { StartCoroutine(blackhole_spewer(true, () => changeFrame(0))); } else { StartCoroutine(blackhole_spewer(false, () => changeFrame(1))); } } } }
internal void Die() { Debug.Log(Name + " is slain!"); DeathEvent.Invoke(this); Destroy(this.gameObject); }
public void AddUnit(Core.Unit unit) { Debug.Log($"Spawned: {unit.ID}"); units.Add(unit.ID, unit); OnUnitAdd.Invoke(unit); }
public void TileUnitCheck(IUnit unit) { CheckUnitTiles?.Invoke(unit); }
void Update() { //sort out mouseover stuff MouseoverPoint = Dungeon.WorldToCell(Camera.main.ScreenToWorldPoint(Input.mousePosition)); if (MouseoverPoint != PreviousMouseoverPoint) { MouseoverChangedEvent.Invoke(MouseoverPoint); PreviousMouseoverPoint = MouseoverPoint; foreach (var unit in AllUnits) { unit.DisableUI(); } var unitUnderMouse = AllUnits.Find(u => u.transform.position == MouseoverPoint); var dungeonTileUnderMouse = (DungeonTile)Dungeon.GetTile(MouseoverPoint); if (unitUnderMouse != null) { unitUnderMouse.EnableUI(); } var dangerzoneUnderMouse = AllDangerzones.Where(d => d.transform.position == MouseoverPoint) .Select(d => d.GetComponent <DangerzoneController>()).ToList(); dangerzoneUnderMouse.AddRange( summoningCircles.Where(s => s.transform.position == MouseoverPoint). Select(s => s.GetComponent <DangerzoneController>())); UI.ShowMouseOverInfo(dungeonTileUnderMouse, unitUnderMouse, dangerzoneUnderMouse); } if (!blockInputs) { //hot keyboard shortcuts if (Input.GetKeyDown(KeyCode.Escape)) { TurnFSM.SetTrigger(GameStateTransitions.Deselect); } else if (Input.GetKeyDown(KeyCode.Alpha1)) { if (UnitClicked != null && UnitClicked.MyLoadout.Abilities.Length > 0) { AbilityButtonClick(0); } } else if (Input.GetKeyDown(KeyCode.Alpha2)) { if (UnitClicked != null && UnitClicked.MyLoadout.Abilities.Length > 1) { AbilityButtonClick(1); } } else if (Input.GetKeyDown(KeyCode.Alpha3)) { if (UnitClicked != null && UnitClicked.MyLoadout.Abilities.Length > 2) { AbilityButtonClick(2); } } if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape)) { TriggerTransition(GameStateTransitions.Deselect); } if (Input.GetMouseButtonDown(0)) { RaycastHit2D[] hits = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); foreach (var hit in hits) { if (hit.collider != null) { if (hit.collider.CompareTag("Unit")) { UnitClickedEvent.Invoke(hit.collider.GetComponent <UnitController>()); } else if (hit.collider.CompareTag("UIHighlights")) { var destination = Dungeon.WorldToCell(hit.point); //TODO: don't hardcode to first ability UIHighlightClickedEvent.Invoke(destination); } } } } } }