Example #1
0
    public override void Save()
    {
        //List is copied so we can replace it with a list more suited for saving, then reinstate the old one
        var listcopy = new List <ObjectWithName>(FrameList);

        FrameList.Clear();
        if (SingleSaveFile)
        {
            FrameList.Add(new ObjectWithName(true, "SingleSave"));
            foreach (WekitPlayer_Base player in ActiveWekitPlayers)
            {
                FrameList.Add(new ObjectWithName(player.GetListAsObject(), player.PlayerName));
            }
        }

        base.Save();

        FrameList = listcopy;
        if (SingleSaveFile)
        {
            return;
        }
        foreach (WekitPlayer_Base player in ActiveWekitPlayers)
        {
            player.UseZip             = UseZip;
            player.UseCompoundArchive = UseCompoundArchive;
            player.CompoundZipName    = CompoundZipName;
            player.FileName           = FileName;
            player.Save();
        }
    }
Example #2
0
        private void InitWithGameObject(GameObject m_GameObject)
        {
            assetsfileList.TryGetTransform(m_GameObject.m_Transform, out var m_Transform);
            var rootTransform = m_Transform;
            var frameList     = new List <ImportedFrame>();

            while (assetsfileList.TryGetTransform(rootTransform.m_Father, out var m_Father))
            {
                frameList.Add(ConvertFrames(m_Father));
                rootTransform = m_Father;
            }
            if (frameList.Count > 0)
            {
                FrameList.Add(frameList[frameList.Count - 1]);
                for (var i = frameList.Count - 2; i >= 0; i--)
                {
                    var frame  = frameList[i];
                    var parent = frameList[i + 1];
                    parent.AddChild(frame);
                }
                ConvertFrames(m_Transform, frameList[0]);
            }
            else
            {
                ConvertFrames(m_Transform, null);
            }

            CreateBonePathHash(rootTransform);
            ConvertMeshRenderer(m_Transform);
        }
Example #3
0
 private void FrameMessage(string InputString)
 {
     /* According to the ASTM E1381-95 standard, frames longer than 240 characters
      *  -- 247 characters including frame overhead (<STX>[FrameNumber]...<ETX>[Checksum]<CR><LF>) --
      *  are sent as one or more intermediate frames followed by an end frame.
      *  Shorter messages are sent as a single end frame.
      *  Intermediate frames use <ETB> in place of <ETX> to indicate that it is continued
      *  in the next frame.
      *  This procedure splits long frames into intermediate frames if necessary
      *  before appending the checksum and <CR><LF> and adding the frame to the message FrameList.
      *  CLSI-LIS1-A increased this frame size to 64,000 including frame overhead.
      *  The use_legacy_frame_size setting in config.yml is used to specify which size to use.
      */
     if (InputString.Length > frameSize + 3)                                 // <STX> + FrameNumber + frame + <ETX>
     {
         string firstString       = InputString.Substring(0, frameSize + 2); // +2 to make room for the <ETB>
         int    firstStringLength = firstString.Length;
         int    iLength           = InputString.Length - firstStringLength;
         firstString += Constants.ETB;
         firstString += ServiceMain.CHKSum(firstString);
         firstString += Constants.CR + Constants.LF;
         string nextString = InputString.Substring(firstStringLength, iLength); // The remainder of the string
         FrameList.Add(firstString);                                            // Add intermediate frame to list           // is passed to this function recursively
         FrameMessage(nextString);                                              // to be added as its own frame(s)
     }
     else
     {
         InputString += ServiceMain.CHKSum(InputString) + Constants.CR + Constants.LF; // Tag on the checksum and <CR><LF>
         FrameList.Add(InputString);                                                   // Add the end frame
     }
 }
        private void CaptureCurrentFrame(MediaPlayer player)
        {
            var frame = GenerateFrame(player);

            #region Scaling

            if (Scale <= 0)
            {
                var bit = frame as BitmapFrame;

                if (bit != null)
                {
                    FrameList.Add(bit);
                }
            }

            var thumbnailFrame = BitmapFrame.Create(new TransformedBitmap(frame as BitmapSource, new ScaleTransform(Scale, Scale))).GetCurrentValueAsFrozen();

            var thumbBit = thumbnailFrame as BitmapFrame;

            if (thumbBit != null)
            {
                FrameList.Add(thumbBit);
            }

            #endregion

            SeekNextFrame();

            GC.Collect();
        }
Example #5
0
        private void InitWithGameObject(GameObject m_GameObject, Dictionary <string, int> sharedFileIndex, List <AssetsFile> assetsfileList, Dictionary <string, EndianBinaryReader> resourceFileReaders)
        {
            assetsfileList.TryGetTransform(m_GameObject.m_Transform, out var m_Transform);
            var rootTransform = m_Transform;
            var frameList     = new List <ImportedFrame>();

            while (assetsfileList.TryGetTransform(rootTransform.m_Father, out var m_Father))
            {
                frameList.Add(ConvertFrames(m_Father));
                rootTransform = m_Father;
            }
            if (frameList.Count > 0)
            {
                FrameList.Add(frameList[frameList.Count - 1]);
                for (var i = frameList.Count - 2; i >= 0; i--)
                {
                    var frame  = frameList[i];
                    var parent = frameList[i + 1];
                    parent.AddChild(frame);
                }
                ConvertFrames(m_Transform, frameList[0]);
            }
            else
            {
                ConvertFrames(m_Transform, null);
            }

            CreateBonePathHash(rootTransform);
            ConvertMeshRenderer(m_Transform, sharedFileIndex, assetsfileList, resourceFileReaders);
        }
Example #6
0
        protected void SendStepAll(object sender, ElapsedEventArgs e)
        {
            if (ClientPool.ActiveCount <= 0)
            {
                if (FrameList.Count > 0)
                {
                    ServerLog.LogServer("所有客户端退出游戏 战斗结束!!!", 1);
                    FrameList.Clear();
                }
                return;
            }

            if (FrameList.Count == 0)
            {
                ServerLog.LogServer("玩家进入服务器 战斗开始!!!", 1);
            }
            ServerLog.LogServer("0[" + FrameList.Count + "]", 1);

            byte[][]     temp     = StepMessage;
            int          length   = temp.Length;
            ProtocolBase protocol = new ByteProtocol();

            protocol.push((byte)MessageType.Frame);
            protocol.push((byte)length);
            //ServerLog.LogServer("获取[" + FrameList.Count + "]", 1);
            for (int i = 0; i < length; i++)
            {
                protocol.push(temp[i] != null);
                protocol.push(temp[i]);
            }
            if (FrameList.Count == 0)
            {
                protocol.push((byte)MessageType.RandomSeed);
                Random rand = new Random();
                protocol.push(rand.Next(10000));
            }
            protocol.push((byte)MessageType.end);
            ServerLog.LogServer("生成帧信息[" + length + "]", 1);
            byte[] temp2 = protocol.GetByteStream();

            FrameList.Add(temp2);

            ClientPool.Foreach((con) => { SendToClient(con.clientId, temp2);
                                          if (!con.ActiveCheck())
                                          {
                                              ServerLog.LogClient("客户端断线 中止连接:" + ClientPool[con.clientId].socket.LocalEndPoint + "ClientID:" + con.clientId, 0, con.clientId);

                                              con.socket.Close();
                                              ClientPool.Recover(con.clientId);
                                          }
                               });

            ServerLog.LogServer("帧同步[" + FrameList.Count + "]", 2);
            //StepMessage = new byte[ClientPool.Count][];
            //for (int i = 0; i < StepMessage.Length; i++)
            //{
            //    StepMessage[i] = new byte[framSize];
            //}
        }
Example #7
0
 /// <summary>
 /// Gets rectangle of the sprite, and the duration of the frame, creates new frame in animation
 /// </summary>
 public void AddFrame(Rectangle rectangle, TimeSpan duration)
 {
     FrameList.Add(new Frame()
     {
         Rectangle = rectangle,
         Duration  = duration
     });
 }
Example #8
0
 /// <summary>
 /// Gets rectangle of the sprite, and the duration of the frame, creates new frame in animation
 /// </summary>
 public void AddFrame(Rectangle source, TimeSpan duration)
 {
     FrameList.Add(new AFrame()
     {
         Source   = source,
         Duration = duration
     });
 }
Example #9
0
        public void Roll(int knockedPins)
        {
            var lastFrame = GetLastFrame();

            //Frame first roll
            if (lastFrame.KnockedPins.Count == 0)
            {
                lastFrame.KnockedPins.Add(knockedPins);
                return;
            }

            //frame second roll
            if (lastFrame.FrameIndex == 9)
            {
                if (lastFrame.KnockedPins.Count < 2)
                {
                    lastFrame.KnockedPins.Add(knockedPins);
                    return;
                }
                else if (lastFrame.KnockedPins.Count == 2)
                {
                    if (lastFrame.KnockedPins[0] == 10 ||
                        lastFrame.KnockedPins[1] == 10 ||
                        (lastFrame.KnockedPins[0] + lastFrame.KnockedPins[1]) == 10)
                    {
                        lastFrame.KnockedPins.Add(knockedPins);
                        return;
                    }
                }
                else
                {
                    throw new Exception("Game Over");
                }
            }
            else
            {
                if (lastFrame.KnockedPins[0] == 10)
                {
                    var newFrame = new Frame();
                    newFrame.FrameIndex = lastFrame.FrameIndex + 1;
                    newFrame.KnockedPins.Add(knockedPins);
                    FrameList.Add(newFrame);
                }
                else if (lastFrame.KnockedPins.Count >= 2)
                {
                    var newFrame = new Frame();
                    newFrame.FrameIndex = lastFrame.FrameIndex + 1;
                    newFrame.KnockedPins.Add(knockedPins);
                    FrameList.Add(newFrame);
                }
                else
                {
                    lastFrame.KnockedPins.Add(knockedPins);
                }
            }
        }
Example #10
0
 private Frame GetLastFrame()
 {
     if (FrameList.Count == 0)
     {
         FrameList.Add(new Frame {
             FrameIndex = 0
         });
     }
     return(FrameList[FrameList.Count - 1]);
 }
Example #11
0
        private void CaptureCurrentFrame(MediaPlayer player)
        {
            var thumbBit = CaptureFrame(player) as BitmapFrame;

            if (thumbBit != null)
            {
                FrameList.Add(thumbBit);
            }

            GC.Collect();

            SeekNextFrame();
        }
Example #12
0
        private void CaptureCurrentFrame(MediaPlayer player)
        {
            if (CaptureFrame(player) is BitmapFrame thumbBit)
            {
                FrameList.Add(thumbBit);
            }

            GC.Collect();

            if (!_cancelled)
            {
                SeekNextFrame();
            }
        }
Example #13
0
 private void ConvertFrames(Transform trans, ImportedFrame parent)
 {
     var frame = ConvertFrame(trans);
     if (parent == null)
     {
         FrameList.Add(frame);
     }
     else
     {
         parent.AddChild(frame);
     }
     foreach (var pptr in trans.m_Children)
     {
         if (pptr.TryGetTransform(out var child))
             ConvertFrames(child, frame);
     }
 }
Example #14
0
        /// <summary>
        /// Inserts a frame into this TextureAtlas
        /// </summary>
        /// <param name="frame">The frame to pack</param>
        public void InsertFrame(IFrame frame)
        {
            if (FrameList.ContainsReference(frame))
            {
                return;
            }

            if (frame.Animation != null && !_animationList.Contains(frame.Animation))
            {
                _animationList.Add(frame.Animation);
            }

            FrameList.Add(frame);
            BoundsList.Add(new Rectangle());
            OriginsList.Add(new Rectangle(0, 0, frame.Width, frame.Height));
            ReuseCount.Add(0);
        }
Example #15
0
        protected void CreateFrameList(IEnumerable <String> lines)
        {
            foreach (String line in lines)
            {
                String[] values      = line.Split(TSharkHelper.OUTPUT_SEPARATOR);
                int      frameNumber = int.Parse(values[0]);

                Frame frame = new Frame(frameNumber,
                                        NetworkTrace,
                                        values[1],
                                        values[2],
                                        values[3],
                                        values[4],
                                        values[5]);

                FrameList.Add(frame);
            }
        }
Example #16
0
File: Fbx.cs Project: kkdevs/sb3u
            private ImportedFrame ConvertFrames(remBone frame)
            {
                ImportedFrame iFrame = new ImportedFrame();

                iFrame.InitChildren(frame.Count);
                iFrame.Name   = frame.name;
                iFrame.Matrix = frame.matrix;

                FrameList.Add(iFrame);

                foreach (remBone child in frame)
                {
                    ImportedFrame iChild = ConvertFrames(child);
                    iFrame.AddChild(iChild);
                }

                return(iFrame);
            }
Example #17
0
        private void InitWithGameObject(GameObject m_GameObject, bool hasTransformHierarchy = true)
        {
            m_GameObject.m_Transform.TryGetTransform(out var m_Transform);
            var rootTransform = m_Transform;

            if (!hasTransformHierarchy)
            {
                var rootFrame = ConvertFrame(rootTransform);
                FrameList.Add(rootFrame);
                DeoptimizeTransformHierarchy();
            }
            else
            {
                var frameList     = new List <ImportedFrame>();
                var tempTransform = rootTransform;
                while (tempTransform.m_Father.TryGetTransform(out var m_Father))
                {
                    frameList.Add(ConvertFrame(m_Father));
                    tempTransform = m_Father;
                }
                if (frameList.Count > 0)
                {
                    FrameList.Add(frameList[frameList.Count - 1]);
                    for (var i = frameList.Count - 2; i >= 0; i--)
                    {
                        var frame  = frameList[i];
                        var parent = frameList[i + 1];
                        parent.AddChild(frame);
                    }
                    ConvertFrames(m_Transform, frameList[0]);
                }
                else
                {
                    ConvertFrames(m_Transform, null);
                }

                CreateBonePathHash(rootTransform);
            }

            ConvertMeshRenderer(m_Transform);
        }
Example #18
0
        private void RefreshFrameList()
        {
            // Clear frame list
            FrameList.Clear();

            // Get current selected inner file
            InnerNpkFile selectedFile = InnerFileList.Current;

            // If none selected nothing else to do here
            if (selectedFile == null)
            {
                return;
            }

            // Get the list of frames. Since it's lazy loaded, there could be a read error.
            List <FrameInfo> frames;

            try
            {
                frames = _editor.Frames[selectedFile.Path].ToList();
            }
            catch (Exception ex)
            {
                // TODO: Better way of displaying than modal?
                // At least get the view to show it instead of the view model
                MessageBox.Show(string.Format("Error reading frames from NPK file: {0}", ex.Message));
                return;
            }

            _smallestX = 0;
            _largestX  = 0;
            _smallestY = 0;
            _largestY  = 0;
            _width     = 1;
            _height    = 1;

            List <FrameInfo> nonLinkFrames = frames.Where(f => f.LinkFrame == null).ToList();

            if (nonLinkFrames.Count > 0)
            {
                FrameInfo.GetNormalizedCoordinates(nonLinkFrames, out _smallestX, out _largestX, out _smallestY, out _largestY);
                _width  = _largestX - _smallestX + 1;
                _height = _largestY - _smallestY + 1;
            }

            // Populate frame list
            for (int frameIndex = 0; frameIndex < frames.Count; frameIndex++)
            {
                FrameInfo frame = frames[frameIndex];
                // if linked frame, follow link
                if (frame.LinkFrame != null)
                {
                    int linkIndex = frame.LinkFrame.Value;
                    if (linkIndex < 0 || linkIndex >= frames.Count)
                    {
                        // TODO: Log error that link is out of range?
                        FrameList.Add(new FrameMetadata(frameIndex, 0, 0, 0, 0, linkIndex));
                    }
                    else
                    {
                        FrameInfo linkedFrame = frames[linkIndex];
                        FrameList.Add(new FrameMetadata(linkedFrame, frameIndex, linkIndex));
                    }
                }
                else
                {
                    FrameList.Add(new FrameMetadata(frame, frameIndex, linkFrameIndex: null));
                }
            }
        }