Пример #1
0
        private ScoreboardDataPacket CreateScoreboardDataPacket(Entity e, bool respawned)
        {
            ScoreboardDataPacket p = new ScoreboardDataPacket();

            ScoreComponent score = e.GetComponent <ScoreComponent>();
            LifeComponent  life  = e.GetComponent <LifeComponent>();

            p.EntityId        = e.EntityId;
            p.Score           = score.Value;
            p.Lives           = life.Lives;
            p.EntityRespawned = respawned;

            return(p);
        }
Пример #2
0
        private void HandleScoreboardData(ScoreboardDataPacket p)
        {
            Entity e = this.entityWorld.EntityManager.GetEntity(p.EntityId);

            if (e != null)
            {
                ScoreComponent score = e.GetComponent <ScoreComponent>();
                LifeComponent  life  = e.GetComponent <LifeComponent>();

                System.Diagnostics.Debug.Assert(score != null, "PositionComponent not found");
                System.Diagnostics.Debug.Assert(life != null, "VelocityComponent not found");

                score.Value = p.Score;
                life.Lives  = p.Lives;
                if (p.EntityRespawned)
                {
                    e.AddComponent(new ShieldComponent());
                    e.GetComponent <RespawnComponent>().TimeSinceRespawn = 0;
                }
            }
        }