Ejemplo n.º 1
0
        public override void Set(Character.Character character)
        {
            if (Character != null)
            {
                Unset(Character);
            }

            base.Set(character);

            _oldCharacterName                        = character.name;
            character.name                           = "Player";
            character.IsPlayerControlled             = true;
            character.OnPrimaryWeaponChanged        += OnPrimaryWeaponChanged;
            character.OnStatusAdded                 += OnStatusAdded;
            character.OnStatusRemoved               += OnStatusRemoved;
            character.OnStatusReset                 += OnStatusReset;
            character.Context.OnKnownEnemiesUpdated += OnKnownEnemiesUpdated;

            var health = character.GetStat(Roguelike.Character.Stats.StatType.Health);

            if (health != null)
            {
                health.OnValueChanged    += OnHealthChanged;
                health.OnMaxValueChanged += OnMaxHealthChanged;

                OnMaxHealthChanged(health, 0);
                OnHealthChanged(health, 0);
            }

            var mana = character.GetStat(Roguelike.Character.Stats.StatType.Mana);

            if (mana != null)
            {
                mana.OnValueChanged    += OnManaChanged;
                mana.OnMaxValueChanged += OnMaxManaChanged;

                OnMaxManaChanged(mana, 0);
                OnManaChanged(mana, 0);
            }

            if (Character.PrimaryWeapon != null)
            {
                OnPrimaryWeaponChanged(Character.PrimaryWeapon, null);
            }

            var cameraBrain = Camera.main.GetComponent <CinemachineBrain>();

            if (cameraBrain != null && cameraBrain.ActiveVirtualCamera != null)
            {
                cameraBrain.ActiveVirtualCamera.LookAt = character.transform;
                cameraBrain.ActiveVirtualCamera.Follow = character.transform;
            }
        }
Ejemplo n.º 2
0
        public override void Unset(Character.Character character)
        {
            base.Unset(character);

            if (!string.IsNullOrEmpty(_oldCharacterName))
            {
                character.name    = _oldCharacterName;
                character.GodMode = false;
            }
            character.IsPlayerControlled             = false;
            character.OnPrimaryWeaponChanged        -= OnPrimaryWeaponChanged;
            character.OnStatusAdded                 -= OnStatusAdded;
            character.OnStatusRemoved               -= OnStatusRemoved;
            character.OnStatusReset                 -= OnStatusReset;
            character.Context.OnKnownEnemiesUpdated -= OnKnownEnemiesUpdated;

            var health = character.GetStat(Roguelike.Character.Stats.StatType.Health);

            if (health != null)
            {
                health.OnValueChanged    -= OnHealthChanged;
                health.OnMaxValueChanged -= OnMaxHealthChanged;
            }

            var mana = character.GetStat(Roguelike.Character.Stats.StatType.Mana);

            if (mana != null)
            {
                mana.OnValueChanged    -= OnManaChanged;
                mana.OnMaxValueChanged -= OnMaxManaChanged;
            }

            var cameraBrain = Camera.main.GetComponent <CinemachineBrain>();

            if (cameraBrain != null && cameraBrain.ActiveVirtualCamera != null)
            {
                cameraBrain.ActiveVirtualCamera.LookAt = null;
                cameraBrain.ActiveVirtualCamera.Follow = null;
            }
        }