示例#1
0
 private void RecreateIntroduction()
 {
     m_introduction = new EntityIntroduction()
     {
         ID        = ID,
         Name      = Name,
         Level     = Level,
         MaxHealth = MaxHealth,
         MaxPower  = MaxPower,
         ModelID   = 0
     };
 }
示例#2
0
        private void BuildAndSendWorldStateUpdate()
        {
            m_worldState.CurrentServerTime = Environment.TickCount;
            m_worldState.Health            = Health;
            m_worldState.Power             = Power;

            List <EntityStateUpdate> entityStates = new List <EntityStateUpdate>();

            m_worldState.EntityIntroductions = null;

            BoundingBox    range        = new BoundingBox(Position - RELEVANCE_RANGE, Position + RELEVANCE_RANGE);
            List <IEntity> nearEntities = CurrentZone.GatherEntitiesInRange(range);

            for (int i = 0; i < nearEntities.Count; i++)
            {
                IEntity           entity = nearEntities[i];
                EntityStateUpdate esu    = entity.GetStateUpdate();
                if (entity.ID != ID && esu != null && !entity.IsDead)
                {
                    entityStates.Add(entity.GetStateUpdate());

                    EntityIntroduction introduction = entity.GetIntroduction();
                    if (!m_introducedEntities.ContainsKey(esu.ID) || m_introducedEntities[esu.ID] != introduction)
                    {
                        if (m_worldState.EntityIntroductions == null)
                        {
                            m_worldState.EntityIntroductions = new List <EntityIntroduction>();
                        }

                        m_worldState.EntityIntroductions.Add(introduction);
                        m_introducedEntities[esu.ID] = introduction;
                    }
                }
            }

            m_worldState.EntityStates = entityStates;
            m_nearEntities            = nearEntities;

            Send(m_worldState);
        }
示例#3
0
        public NPCInstance(Fiber fiber, NPCModel npc, NPCSpawnModel npcSpawn, List <INPCBehaviour> behaviours, IReadOnlyDictionary <StatType, float> stats, MapData mapData)
        {
            NPCModel      = npc;
            NPCSpawnModel = npcSpawn;
            m_stats       = stats;
            m_fiber       = fiber;
            m_mapData     = mapData;

            m_behavioursByType = m_behaviours.ToDictionary(b => b.GetType());

            Position = new Vector2((float)npcSpawn.X, (float)npcSpawn.Y);
            ID       = IDGenerator.GetNextID();

            MaxHealth = Formulas.StaminaToHealth(GetStatValue(StatType.Stamina));
            Health    = MaxHealth;

            MaxPower = Formulas.LevelToPower(Level);
            Power    = MaxPower;

            m_introduction = new EntityIntroduction()
            {
                ID        = ID,
                Level     = (byte)NPCModel.Level,
                MaxHealth = MaxHealth,
                MaxPower  = MaxPower,
                Name      = Name,
                ModelID   = NPCModel.ModelID
            };

            m_stateUpdate = new EntityStateUpdate()
            {
                Rotation = Compression.RotationToByte(npcSpawn.Rotation),
                ID       = ID,
                Health   = Health,
                Power    = 100,
            };

            m_behaviours = behaviours;
        }