void Awake() { _startingRotation = transform.localRotation; MessageKit.addObserver(Messages.PlayerMoving, ResetView); MessageKit.addObserver(Messages.PlayerRotated, ResetView); MessageKit.addObserver(Messages.OptionsChanged, SetOptions); }
public PhysicsMoverSystem() { _rbDel = CheckPaused; _moverDel = HandleVelocityMover; MessageKit.addObserver(Messages.PauseChanged, CheckPause); _moverList = EntityController.GetTemplateList <RigidbodyMoverTemplate>(); }
void Awake() { _characterTargetRotation = _pivotTr.localRotation; _cameraTargetRotation = _camTr.localRotation; MessageKit <float> .addObserver(Messages.PlayerViewRotated, ChangeRotation); // don't forget about keyboard turning }
public virtual void Teleport(Vector3 location, Quaternion rotation) { Tr.rotation = rotation; Tr.position = FindFloorPoint(location); MessageKit <float> .post(Messages.PlayerViewRotated, rotation.eulerAngles.y); MessageKit.post(Messages.PlayerTeleported); }
public void OnCreate(PrefabEntity entity) { Tr = transform; _cameraOffset = Tr.localPosition; _nativeRotation = Tr.localRotation; _nativeRotation.eulerAngles = Vector3.up * Tr.localEulerAngles.y; HoldStartPosition = _holdTransform.localPosition; MessageKit.addObserver(Messages.OptionsChanged, SetOptions); }
void Awake() { SetupSlots(); if (_startDisabled) { SetStatus(false, true); } MessageKit.addObserver(Messages.PlayerNewGame, ClearHotbar); }
private void ClearTargetOptions() { MessageKit.post(Messages.OptionsChanged); _inputMapper.RemoveAllEventListeners(); for (int i = 0; i < _targetOptions.Count; i++) { ItemPool.Despawn(_targetOptions[i]); } _targetOptions.Clear(); }
public CullingSystem() { MessageKit.addObserver(Messages.LevelClear, ClearList); MessageKit.addObserver(Messages.PlayerReachedDestination, UpdatePlayerPosition); MessageKit.addObserver(Messages.PlayerTeleported, UpdatePlayerPosition); _list = new[] { new BufferedList <Point3>(), new BufferedList <Point3>(), }; }
protected virtual void Awake() { Player.Tr = transform; Tr = transform; Player.Currency = _currency; MessageKit.addObserver(Messages.LoadingFinished, EnablePlayer); Entity = Entity.New("PlayerController"); Entity.Add(new LabelComponent("PlayerController")); Entity.Tr = Tr; }
//public void CloseClassMenu() { // FadeIn(IndexMain); // FadeOut(IndexClass); //} public void StartNewGame() { CloseMainMenu(0); if (_menuMusic != null && _menuMusic.isPlaying) { TimeManager.StartUnscaled(FadeMusic(false, 0.2f)); } TimeManager.PauseFor(_transitionLength * 0.25f, true, () => { MessageKit.post(Messages.StartNewGame); }); }
void Awake() { _camTr = transform; _rotationX = _rotationY = 0; //_nativeRotation = _camTr.localRotation; //_nativeRotation.eulerAngles = Vector3.up * _camTr.localEulerAngles.y; MessageKit <float> .addObserver(Messages.PlayerViewRotated, ChangeRotation); MessageKit.addObserver(Messages.PlayerTeleported, ForceMoveUpdate); InitSprings(); BuildEventDictionary(); }
public void OnSystemUpdate(float dt) { if (_list == null) { _list = EntityController.GetComponentArray <ModifiersContainer>(); } if (_list != null) { _list.Run(_del); MessageKit.post(Messages.ModifiersUpdated); } }
private void CloseMainMenu(int index) { if (_animating != null) { return; } _animating = _canvasGroup.FadeTo(0, _transitionLength * 0.5f, EasingTypes.SinusoidalIn, true, Tween.TweenRepeat.Once, () => _animating = null); _canvasGroup.interactable = _canvasGroup.blocksRaycasts = false; _saveLoad.Close(); Game.RemovePauseAndLockCursor("UIMainMenu"); MessageKit <GameObject> .post(Messages.MenuClosed, gameObject); }
public static void SetDataInt(string key, int data) { if (Player.Data.DataInt.ContainsKey(key)) { Player.Data.DataInt[key] = data; } else { Player.Data.DataInt.Add(key, data); } MessageKit <string> .post(Messages.GlobalDataChanged, key); }
public void Show(params System.Object[] param) { string message; try { message = string.Format(_message, param); } catch (FormatException e) { Debug.LogFormat("Received {0} and {1} but threw {2}", _message, param.Length, e); return; } MessageKit <UINotificationWindow.Msg> .post(Messages.MessageLog, new UINotificationWindow.Msg(message, _messageColor)); }
public void HandleGlobal(CollisionEvent msg) { _eventLog.Add(msg); if (msg.Hit < 0) { msg.Hit = CollisionResult.Hit; for (int h = 0; h < _globalHandlers.Count; h++) { msg.Hit = MathEx.Min(_globalHandlers[h].CheckHit(msg), msg.Hit); } } if (msg.Hit <= 0) { return; } var criticalHit = msg.Target.Entity.Get <CriticalHitCollider>(); if (criticalHit != null && criticalHit.IsCritical(msg.Target.Tr, msg.HitPoint)) { msg.Hit = CollisionResult.CriticalHit; } var ae = new ActionEvent(msg.Origin.Entity, msg.Target.Entity, msg.HitPoint, msg.HitNormal == Vector3.zero ? Quaternion.identity :Quaternion.LookRotation(msg.HitNormal), ActionState.Impact); var origin = msg.Origin.Entity.FindTemplate <CharacterTemplate>(); World.Get <RulesSystem>().Post(new ImpactEvent(msg, ae.Action, origin, msg.Target.Entity.FindTemplate <CharacterTemplate>())); msg.Origin.Post(ae); if (!_collisionMessage) { return; } _collisionString.Clear(); _collisionString.Append(msg.Origin.GetName()); if (msg.Hit == CollisionResult.CriticalHit) { _collisionString.Append(" critically hit "); } else { _collisionString.Append(" struck "); } _collisionString.Append(msg.Target.GetName()); MessageKit <UINotificationWindow.Msg> .post(Messages.MessageLog, new UINotificationWindow.Msg( _collisionString.ToString(), "", Color.blue)); if (msg.Target.Entity.HasComponent <DespawnOnCollision>()) { msg.Target.Entity.Destroy(); } }
public void SetupActor(CharacterNode actor) { if (_actor != null) { _actor.Entity.RemoveObserver(this); MessageKit.removeObserver(Messages.ModifiersUpdated, UpdateMods); } _actor = actor; if (_actor == null) { return; } _actor.Entity.AddObserver(this); MessageKit.addObserver(Messages.ModifiersUpdated, UpdateMods); }
public static void BroadcastMessage(this LockType lockType, string id, bool locked) { switch (lockType) { case LockType.Switch: MessageKit <string> .post(Messages.SwitchToggle, id); break; case LockType.Key: MessageKit <string> .post(locked?Messages.Locked : Messages.Unlocked, id); break; } }
public void HandleGlobal(CollisionEvent msg) { _eventLog.Add(msg); if (msg.Hit < 0) { msg.Hit = CollisionResult.Hit; for (int h = 0; h < _globalHandlers.Count; h++) { msg.Hit = MathEx.Min(_globalHandlers[h].CheckHit(msg), msg.Hit); } } if (msg.Hit <= 0) { return; } var criticalHit = msg.Target.Entity.Get <CriticalHitCollider>(); if (criticalHit != null && criticalHit.IsCritical(msg.Target.Tr, msg.HitPoint)) { msg.Hit = CollisionResult.CriticalHit; } var origin = msg.Origin.Entity.FindTemplate <CharacterTemplate>(); var target = msg.Target.Entity.FindTemplate <CharacterTemplate>(); PostImpactEvent(origin, target, null, msg.HitPoint, msg.HitNormal); if (!_collisionMessage) { return; } _collisionString.Clear(); _collisionString.Append(msg.Origin.GetName()); if (msg.Hit == CollisionResult.CriticalHit) { _collisionString.Append(" critically hit "); } else { _collisionString.Append(" struck "); } _collisionString.Append(msg.Target.GetName()); MessageKit <UINotificationWindow.Msg> .post(Messages.MessageLog, new UINotificationWindow.Msg( _collisionString.ToString(), "", Color.blue)); if (msg.Target.Entity.HasComponent <DespawnOnCollision>()) { msg.Target.Entity.Destroy(); } }
public void HandleGlobal(CollisionEvent msg) { _eventLog.Add(msg); if (msg.Hit < 0) { msg.Hit = CollisionResult.Hit; for (int h = 0; h < _globalHandlers.Count; h++) { msg.Hit = MathEx.Min(_globalHandlers[h].CheckHit(msg), msg.Hit); } } var blockDamage = msg.Target.Entity.Get <BlockDamage>(); if (blockDamage != null) { for (int h = 0; h < blockDamage.CollisionHandlers.Count; h++) { msg.Hit = MathEx.Min(blockDamage.CollisionHandlers[h](msg), msg.Hit); } } if (msg.Hit <= 0) { return; } var actionStateEvent = new ActionStateEvent(msg.Origin.Entity, msg.Target.Entity, msg.HitPoint, msg.HitNormal == Vector3.zero ? Quaternion.identity :Quaternion.LookRotation(msg.HitNormal), ActionStateEvents.Impact); msg.Source.PostAll(new ImpactEvent(msg, msg.Origin.Entity.FindNode <CharacterNode>(), msg.Target.Entity.FindNode <CharacterNode> ())); msg.Origin.Post(actionStateEvent); if (!_collisionMessage) { return; } _collisionString.Clear(); _collisionString.Append(msg.Origin.GetName()); _collisionString.Append(" struck "); _collisionString.Append(msg.Target.GetName()); MessageKit <UINotificationWindow.Msg> .post(Messages.MessageLog, new UINotificationWindow.Msg( _collisionString.ToString(), "", Color.blue)); if (msg.Target.Entity.HasComponent <DespawnOnCollision>()) { msg.Target.Entity.Destroy(); } }
public static void RemoveObserver(this LockType lockType, System.Action <string> delToggle, System.Action <string> delUnlocked, System.Action <string> delLocked) { switch (lockType) { case LockType.Switch: MessageKit <string> .removeObserver(Messages.SwitchToggle, delToggle); break; case LockType.Key: MessageKit <string> .removeObserver(Messages.Unlocked, delUnlocked); MessageKit <string> .removeObserver(Messages.Locked, delLocked); break; } }
public void OnSystemUpdate(float dt, float unscaledDt) { if (_allInputBlocked || LocalInput == null) { return; } CheckDebugInput(); if (LocalInput.GetButtonDown(PlayerControls.Menu)) { if (OnCancel != null) { CancelCurrent(); } else if (UIBasicMenu.OpenMenus.Count > 0) { UIBasicMenu.CloseAll(); } else if (Game.GameActive) { MessageKit.post(Messages.ToggleMainMenu); } } LocalInput.RunUpdate(); }
private void LoadFile(string path) { string text = FileUtility.ReadFile(path); if (string.IsNullOrEmpty(text)) { return; } var saveGame = JsonConvert.DeserializeObject <SerializedSaveGame>(text, Serializer.ConverterSettings); if (saveGame == null) { Debug.LogErrorFormat("Error deserializing save game {0}", path); return; } MessageKit.post(Messages.ToggleMainMenu); saveGame.Load(); }
public virtual void Teleport(Vector3 location) { Tr.position = FindFloorPoint(location); MessageKit.post(Messages.PlayerTeleported); }
//private void OpenScores(int index) { // FadeOut(IndexMain); // FadeIn(IndexHighScores); // UIScoreList.main.ListScores(); //} //public void CloseScores() { // FadeIn(IndexMain); // FadeOut(IndexHighScores); //} private void OpenPartyManagement(int index) { MessageKit.post(Messages.SetupNewGame); //FadeOut(IndexMain); //FadeIn(IndexClass); }
void Awake() { MessageKit <UINotificationWindow.Msg> .addObserver(Messages.MessageLog, AddNewMessage); MessageKit.addObserver(Messages.PlayerNewGame, StartNewGame); }
public virtual void NewGame() { Player.DefaultCurrencyHolder.ChangeValue(100); MessageKit.post(Messages.PlayerNewGame); }
public override void Dispose() { base.Dispose(); MessageKit.removeObserver(Messages.PauseChanged, CheckPause); }
public PhysicsMoverSystem() { MessageKit.addObserver(Messages.PauseChanged, CheckPause); }
private static void PauseChanged() { MessageKit.post(Messages.PauseChanged); //UnityEngine.Time.timeScale = Paused ? 0f : 1f; //UnityEngine.Time.fixedDeltaTime = 0.02f * Mathf.Clamp(UnityEngine.Time.timeScale, 0.00001f, 1); }