void Update() { if (Input.GetKeyDown(KeyCode.KeypadPlus)) { EventCoordinator.TriggerEvent(EventName.System.Economy.ModifyResource(), GameMessage.Write().WithFloatMessage(1.5f).WithResource(ResourceItem.Ductape)); EventCoordinator.TriggerEvent(EventName.System.Economy.ModifyResource(), GameMessage.Write().WithFloatMessage(-1.5f).WithResource(ResourceItem.Wd)); } if (Input.GetKeyDown(KeyCode.Keypad1)) { EventCoordinator.TriggerEvent(EventName.System.Story.UnlockEnding(), GameMessage.Write().WithIntMessage(1)); } if (Input.GetKeyDown(KeyCode.Keypad2)) { EventCoordinator.TriggerEvent(EventName.System.Story.UnlockEnding(), GameMessage.Write().WithIntMessage(2)); } if (Input.GetKeyDown(KeyCode.Keypad3)) { EventCoordinator.TriggerEvent(EventName.System.Story.UnlockEnding(), GameMessage.Write().WithIntMessage(3)); } if (Input.GetKeyDown(KeyCode.E)) { EventCoordinator.TriggerEvent(EventName.System.EndGame(), GameMessage.Write()); } if (Input.GetKeyDown(KeyCode.Delete)) { ClearSaves(); } }
IEnumerator PickUpLoot() { animator.SetInteger("state", 2); // PickUp animation float startTime = Time.time; do { if (target == null) { StartCoroutine(Wait()); yield break; } if (isChasing) { yield break; } yield return(null); }while (startTime + pickUpTime > Time.time); Debug.Log("pick up"); EventCoordinator.TriggerEvent(EventName.System.Environment.PickUpLoot(), GameMessage.Write().WithTargetTransform(target)); Reevaluate(); }
void Start() { if (GameStateView.HasState(GameState.gameReloaded)) { EventCoordinator.TriggerEvent(EventName.System.SceneLoaded(), GameMessage.Write()); } }
void Update() { if (Input.GetKeyDown(KeyCode.S)) { EventCoordinator.TriggerEvent(EventName.Input.StartGame(), GameMessage.Write().WithStringMessage("yay")); } }
public static void IsolateLabelMaskGroup(int groupId) { if (groupId == 0) { LabelMaskCoordinator.SetAllStates(true); } else { LabelMaskCoordinator.SetAllStates(false); if (groupId == 1) { Instance.EnableLabelGroup(LabelsBucket.BuildingLabels); } if (groupId == 2) { Instance.EnableLabelGroup(LabelsBucket.FurnitureLabels); } if (groupId == 3) { Instance.EnableLabelGroup(LabelsBucket.ItemLabels); } if (groupId == 4) { Instance.EnableLabelGroup(LabelsBucket.AnimalsLabels); } } EventCoordinator.TriggerEvent(EventName.UI.LabelMaskChanged(), GameMessage.Write()); }
IEnumerator Attack() { isChasing = false; animator.SetInteger("state", 3); // Attack animation float startTime = Time.time; agent.isStopped = true; do { if (target == null) { StartCoroutine(Wait()); yield break; } if (isChasing) { yield break; } yield return(null); }while (startTime + attackTime > Time.time); if (target != null && CanAttack(target)) { Debug.Log("hit"); EventCoordinator.TriggerEvent(EventName.System.Environment.Damage(), GameMessage.Write().WithTargetTransform(target)); } Reevaluate(); }
void OnResourceChanged(GameMessage msg) { if (PlayerDataBucket.IsAnyResourceEmpty()) { EventCoordinator.TriggerEvent(EventName.System.EndGame(), GameMessage.Write()); } }
void OnModifyResource(GameMessage msg) { bool goodSelected = msg.cardData.correctResrouce == msg.resourceItem; Answer answer = msg.cardData.answers.Where(x => x.good == goodSelected && x.resource == msg.resourceItem).FirstOrDefault(); float amount = answer.cost; EventCoordinator.TriggerEvent(EventName.System.Economy.ModifyResource(), GameMessage.Write().WithResource(msg.resourceItem).WithFloatMessage(-amount)); }
void Update() { if (Input.GetKeyDown(KeyCode.Space)) { inferenceState = !inferenceState; if (inferenceState) { EventCoordinator.TriggerEvent(EventName.System.StartInference(), GameMessage.Write()); } else { EventCoordinator.TriggerEvent(EventName.System.StopInference(), GameMessage.Write()); } } if (Input.GetKeyDown(KeyCode.BackQuote)) { LabelMaskController.IsolateLabelMaskGroup(0); } if (Input.GetKeyDown(KeyCode.F1)) { LabelMaskController.IsolateLabelMaskGroup(1); } if (Input.GetKeyDown(KeyCode.F2)) { LabelMaskController.IsolateLabelMaskGroup(2); } if (Input.GetKeyDown(KeyCode.F3)) { LabelMaskController.IsolateLabelMaskGroup(3); } if (Input.GetKeyDown(KeyCode.F4)) { LabelMaskController.IsolateLabelMaskGroup(4); } // Add more F keys if you made more label groups //... if (Input.GetKeyDown(KeyCode.Q)) { HideBackgroundController.ChangeShowState(); } if (Input.GetKeyDown(KeyCode.E)) { OverlayColorController.ChangeShowState(); } if (Input.GetKeyDown(KeyCode.KeypadMinus)) { OverlayColorController.DecreaseOpacity(); } if (Input.GetKeyDown(KeyCode.KeypadPlus)) { OverlayColorController.IncreaseOpacity(); } }
void SetPortalProgress(float progress) { currentProgress = 1 - progress; rend.material.SetFloat("FillLevelA", currentProgress); rend.material.SetFloat("FillLevelB", 0); if (currentProgress <= 0) { EventCoordinator.TriggerEvent(EventName.System.Victory(), GameMessage.Write().WithCoordinates(transform.position)); } }
void Update() { if (Input.GetKeyDown(KeyCode.W)) { AddDir(Vector2.up); } if (Input.GetKeyUp(KeyCode.W)) { RemoveDir(Vector2.up); } if (Input.GetKeyDown(KeyCode.A)) { AddDir(Vector2.left); } if (Input.GetKeyUp(KeyCode.A)) { RemoveDir(Vector2.left); } if (Input.GetKeyDown(KeyCode.S)) { AddDir(Vector2.down); } if (Input.GetKeyUp(KeyCode.S)) { RemoveDir(Vector2.down); } if (Input.GetKeyDown(KeyCode.D)) { AddDir(Vector2.right); } if (Input.GetKeyUp(KeyCode.D)) { RemoveDir(Vector2.right); } if (Input.GetKeyDown(KeyCode.Space)) { //start channeling input EventCoordinator.TriggerEvent(EventName.Input.Player.StartChannelingPortal(), GameMessage.Write().WithCoordinates(transform.position)); } if (Input.GetKeyUp(KeyCode.Space)) { //stop channeling input EventCoordinator.TriggerEvent(EventName.Input.Player.StopChannelingPortal(), GameMessage.Write().WithCoordinates(transform.position)); } if (Input.GetKeyDown(KeyCode.F)) { //open chest EventCoordinator.TriggerEvent(EventName.Input.Player.OpenChest(), GameMessage.Write().WithCoordinates(transform.position)); } if (Input.GetMouseButtonDown(0)) { Vector3 coord = Camera.main.ScreenToWorldPoint(Input.mousePosition); EventCoordinator.TriggerEvent(EventName.Input.Player.ThrowLoot(), GameMessage.Write().WithCoordinates(transform.position).WithTargetCoordinates(coord)); } }
public void Open() { renderer.sprite = open; if (!isOpen) { GoblinLootCoordinator.IncreaseLoot(1); EventCoordinator.TriggerEvent(EventName.System.Economy.ChestWasOpened(), GameMessage.Write().WithChest(this)); EventCoordinator.TriggerEvent(EventName.System.Economy.AmountLootedChanged(), GameMessage.Write().WithIntMessage(GoblinLootCoordinator.GetLootAmount())); } isOpen = true; }
void OnSwipe(bool swipedRight) { CardData cardData = GetComponent <Card>().cardData; if (swipedRight) { EventCoordinator.TriggerEvent(EventName.Input.Swipe.FinishRight(), GameMessage.Write().WithCardData(cardData)); } else { EventCoordinator.TriggerEvent(EventName.Input.Swipe.FinishLeft(), GameMessage.Write().WithCardData(cardData)); } }
void GetDamage(GameMessage msg) { if (gameObject.transform == msg.targetTransform) { EventCoordinator.TriggerEvent(EventName.System.Environment.MobKilled(), GameMessage.Write().WithTargetTransform(gameObject.transform)); onDie.Invoke(); Destroy(gameObject); Transform blood = Instantiate(bloodPrefab, transform.position, Quaternion.identity); blood.parent = transform.parent; } }
void OnLootThrow(GameMessage msg) { if (GoblinLootCoordinator.HasLoot()) { GameObject newThrown = Instantiate(lootPrefab); newThrown.transform.position = msg.coordinates; newThrown.GetComponent <LootFly>().ThrowAt(msg.targetCoordinates); GoblinLootCoordinator.DecreaseLoot(1); //Debug.Log("target coords: " + msg.targetCoordinates); newThrown.GetComponentInChildren <SpriteRenderer>().sprite = itemSprites[Random.Range(0, itemSprites.Count)]; newThrown.transform.parent = GoblinLootCoordinator.Instance.transform; EventCoordinator.TriggerEvent(EventName.System.Economy.AmountLootedChanged(), GameMessage.Write().WithIntMessage(GoblinLootCoordinator.GetLootAmount())); } }
void OnGotDamage(GameMessage msg) { if (transform == msg.targetTransform) { health -= 1; EventCoordinator.TriggerEvent(EventName.System.Environment.GoblinGotDamage(), GameMessage.Write()); if (health == 0) { EventCoordinator.TriggerEvent(EventName.System.Environment.GoblinDied(), GameMessage.Write().WithTargetTransform(gameObject.transform)); } } }
public static CardData GetNextCardData() { if (Instance.cards.Count > Instance.currentCardIndex) { CardData nextcard = Instance.cards[Instance.currentCardIndex]; Instance.currentCardIndex++; Debug.Log("next card index is " + Instance.currentCardIndex); return(nextcard); } else { EventCoordinator.TriggerEvent(EventName.System.EndGame(), GameMessage.Write()); //Debug.LogError("Out of cards, not enough cards in list!"); return(null); } }
void OnCardsImported(GameMessage msg) { CardCoordinator.RandomizeCardsForPlayer(); float wdAmount = 0; float tapeAmount = 0; if (PlayerPrefs.GetInt("Ending1") > 0) { wdAmount += GameConstantsBucket.EndingResourceAward; } if (PlayerPrefs.GetInt("Ending2") > 0) { tapeAmount += GameConstantsBucket.EndingResourceAward; } EventCoordinator.TriggerEvent(EventName.System.Economy.ModifyResource(), GameMessage.Write().WithFloatMessage(tapeAmount).WithResource(ResourceItem.Ductape)); EventCoordinator.TriggerEvent(EventName.System.Economy.ModifyResource(), GameMessage.Write().WithFloatMessage(wdAmount).WithResource(ResourceItem.Wd)); }
void Update() { if (moveDirection.magnitude > 0) { previousMoveDirection = moveDirection; isMoving = true; if (speed < 1f) { speed += Time.deltaTime * 4f; } } else { if (speed > 0) { speed -= Time.deltaTime * 4f; } if (speed <= 0) { isMoving = false; } } if (speed > 0) { float actual = Easing.Quadratic.Out(speed); Vector3 moveTo = previousMoveDirection; moveTo = CheckForObjects(moveTo); moveTo = CheckNavmesh(moveTo); moveTo = moveTo * actual * baseSpeed; transform.Translate(moveTo); } if (isMoving != stopTrigger) { stopTrigger = isMoving; if (!isMoving) { speed = 0; EventCoordinator.TriggerEvent(EventName.Input.Player.MovementStopped(), GameMessage.Write()); } } }
void OnEndGame(GameMessage msg) { if (correctTape * GameConstantsBucket.EndingResourceMultiplier > correctWd) { EventCoordinator.TriggerEvent(EventName.System.Story.UnlockEnding(), GameMessage.Write().WithIntMessage(0)); } else { if (correctTape < correctWd * GameConstantsBucket.EndingResourceMultiplier) { EventCoordinator.TriggerEvent(EventName.System.Story.UnlockEnding(), GameMessage.Write().WithIntMessage(1)); } else { if (Mathf.Abs(correctTape - correctWd) < GameConstantsBucket.EndingResourceDifference) { EventCoordinator.TriggerEvent(EventName.System.Story.UnlockEnding(), GameMessage.Write().WithIntMessage(2)); } } } }
void GenerateObject() { for (int i = 0; i < count; i++) { mobIndex = UnityEngine.Random.Range(0, 4); if (mobList[mobIndex] == null) { continue; } var pos = GetRandomPoint(); NavMeshHit navHit; if (NavMesh.SamplePosition(pos, out navHit, 1.0f, NavMesh.AllAreas)) { GameObject tmp = Instantiate(mobList[mobIndex]); tmp.transform.SetParent(transform.parent); tmp.gameObject.transform.position = navHit.position; EventCoordinator.TriggerEvent(EventName.System.Environment.CreateMob(), GameMessage.Write().WithTargetTransform(tmp.transform)); } } }
//There has to be an EventCoordinator in the scene to call triggers! public void ExampleTriggerEvent() { EventCoordinator.TriggerEvent(EventName.UI.ExampleEvent(), GameMessage.Write().WithStringMessage("Example Button Clicked").WithIntMessage(size)); }
void OnEndGame(GameMessage msg) { EventCoordinator.TriggerEvent(EventName.UI.ShowPostScreen(), GameMessage.Write()); }
void OnModifyResource(GameMessage msg) { PlayerDataBucket.AddResource(msg.floatMessage, msg.resourceItem); EventCoordinator.TriggerEvent(EventName.System.Economy.ResourceChanged(), GameMessage.Write().WithResource(msg.resourceItem).WithFloatMessage(PlayerDataBucket.GetResource(msg.resourceItem))); }
public void OnButtonClick() { EventCoordinator.TriggerEvent(EventName.Input.StartGame(), GameMessage.Write()); }
void OnPlayerEliminated(GameMessage msg) { EventCoordinator.TriggerEvent(EventName.System.Player.PostElimination(), msg); }
void OnSwipeLeft(GameMessage msg) { EventCoordinator.TriggerEvent(EventName.Input.CardSelected(), GameMessage.Write().WithCardData(msg.cardData).WithResource(LeftSwipeResource)); StartCoroutine(DelayCreateCard()); }
public void TryAgainButtonClick() { EventCoordinator.TriggerEvent(EventName.Input.ResetGame(), GameMessage.Write()); }
void OnGameStart(GameMessage msg) { EventCoordinator.TriggerEvent(EventName.System.MatchStarted(), msg); }
void MatchStarted(GameMessage msg) { EventCoordinator.TriggerEvent(EventName.System.CardsImported(), msg); }