Beispiel #1
0
        public override void OnAttached(AbstractEntity arrow)
        {
            this.arrow     = arrow as Entity;
            this.island    = null;
            this.constants = Game.Instance.Simulation.EntityManager["player_constants"];

//            this.player = Game.Instance.Simulation.EntityManager[arrow.GetString("player")];

            // register island change handler
            arrow.GetStringAttribute("island").ValueChanged += OnIslandChanged;

            arrow.AddQuaternionAttribute(CommonNames.Rotation, Quaternion.Identity);

            relPos = constants.GetFloat("arrow_island_min_distance_factor");

            (arrow as Entity).OnUpdate += OnUpdate;
        }
Beispiel #2
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));
        }
Beispiel #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);
        }