コード例 #1
0
ファイル: DotFactory.cs プロジェクト: codezips/pacman-c-
        public Dot CreateDot(DotTypes type, Position position)
        {
            Dot instance = null;

            if (!_instances.TryGetValue(type, out instance))
            {
                switch (type)
                {
                case DotTypes.Regular:
                    instance = new RegularDot(position);
                    break;

                case DotTypes.Heavy:
                    instance = new HeavyDot(position);
                    break;

                default:
                    throw new ArgumentException($"Not supported dot type {type}");
                }
                _instances.Add(type, instance);
            }
            instance.Position = position;
            instance.RecreateFigure();
            return(instance);
        }
コード例 #2
0
        /// <summary>
        /// Convert a Compressed dot into a normal dot
        /// </summary>
        /// <param name="cDot"></param>
        /// <param name="timeStamp"></param>
        /// <param name="maxForce"></param>
        public Dot(CompressedDot cDot, long timeStamp, int maxForce)
        {
            switch (cDot.DotType)
            {
            case 0:
                this.DotType = DotTypes.PEN_DOWN;
                break;

            case 1:
                this.DotType = DotTypes.PEN_MOVE;
                break;

            case 2:
                this.DotType = DotTypes.PEN_UP;
                break;

            case 3:
                this.DotType = DotTypes.PEN_HOVER;
                break;

            case 4:
                this.DotType = DotTypes.PEN_ERROR;
                break;
            }

            this.Force     = (int)(cDot.Force * maxForce);
            this.X         = cDot.X;
            this.Y         = cDot.Y;
            this.Fx        = cDot.Fx;
            this.Fy        = cDot.Fy;
            this.Timestamp = timeStamp;
            this.TiltX     = cDot.TiltX;
            this.TiltY     = cDot.TiltY;
        }
コード例 #3
0
 /// <summary>
 /// A constructor that constructs a Dot object
 /// </summary>
 /// <param name="owner">The Owner Id of the NCode paper</param>
 /// <param name="section">The Section Id of the NCode paper</param>
 /// <param name="note">The Note Id of the NCode paper</param>
 /// <param name="page">The Page Number of the NCode paper</param>
 /// <param name="timestamp">the timestamp of the dot</param>
 /// <param name="x">the x coordinates of NCode cell</param>
 /// <param name="y">the y coordinates of NCode cell</param>
 /// <param name="force">the pressure of the dot</param>
 /// <param name="type">the type of the dot</param>
 /// <param name="color">the color of the dot</param>
 public Dot(int owner, int section, int note, int page, long timestamp, float x, float y, int force, DotTypes type, int color)
 {
     Owner     = owner;
     Section   = section;
     Note      = note;
     Page      = page;
     X         = x;
     Y         = y;
     Force     = force;
     Timestamp = timestamp;
     DotType   = type;
     Color     = color;
 }
        private void InitPageIndicator()
        {
            DotCount     = MinDotCount;
            _gravityFlag = GravityFlags.Center;
            _activeDot   = 0;
            _dotSpacing  = 0;
            _dotType     = DotTypes.Single;

            _extraState = OnCreateDrawableState(1);
            var setAsInt = SelectedStateSet.OfType <int>().ToArray();

            MergeDrawableStates(_extraState, setAsInt);
        }
コード例 #5
0
        private void ParseBody()
        {
            mDots.Clear();
            strokeRefList.Clear();

            while (true)
            {
                StrokeRef strokeRef = new StrokeRef(isLittleEndian);

                if (strokeRef.readFromStream(mStrokeInputStream))
                {
                    strokeRefList.Add(strokeRef);
                }
                else
                {
                    break;
                }
            }

            for (int i = 0; i < strokeRefList.Count; i++)
            {
                StrokeRef strokeRef = strokeRefList[i];

                for (int n = 0; n < strokeRef.codeCount; n++)
                {
                    DotData dotData = new DotData(isLittleEndian);

                    if (dotData.readFromStream(mDotInputStream) == false)
                    {
                        break;
                    }

                    //if (status == 0x00 || status == 0x01)
                    {
                        DotTypes type = (n == 0) ? DotTypes.PEN_DOWN : DotTypes.PEN_MOVE;

                        Dot dot = new Dot(strokeFileHeader.ownerId, strokeFileHeader.sectionId, strokeFileHeader.noteId, strokeRef.pageId,
                                          strokeRef.downTime + dotData.timestampDelta, dotData.x, dotData.y, dotData.fx, dotData.fy, dotData.force,
                                          type, strokeRef.penTipColor);

                        mDots.Add(dot);
                    }
                }
            }
        }
コード例 #6
0
        private void ParseDot(Packet mPack, DotTypes type)
        {
            int timeadd = mPack.GetByte();

            mTime += timeadd;

            int force = mPack.GetShort();

            int x = mPack.GetShort();
            int y = mPack.GetShort();

            int fx = mPack.GetByte();
            int fy = mPack.GetByte();

            int tx = mPack.GetByte();
            int ty = mPack.GetByte();

            int twist = mPack.GetShort();

            PenController.onReceiveDot(new DotReceivedEventArgs(MakeDot(PenMaxForce, mCurOwner, mCurSection, mCurNote, mCurPage, mTime, x, y, fx, fy, force, type, mPenTipColor)));
        }
コード例 #7
0
        /// <summary>
        ///     Method used to create a dot.
        /// </summary>
        /// <param name="cell">The cell you want to move the dot to.</param>
        /// <param name="type">The type of dot you want to create.</param>
        public void CreateDot(BoardCell cell, DotTypes type = DotTypes.Normal)
        {
            Dot dotCreated = null;

            switch (type)
            {
            case DotTypes.None:
                Debug.LogError("Invalid Dot Type.");
                break;

            case DotTypes.Normal:
                dotCreated = PoolManager.Instance.GetPoolableObject().GetComponent <NormalDot>();
                dotCreated.Setup(DotTypes.Normal, cell);

                // to prevent the same color as square from getting created right after the square is found.
                int colorIndex;
                do
                {
                    colorIndex = Random.Range(0, _colors.Count);
                } while (RemovedSquareColor == _colors[colorIndex]);

                ((NormalDot)dotCreated).DotColor = _colors[colorIndex];
                break;

            default:
                throw new InvalidEnumArgumentException();
            }

            if (dotCreated == null)
            {
                Debug.LogError("No Dot created");
                return;
            }

            cell.ContainingDot = dotCreated;
            cell.ContainingDot.SetSpawnPosition(_spawningPositions[dotCreated.ColumnNumber]);
            cell.ContainingDot.MoveToPosition(cell.transform);
            MoveManager.Instance.AddEventListeners(dotCreated);
        }
コード例 #8
0
 public void Init(int x, int y, DotTypes type, Board board)
 {
     this.board = board;
     SetPosition(x, y);
     SetType(type);
 }
コード例 #9
0
 public Builder dotType(DotTypes dotType)
 {
     mDot.DotType = dotType;
     return(this);
 }
コード例 #10
0
 /// <summary>
 /// A constructor that constructs a Dot object
 /// </summary>
 /// <param name="owner">The Owner Id of the NCode paper</param>
 /// <param name="section">The Section Id of the NCode paper</param>
 /// <param name="note">The Note Id of the NCode paper</param>
 /// <param name="page">The Page Number of the NCode paper</param>
 /// <param name="timestamp">the timestamp of the dot</param>
 /// <param name="x">the x coordinates of NCode cell</param>
 /// <param name="y">the y coordinates of NCode cell</param>
 /// <param name="tiltX"></param>
 /// <param name="tiltY"></param>
 /// <param name="twist"></param>
 /// <param name="force">the pressure of the dot</param>
 /// <param name="type">the type of the dot</param>
 /// <param name="color">the color of the dot</param>
 public Dot(int owner, int section, int note, int page, long timestamp, float x, float y, int tiltX, int tiltY, int twist, int force, DotTypes type, int color)
     : this(owner, section, note, page, timestamp, x, y, force, type, color)
 {
     TiltX = tiltX;
     TiltY = tiltY;
     Twist = twist;
 }
コード例 #11
0
        private Dot MakeDot(int owner, int section, int note, int page, long timestamp, float x, float y, int tiltX, int tiltY, int twist, int force, DotTypes type, int color)
        {
            Dot.Builder builder = new Dot.Builder();

            builder.owner(owner)
            .section(section)
            .note(note)
            .page(page)
            .timestamp(timestamp)
            .coord(x, y)
            .tilt(tiltX, tiltY)
            .twist(twist)
            .force(force)
            .dotType(type)
            .color(color);
            return(builder.Build());
        }
コード例 #12
0
        internal static void DrawDots(DrawingContext drawingContext, DotTypes types, Point p, AnchorPoint anchor, bool selected)
        {
            int gridSize = Configurations.DotGridSize;
            int cellSize = gridSize / 3; //3x3 grid
            Size rectSize = new Size(2, 2);
            Rect rect = new Rect();
            p.X = (int)p.X;
            p.Y = (int)p.Y;
            Point pt = p;

            switch (anchor)
            {
                case AnchorPoint.TopLeft:
                    break;
                case AnchorPoint.TopRight:
                    p.X -= gridSize;
                    break;
                case AnchorPoint.BottomLeft:
                    p.Y -= gridSize;
                    break;
                case AnchorPoint.BottomRight:
                    p.X -= gridSize;
                    p.Y -= gridSize;
                    break;
                default:
                    throw new InvalidOperationException();
            }

            if (types.HasFlag(DotTypes.TopLeft))
            {
                pt = p;
                pt.Offset(0, 0);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.Top))
            {
                pt = p;
                pt.Offset(cellSize, 0);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.TopRight))
            {
                pt = p;
                pt.Offset(2 * cellSize, 0);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.MiddleLeft))
            {
                pt = p;
                pt.Offset(0, cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.Middle))
            {
                pt = p;
                pt.Offset(0, cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.MiddleRight))
            {
                pt = p;
                pt.Offset(2 * cellSize, cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.BottomLeft))
            {
                pt = p;
                pt.Offset(0, 2 * cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.Bottom))
            {
                pt = p;
                pt.Offset(cellSize, 2 * cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.BottomRight))
            {
                pt = p;
                pt.Offset(2 * cellSize, 2 * cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }
            return;
        }
コード例 #13
0
        internal static void DrawDots(DrawingContext drawingContext, DotTypes types, Point p, AnchorPoint anchor, bool selected)
        {
            int  gridSize = Configurations.DotGridSize;
            int  cellSize = gridSize / 3; //3x3 grid
            Size rectSize = new Size(2, 2);
            Rect rect     = new Rect();

            p.X = (int)p.X;
            p.Y = (int)p.Y;
            Point pt = p;

            switch (anchor)
            {
            case AnchorPoint.TopLeft:
                break;

            case AnchorPoint.TopRight:
                p.X -= gridSize;
                break;

            case AnchorPoint.BottomLeft:
                p.Y -= gridSize;
                break;

            case AnchorPoint.BottomRight:
                p.X -= gridSize;
                p.Y -= gridSize;
                break;

            default:
                throw new InvalidOperationException();
            }

            if (types.HasFlag(DotTypes.TopLeft))
            {
                pt = p;
                pt.Offset(0, 0);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.Top))
            {
                pt = p;
                pt.Offset(cellSize, 0);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.TopRight))
            {
                pt = p;
                pt.Offset(2 * cellSize, 0);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.MiddleLeft))
            {
                pt = p;
                pt.Offset(0, cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.Middle))
            {
                pt = p;
                pt.Offset(0, cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.MiddleRight))
            {
                pt = p;
                pt.Offset(2 * cellSize, cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.BottomLeft))
            {
                pt = p;
                pt.Offset(0, 2 * cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.Bottom))
            {
                pt = p;
                pt.Offset(cellSize, 2 * cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }

            if (types.HasFlag(DotTypes.BottomRight))
            {
                pt = p;
                pt.Offset(2 * cellSize, 2 * cellSize);
                rect = new Rect(pt, rectSize);
                DrawSmallDots(drawingContext, selected, rect);
            }
            return;
        }
コード例 #14
0
ファイル: PenClientParserV1.cs プロジェクト: hrhwang/UWPSDK
        private void ProcessDot(int ownerId, int sectionId, int noteId, int pageId, long timeLong, int x, int y, int fx, int fy, int force, DotTypes type, int color)
        {
            Dot.Builder builder = null; new Dot.Builder();
            if (PenMaxForce == 0)
            {
                builder = new Dot.Builder();
            }
            else
            {
                builder = new Dot.Builder(PenMaxForce);
            }

            builder.owner(ownerId)
            .section(sectionId)
            .note(noteId)
            .page(pageId)
            .timestamp(timeLong)
            .coord(x + fx * 0.01f, y + fy * 0.01f)
            .force(force)
            .dotType(type)
            .color(color);

            PenController.onReceiveDot(new DotReceivedEventArgs(builder.Build()));
        }
 private void ProcessDot(int ownerId, int sectionId, int noteId, int pageId, long timeLong, int x, int y, int fx, int fy, int force, DotTypes type, int color)
 {
     Callback.onReceiveDot(this, new Dot(ownerId, sectionId, noteId, pageId, timeLong, x, y, fx, fy, force, type, color));
 }
コード例 #16
0
 public void SetType(DotTypes type)
 {
     Type        = type;
     image.color = type.color;
 }
コード例 #17
0
 /// <summary>
 /// Setups the dot.
 /// </summary>
 /// <param name="dotType">Type of the dot.</param>
 /// <param name="cell">The cell.</param>
 public virtual void Setup(DotTypes dotType, BoardCell cell)
 {
     DotType = dotType;
     UpdateCoordinates(cell.Row, cell.Column);
 }
コード例 #18
0
        //public Dot(
        private Dot MakeDot(int penMaxForce, int owner, int section, int note, int page, long timestamp, int x, int y, int fx, int fy, int force, DotTypes type, int color)
        {
            Dot.Builder builder = null;
            if (penMaxForce == 0)
            {
                builder = new Dot.Builder();
            }
            else
            {
                builder = new Dot.Builder(penMaxForce);
            }

            builder.owner(owner)
            .section(section)
            .note(note)
            .page(page)
            .timestamp(timestamp)
            .coord(x + fx * 0.01f, y + fy * 0.01f)
            .force(force)
            .dotType(type)
            .color(color);
            return(builder.Build());
        }