Exemplo n.º 1
0
        public override void OnAttached(AbstractEntity entity)
        {
            this.constants = Game.Instance.Simulation.EntityManager["player_constants"];

            if (!entity.HasAttribute("burn_time"))
            {
                entity.AddIntAttribute("burn_time", constants.GetInt("flamethrower_after_burn_time"));
            }
            entity.AddFloatAttribute("burnt_at", -entity.GetInt("burn_time"));

            (entity as Entity).OnUpdate += OnUpdate;
        }
        public override void OnAttached(AbstractEntity entity)
        {
            base.OnAttached(entity);

            if (!entity.HasAttribute("pillar"))
            {
                entity.AddStringAttribute("pillar", "");
                AssignPillar(entity as Entity);
            }
            else
            {
                pillar = Game.Instance.Simulation.EntityManager[entity.GetString("pillar")];

                // get radius
                Vector3 radiusV = (island.GetVector3(CommonNames.Position) - pillar.GetVector3(CommonNames.Position));
                radiusV.Y = 0;
                radius    = radiusV.Length();
            }
        }
Exemplo n.º 3
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));
        }
        public override void OnAttached(AbstractEntity entity)
        {
            Debug.Assert(entity.HasVector3(CommonNames.Position));

            this.island          = entity as Entity;
            this.constants       = Game.Instance.Simulation.EntityManager["island_constants"];
            this.playerConstants = Game.Instance.Simulation.EntityManager["player_constants"];

            if (!entity.HasAttribute(CommonNames.MaxHealth))
            {
                entity.AddFloatAttribute(CommonNames.MaxHealth, (entity.GetVector3(CommonNames.Scale).Length() * constants.GetFloat("scale_health_multiplier")));
            }
            entity.AddFloatAttribute(CommonNames.Health, entity.GetFloat(CommonNames.MaxHealth));

            hasFixedMovementPath = entity.GetBool("fixed");

            entity.AddVector3Attribute("repulsion_velocity", Vector3.Zero);
            entity.AddVector3Attribute("pushback_velocity", Vector3.Zero);
            entity.AddVector3Attribute("repositioning_velocity", Vector3.Zero);

            entity.AddStringAttribute("repulsed_by", "");
            entity.AddIntAttribute("players_on_island", 0);
            entity.AddIntAttribute("players_targeting_island", 0);

            // approximation of island's radius and height
            Vector3 scale = island.GetVector3(CommonNames.Scale);

            entity.AddFloatAttribute("height", scale.Y);
            scale.Y = 0;
            entity.AddFloatAttribute("radius", scale.Length());

            (entity as Entity).OnUpdate += OnUpdate;

            entity.GetProperty <CollisionProperty>("collision").OnContact += CollisionHandler;
//            ((Vector3Attribute)entity.GetAttribute("repulsion_velocity")).ValueChanged += RepulsionChangeHandler;
            entity.GetAttribute <StringAttribute>("repulsed_by").ValueChanged    += RepulsedByChangeHandler;
            entity.GetAttribute <IntAttribute>("players_on_island").ValueChanged += PlayersOnIslandChangeHandler;

            originalPosition = entity.GetVector3(CommonNames.Position);
        }