Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public StatePart Create(StatePartTypeEnum type, BinaryReader reader)
        {
            StatePart part = null;

            switch (type)
            {
            case StatePartTypeEnum.GAME_OBJECT: part = new GameObjectPart(); break;

            case StatePartTypeEnum.MOVABLE_ENTITY: part = new MovableEntityPart(); break;

            case StatePartTypeEnum.COMBAT_ENTITY: part = new CombatEntityPart(); break;

            case StatePartTypeEnum.HERO_ENTITY: part = new HeroEntityPart(); break;

            case StatePartTypeEnum.PHYSIC_OBJECT: part = new PhysicObjectPart(); break;

            default: throw new ArgumentException("unknow state part type id : " + type);
            }
            try {
                part.FromNetwork(reader);
            }
            catch (Exception e)
            {
                throw new StatePartDeserializationException("unable to deserialize part : " + part.Type, e);
            }
            return(part);
        }
Пример #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="part"></param>
 public void UpdateMovableEntityPart(MovableEntityPart part)
 {
     InitialVelocityX = part.VelocityX;
     InitialVelocityY = part.VelocityY;
     if(!IsLocal)
         SetVelocityInterpolation(part.VelocityX, part.VelocityY);
     SetPositionInterpolation(part.X, part.Y);
     Ghost.PositionX = GetMeterToPoint(part.X);
     Ghost.PositionY = GetMeterToPoint(part.Y);
 }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reader"></param>
        public override void FromNetwork(BinaryReader reader)
        {
            base.FromNetwork(reader);

            var movablePart = new MovableEntityPart();
            movablePart.FromNetwork(reader);
            UpdateMovableEntityPart(movablePart);
        }