示例#1
0
 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>();
 }
示例#3
0
        void Awake()
        {
            _characterTargetRotation = _pivotTr.localRotation;
            _cameraTargetRotation    = _camTr.localRotation;
            MessageKit <float> .addObserver(Messages.PlayerViewRotated, ChangeRotation);

            // don't forget about keyboard turning
        }
示例#4
0
        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);
        }
示例#5
0
 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);
 }
示例#6
0
 void Awake()
 {
     SetupSlots();
     if (_startDisabled)
     {
         SetStatus(false, true);
     }
     MessageKit.addObserver(Messages.PlayerNewGame, ClearHotbar);
 }
示例#7
0
 private void ClearTargetOptions()
 {
     MessageKit.post(Messages.OptionsChanged);
     _inputMapper.RemoveAllEventListeners();
     for (int i = 0; i < _targetOptions.Count; i++)
     {
         ItemPool.Despawn(_targetOptions[i]);
     }
     _targetOptions.Clear();
 }
示例#8
0
 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>(),
     };
 }
示例#9
0
 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;
 }
示例#10
0
        //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);
            });
        }
示例#11
0
        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();
        }
示例#12
0
 public void OnSystemUpdate(float dt)
 {
     if (_list == null)
     {
         _list = EntityController.GetComponentArray <ModifiersContainer>();
     }
     if (_list != null)
     {
         _list.Run(_del);
         MessageKit.post(Messages.ModifiersUpdated);
     }
 }
示例#13
0
 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);
 }
示例#14
0
 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);
 }
示例#15
0
        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));
        }
示例#16
0
        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();
            }
        }
示例#17
0
 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);
 }
示例#18
0
        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;
            }
        }
示例#19
0
        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();
            }
        }
示例#20
0
        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();
            }
        }
示例#21
0
        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;
            }
        }
示例#22
0
 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();
 }
示例#23
0
        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();
        }
示例#24
0
 public virtual void Teleport(Vector3 location)
 {
     Tr.position = FindFloorPoint(location);
     MessageKit.post(Messages.PlayerTeleported);
 }
示例#25
0
        //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);
        }
示例#26
0
        void Awake()
        {
            MessageKit <UINotificationWindow.Msg> .addObserver(Messages.MessageLog, AddNewMessage);

            MessageKit.addObserver(Messages.PlayerNewGame, StartNewGame);
        }
示例#27
0
 public virtual void NewGame()
 {
     Player.DefaultCurrencyHolder.ChangeValue(100);
     MessageKit.post(Messages.PlayerNewGame);
 }
示例#28
0
 public override void Dispose()
 {
     base.Dispose();
     MessageKit.removeObserver(Messages.PauseChanged, CheckPause);
 }
示例#29
0
 public PhysicsMoverSystem()
 {
     MessageKit.addObserver(Messages.PauseChanged, CheckPause);
 }
示例#30
0
 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);
 }