Exemple #1
0
        public override void OnAttached(AbstractEntity entity)
        {
            Debug.Assert(entity.HasAttribute(CommonNames.Kind) && entity.GetString(CommonNames.Kind) == "player");

            base.OnAttached(entity);

            Entity playerConstants = Game.Instance.Simulation.EntityManager["player_constants"];

            if (entity.HasString(CommonNames.PlayerName))
            {
                entity.GetStringAttribute(CommonNames.PlayerName).ValueChanged += PlayerNameChanged;
            }
            if (entity.HasInt(CommonNames.GamePadIndex))
            {
                entity.GetIntAttribute(CommonNames.GamePadIndex).ValueChanged += GamePadIndexChanged;
            }
            if (entity.HasFloat(CommonNames.Health))
            {
                entity.GetFloatAttribute(CommonNames.Health).ValueChanged += HealthChanged;
            }
            if (playerConstants.HasFloat(CommonNames.MaxHealth))
            {
                playerConstants.GetFloatAttribute(CommonNames.MaxHealth).ValueChanged += MaxHealthChanged;
            }
            if (entity.HasFloat(CommonNames.Energy))
            {
                entity.GetFloatAttribute(CommonNames.Energy).ValueChanged += EnergyChanged;
            }
            if (playerConstants.HasFloat(CommonNames.MaxEnergy))
            {
                playerConstants.GetFloatAttribute(CommonNames.MaxEnergy).ValueChanged += MaxEnergyChanged;
            }
            if (entity.HasInt(CommonNames.Frozen))
            {
                entity.GetIntAttribute(CommonNames.Frozen).ValueChanged += FrozenChanged;
            }
            entity.GetIntAttribute(CommonNames.Lives).ValueChanged += LivesChanged;

            Game.Instance.Simulation.CurrentUpdateQueue.AddUpdate(new AddRenderableUpdate((Renderable)Updatable));
        }
Exemple #2
0
        public override void OnDetached(AbstractEntity entity)
        {
            base.OnDetached(entity);

            if (entity.HasFloat(CommonNames.Health))
            {
                entity.GetFloatAttribute(CommonNames.Health).ValueChanged -= HealthChanged;
            }
            if (entity.HasInt(CommonNames.Frozen))
            {
                entity.GetIntAttribute(CommonNames.Frozen).ValueChanged -= FrozenChanged;
            }
        }
Exemple #3
0
        public override void OnDetached(AbstractEntity entity)
        {
            Game.Instance.Simulation.CurrentUpdateQueue.AddUpdate(new RemoveRenderableUpdate((Renderable)Updatable));

            Entity playerConstants = Game.Instance.Simulation.EntityManager["player_constants"];

            if (entity.HasString(CommonNames.PlayerName))
            {
                entity.GetStringAttribute(CommonNames.PlayerName).ValueChanged -= PlayerNameChanged;
            }
            if (entity.HasInt(CommonNames.GamePadIndex))
            {
                entity.GetIntAttribute(CommonNames.GamePadIndex).ValueChanged -= GamePadIndexChanged;
            }
            if (entity.HasFloat(CommonNames.Health))
            {
                entity.GetFloatAttribute(CommonNames.Health).ValueChanged -= HealthChanged;
            }
            if (playerConstants != null && playerConstants.HasFloat(CommonNames.MaxHealth))
            {
                playerConstants.GetFloatAttribute(CommonNames.MaxHealth).ValueChanged -= MaxHealthChanged;
            }
            if (entity.HasFloat(CommonNames.Energy))
            {
                entity.GetFloatAttribute(CommonNames.Energy).ValueChanged -= EnergyChanged;
            }
            if (playerConstants != null && playerConstants.HasFloat(CommonNames.MaxEnergy))
            {
                playerConstants.GetFloatAttribute(CommonNames.MaxEnergy).ValueChanged -= MaxEnergyChanged;
            }
            if (entity.HasInt(CommonNames.Frozen))
            {
                entity.GetIntAttribute(CommonNames.Frozen).ValueChanged -= FrozenChanged;
            }
            entity.GetIntAttribute(CommonNames.Lives).ValueChanged -= LivesChanged;

            base.OnDetached(entity);
        }