/// <summary> /// 选择材料类型 /// </summary> /// <param name="ie"></param> private void MaterialsChooseType(IEventParam ie) { if (ie is ChooseMaterialType) { materialType = (ie as ChooseMaterialType).value; } }
/// <summary> /// 设置激活的种类 /// </summary> /// <param name="ie"></param> private void SetActivateType(IEventParam ie) { if (ie is ActivateTypeParam) { type = (ie as ActivateTypeParam).value; } }
void TargetUnit(IEventParam parameters) { TargetUnitEventParam eventParams = (TargetUnitEventParam)parameters; GameManager.instance.currentTarget = eventParams.unit; Debug.Log("Target unit : " + eventParams.unit); }
/// <summary> /// 获取所有的资源 /// </summary> private void GetAllResources(IEventParam ie) { if (ie is GameObjectListParam) { allResources = (ie as GameObjectListParam).value; } }
private void OnRoundEnd(IEventParam e) { r.enabled = false; i.enabled = false; EventManager.Instance.Raise("round-prepare", null); }
public void Raise(string eventName, IEventParam eventParam) { if (events.TryGetValue(eventName, out Action <IEventParam> thisEvent)) { thisEvent.Invoke(eventParam); } }
/// <summary> /// 检测玩家是否能够被控制 /// </summary> /// <param name="ie"></param> private void MonitorCanBeControled(IEventParam ie) { if (ie is BooleanParam) { canBeControled = (ie as BooleanParam).value; } }
/// <summary> /// 初次展示任务面板 /// </summary> private void ShowTaskPanel(IEventParam ie) { AllUIElementInMainPanel(false); AllUIElementInTaskPanel(true); //控制主角取消控制 EventManager.Instance.DispatchEvent(EventEnum.PlayerCanBeControled, new BooleanParam(false)); }
private void SelcetWhichChangeColor(IEventParam ie) { if (ie is BooleanParam) { if (hasActivatedType.Contains(type)) { return; } switch (type) { case ActivateType.ACTIVATE: hasActivatedType.Add(type); ChangeColor(ActivateBtn); break; case ActivateType.COLLECT: //如果机器人没有激活是不允许收集功能激活的 if (!hasActivatedType.Contains(ActivateType.ACTIVATE)) { return; } if (UIView.ControlRobotStartUpAndSayHi != 3) { return; } hasActivatedType.Add(type); ChangeColor(CollentBtn); break; } } }
/// <summary> /// 是否展示Bot按钮 /// </summary> /// <param name="ie"></param> private void ShowBotBtn(IEventParam ie) { if (ie is BooleanParam) { isShowBotBtn = (ie as BooleanParam).value; BotBtn.transform.parent.gameObject.SetActive(isShowBotBtn); } }
private void OnRoundPrepare(IEventParam e) { r.Reset(); m.Clean(); r.enabled = true; i.enabled = true; }
private void RobotCanCollectResource(IEventParam ie) { if (ie is BooleanParam) { Debug.Log(RobotCanCollect); RobotCanCollect = (ie as BooleanParam).value; } }
private void OnRequestScene(IEventParam e) { IntParam p = (IntParam)e; if (p.val > -1) { Requested = p.val; } }
/// <summary> /// 设置六边形的数量 /// </summary> private void SetHexagonNum(IEventParam ie) { if (ie is IntParam) { hexagonNum += (ie as IntParam).value; HexagonNumText.text = hexagonNum.ToString(); ShowBuildBtn(); } }
/// <summary> /// Triggers an event. /// </summary> /// <param name="eventName">Event name.</param> /// <param name="eventParam">Event parameter.</param> public static void TriggerEvent(string eventName, IEventParam eventParam) { Action <IEventParam> thisEvent = null; if (Instance._eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(eventParam); } }
/// <summary> /// 设置三边形的数量 /// </summary> private void SetTriangleNum(IEventParam ie) { if (ie is IntParam) { triangleNum += (ie as IntParam).value; TriangleNumText.text = triangleNum.ToString(); ShowBuildBtn(); } }
/** * Trigger the event with params */ public static void TriggerEvent(string eventName, IEventParam parameters) { Action <IEventParam> e = null; if (instance.eventDictionary.TryGetValue(eventName, out e)) { e.Invoke(parameters); } }
/// <summary> /// 游戏失败 /// </summary> private void Failure(IEventParam ie) { EndBlackBG.gameObject.SetActive(true); EndBlackBG.DOFade(1, 0.5f).OnComplete(delegate { StartCoroutine(EndText.Print("Sorry, you did not build the shelter successfully before you run out of your energy. Please try again.", 0.1f, delegate { })); }); }
/// <summary> /// 显示隐藏资源 /// </summary> private void ShowOrHideResources(IEventParam ie) { if (ie is BooleanParam) { bool isShow = (ie as BooleanParam).value; foreach (var v in TotalResources) { v.SetActive(isShow); } } }
void CancelCast(IEventParam parameters) { castBar.GetComponent <CastBar>().ResetBar(); Spell spell = GameManager.instance.currentCastingSpell; if (spell != null) { manaBar.GetComponent <ManaBar>().GainMana(spell.manaCost); GameManager.instance.currentCastingSpell = null; } }
/// <summary> /// Update Hud on player complete level event. /// </summary> void OnPlayerCompleteLevel(IEventParam eventParam) { hudWindow.transform.localScale = Vector3.zero; hudWindow.SetActive(true); SoundManager.instance.PlaySoundByName("level_complete"); Sequence mySequence = DOTween.Sequence(); mySequence.Append(hudWindow.transform.DOScale(1f, 1.5f).SetEase(Ease.OutExpo)); mySequence.AppendInterval(10); mySequence.Append(hudWindow.transform.DOScale(0f, 1f).SetEase(Ease.InExpo)); }
void FinishedCast(IEventParam parameters) { Debug.Log("FinishedCast was triggered."); GameManager.instance.currentCastingSpell.Behaviour(); GameManager.instance.currentCastingSpell = null; GameManager.instance.currentCastingTarget = null; if (GameManager.instance.precastedSpell != null) { TriggerSpell(GameManager.instance.precastedSpell); } }
void UnitDied(IEventParam parameters) { UnitDiedEventParam eventParams = (UnitDiedEventParam)parameters; GameObject unit = eventParams.unit; Debug.Log("Unit " + unit.GetComponent <HealthBar>().unitName + " died."); if (!GameManager.instance.IsCurrentCastingTargetAlive()) { CancelCast(null); } }
/// <summary> /// 激活机器人的收集的功能 /// </summary> private void SetCollect(IEventParam ie) { if (ie is BooleanParam) { bool m_value = (ie as BooleanParam).value; IsCollect = m_value; IsFollowing = !m_value; if (IsCollect) { EventManager.Instance.DispatchEvent(EventEnum.RobotCollectNextResource, ie); } } }
/// <summary> /// 机器人开始收集资源 /// </summary> private void RobotStartCollectResource(IEventParam ie) { if (allResources.Count <= 0) { return; } currentCollectingResource = GetNearestPosition(); float length = Vector2.Distance(transform.position, currentCollectingResource.transform.position); float timer = length / speed; Debug.Log(TAG + "robot move time = " + timer); transform.DOMove(currentCollectingResource.transform.position, timer).SetEase(Ease.Linear); }
IEnumerator Tick(string tickName, string completeName, IEventParam onTick, IEventParam onComplete) { while (ClockTime > 0 && running) { EventManager.Instance.Raise(tickName, onTick); yield return(new WaitForSeconds(1)); ClockTime--; } if (running) { running = false; EventManager.Instance.Raise(completeName, onComplete); } }
/// <summary> /// 从列表里移除资源 /// </summary> private void RemoveResourceFromList(IEventParam ie) { if (ie is GameObjectParam) { GameObject obj = (ie as GameObjectParam).value; if (TotalResources.Contains(obj)) { TotalResources.Remove(obj); UpdateRobotResourcesPositionList(); } else { Debug.LogWarning(TAG + "TotalResources dont contains " + obj.name); } } }
/// <summary> /// 执行事件 /// </summary> public void DispatchEvent(EventEnum ec, IEventParam ie) { List <mEvent> lists = null; if (events.TryGetValue(ec, out lists)) { foreach (var v in lists) { v(ie); } } else { Debug.LogWarning(TAG + "events dont contain " + ec); } }
/// <summary> /// Raises the pickup coin event. /// </summary> /// <param name="eventParam">Event parameter.</param> void OnPickupCoin(IEventParam eventParam) { SoundManager.instance.PlaySoundByName("coin_pickup"); EventPlayerPickUpCoin eventPickup = (EventPlayerPickUpCoin)eventParam; Vector3 screenPos = UnityEngine.Camera.main.WorldToScreenPoint(eventPickup.position); GameObject coin = Instantiate(coinUiPrefab, screenPos, Quaternion.identity); coin.transform.SetParent(gameObject.transform); coin.transform.DOMove(coinText.transform.position, 1f) .SetEase(Ease.OutExpo) .OnComplete(() => { coinText.text = String.Format("{0:00000}", eventPickup.totalCoins); Destroy(coin); _animation.Play("hud_coins_inc"); }); }
private void SetEnergyValue(IEventParam ie) { if (ie is FloatParam) { model.EnergyValue = model.EnergyValue - (ie as FloatParam).value; Debug.Log("Energy = " + model.EnergyValue); if (model.EnergyValue <= 0) { model.EnergyValue = 0; if (!UIView.hasHouse) { EventManager.Instance.DispatchEvent(EventEnum.GameFailure, null); } } else if (model.EnergyValue >= 100) { model.EnergyValue = 100; } view.SetEneryImageValue(model.EnergyValue * 0.01f); } }