Пример #1
0
                // Before reports whether the position p comes before q in the source.
                // For positions with different bases, ordering is by base index.
                public static bool Before(this XPos p, XPos q)
                {
                    var n = p.index;
                    var m = q.index;

                    return(n < m || n == m && p.lico < q.lico);
                }
Пример #2
0
                // After reports whether the position p comes after q in the source.
                // For positions with different bases, ordering is by base index.
                public static bool After(this XPos p, XPos q)
                {
                    var n = p.index;
                    var m = q.index;

                    return(n > m || n == m && p.lico > q.lico);
                }
Пример #3
0
        public override string ToString()
        {
            string gcodeLineText = "";

            gcodeLineText += LineNumber.ToString() + ";";

            foreach (string command in Command)
            {
                gcodeLineText += command + ";";
            }

            gcodeLineText += XPos.ToString() + SEPERATOR
                             + YPos.ToString() + SEPERATOR
                             + ZPos.ToString() + SEPERATOR
                             + IPos.ToString() + SEPERATOR
                             + JPos.ToString() + SEPERATOR
                             + CRNumber.ToString() + SEPERATOR;

            foreach (ErrorGCode error in Error)
            {
                gcodeLineText += error.ToString() + SEPERATOR;
            }


            return(gcodeLineText);
        }
Пример #4
0
        // Continuesly reading memory and updating the UI
        private async void OnTickMemoryRead()
        {
            if (openProc)
            {
                CurrentHealth            = m.readInt("GameAssembly.dll+00E4FAB8,0xB8,0x0,0x1C8,0x10,0x28,0x148");
                txtbx_currentHealth.Text = CurrentHealth.ToString();

                EnemyCurrentHealth            = m.readInt("GameAssembly.dll+00C2BE60,0x78,0x70,0x20,0x10,0xA2C");
                txtbx_enemyCurrentHealth.Text = EnemyCurrentHealth.ToString();

                IsFight = m.readInt("GameAssembly.dll+00E4EE78,0xB8,0x0,0x950,0xE8,0x228");
                txtbx_fightState.Text = IsFight.ToString();

                EncounterPokeIndex   = m.readInt("GameAssembly.dll+00E4B510,0xB8,0x20,0x98,0x38,0xA24");
                txtbx_pokemonID.Text = EncounterPokeIndex.ToString();

                //PokeDollars = m.readInt("GameAssembly.dll+00A508B0,0xB8,0x48,0xB8,0x298,0x290");
                //txtbx_pokeDollar.Text = PokeDollars.ToString();

                XPos            = (int)Math.Ceiling(m.readFloat("UnityPlayer.dll+015F5600,0xB8,0x18,0x18,0xE0,0x90"));
                txtbx_xPos.Text = XPos.ToString();


                YPos            = (int)Math.Abs(Math.Ceiling(m.readFloat("GameAssembly.dll+00E5B690,0x90,0x28,0xB8,0x20,0x278,0x230")));
                txtbx_yPos.Text = YPos.ToString();

                txtbx_currentPP1.Text = AbilityPP1.ToString();

                await Task.Delay(100);

                OnTickMemoryRead();
            }
        }
Пример #5
0
        public override int GetHashCode()
        {
            int hashCode = 13;

            hashCode = (hashCode * 7) + XPos.GetHashCode();
            hashCode = (hashCode * 7) + YPos.GetHashCode();
            return(hashCode);
        }
Пример #6
0
            private void CheckXBox(XPos xPos, ref CharaPos charaPos, ref CharaLastPos charaLastPos,
                                   ref CharaFlag charaFlag, ref CharaQueue charaQueue)
            {
                int mapX     = 0;
                int lastMapX = 0;
                int sideMapX = 0;
                int offsetX  = 0;

                switch (xPos)
                {
                case XPos.Left:
                    mapX     = charaPos.m_mapXLeft;
                    lastMapX = charaLastPos.m_mapXLeft;
                    sideMapX = mapX + 1;
                    offsetX  = TIP_SIZE + SIDE_OFFSET;
                    break;

                case XPos.Center:
                    mapX     = charaPos.m_mapXCenter;
                    lastMapX = charaLastPos.m_mapXCenter;
                    break;

                case XPos.Right:
                    mapX     = charaPos.m_mapXRight;
                    lastMapX = charaLastPos.m_mapXRight;
                    sideMapX = mapX - 1;
                    offsetX  = -1 - SIDE_OFFSET;
                    break;
                }

                // MapX移動が無いときはチェックしない
                if (mapX == lastMapX)
                {
                    return;
                }

                // 横が空の時のみ、壁チェック
                EnumShapeType sideShape = GetShape(sideMapX, charaPos.m_mapY, charaPos.m_mapZ);

                if (!sideShape.IsEmpty())
                {
                    return;
                }

                // ブロックのみ補正行う、斜め壁は別途
                EnumShapeType shape = GetShape(mapX, charaPos.m_mapY, charaPos.m_mapZ);

                if (!shape.IsBox())
                {
                    return;
                }

                // 中心位置への補正SIDE_OFFSET
                int newX = (mapX << PIX_MAP) + offsetX;

                charaPos.SetPixX(newX);
                QueueCrash(ref charaFlag, ref charaQueue);
            }
Пример #7
0
                public static @string LineNumberHTML(this XPos p)
                {
                    if (!p.IsKnown())
                    {
                        return("?");
                    }

                    return(p.lico.lineNumberHTML());
                }
Пример #8
0
 public DriveComponent(SpeedType speedType, int speed)
 {
     this.SpeedType      = speedType;
     this.Speed          = speed;
     this.State          = DriveState.Idle;
     this.FlowField      = null;
     this.MovementVector = new Vector2I();
     this.Destination    = new XPos();
 }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        float 当前时刻 = Time.realtimeSinceStartup;
        float Y位置  = YPos.Evaluate(当前时刻);
        float X位置  = XPos.Evaluate(当前时刻);

        Vector3 局域位置 = new Vector3(X位置, Y位置, 0);

        transform.localPosition = 局域位置;
    }
Пример #10
0
 public DriveComponent(SpeedType speedType, int speed,
                       DriveState state, IFlowField flowField, Vector2I movementVector, XPos destination)
 {
     this.SpeedType      = speedType;
     this.Speed          = speed;
     this.State          = state;
     this.FlowField      = flowField;
     this.MovementVector = movementVector;
     this.Destination    = destination;
 }
Пример #11
0
            private bool CheckFloatWall(XPos xPos, ref CharaPos charaPos, ref CharaFlag charaFlag, ref CharaQueue charaQueue)
            {
                // tipYが中途半端な場合は浮いている
                if (charaPos.m_tipY != 0)
                {
                    return(true);
                }

                int mapX = 0;
                int tipX = 0;

                switch (xPos)
                {
                case XPos.Left:
                    mapX = charaPos.m_mapXLeft;
                    tipX = charaPos.m_tipXLeft;
                    break;

                case XPos.Center:
                    mapX = charaPos.m_mapXCenter;
                    tipX = charaPos.m_tipXCenter;
                    break;

                case XPos.Right:
                    mapX = charaPos.m_mapXRight;
                    tipX = charaPos.m_tipXRight;
                    break;
                }

                // ひとつ下のチップをチェック
                EnumShapeType bottomShape = GetShape(mapX, charaPos.m_mapY - 1, charaPos.m_mapZ);

                bool isFloat = false;

                switch (bottomShape)
                {
                case EnumShapeType.Box:
                    isFloat = false;
                    break;

                case EnumShapeType.BSlashWall:
                    isFloat = (tipX < (TIP_SIZE - 1 - charaPos.m_tipZ));
                    break;

                case EnumShapeType.SlashWall:
                    isFloat = (tipX > charaPos.m_tipZ);
                    break;

                default:
                    isFloat = true;
                    break;
                }

                return(isFloat);
            }
Пример #12
0
                // WithBogusLine returns a bogus line that won't match any recorded for the source code.
                // Its use is to disrupt the statements within an infinite loop so that the debugger
                // will not itself loop infinitely waiting for the line number to change.
                // gdb chooses not to display the bogus line; delve shows it with a complaint, but the
                // alternative behavior is to hang.
                public static XPos WithBogusLine(this XPos p) => func((_, panic, __) =>
                {
                    if (p.index == 0L)
                    {
                        // See #35652
                        panic("Assigning a bogus line to XPos with no file will cause mysterious downstream failures.");
                    }

                    p.lico = makeBogusLico();
                    return(p);
                });
Пример #13
0
        public VectorInput(PropertyInfo prop, object owner, NodeType type = NodeType.Float4, NumberInputType ntype = NumberInputType.Float)
        {
            InitializeComponent();
            property      = prop;
            propertyOwner = owner;

            switch (type)
            {
            case NodeType.Float2:
                ZPos.Visibility = Visibility.Collapsed;
                WPos.Visibility = Visibility.Collapsed;
                break;

            case NodeType.Float3:
                ZPos.Visibility = Visibility.Visible;
                WPos.Visibility = Visibility.Collapsed;
                break;

            case NodeType.Float4:
                ZPos.Visibility = Visibility.Visible;
                WPos.Visibility = Visibility.Visible;
                break;
            }

            object b = prop.GetValue(owner);

            if (b == null)
            {
                pc = new VectorPropertyContainer(new MVector());
            }
            else
            {
                MVector vec = (MVector)b;
                pc = new VectorPropertyContainer(vec);
            }

            pc.OnUpdate += Pc_OnUpdate;

            var xprop = pc.GetType().GetProperty("XProp");
            var yprop = pc.GetType().GetProperty("YProp");
            var zprop = pc.GetType().GetProperty("ZProp");
            var wprop = pc.GetType().GetProperty("WProp");

            XPos.Set(ntype, pc, xprop);
            YPos.Set(ntype, pc, yprop);
            ZPos.Set(ntype, pc, zprop);
            WPos.Set(ntype, pc, wprop);
        }
Пример #14
0
            private void CheckZBox(XPos xPos, ref CharaPos charaPos, ref CharaLastPos charaLastPos,
                                   ref CharaFlag charaFlag, ref CharaQueue charaQueue)
            {
                // MapZ移動が無いときはZチェックしない
                if (charaPos.m_mapZ == charaLastPos.m_mapZ)
                {
                    return;
                }

                int mapX = 0;

                switch (xPos)
                {
                case XPos.Left:
                    mapX = charaPos.m_mapXLeft;
                    break;

                case XPos.Center:
                    mapX = charaPos.m_mapXCenter;
                    break;

                case XPos.Right:
                    mapX = charaPos.m_mapXRight;
                    break;
                }

                // 手前が壁以外のときのみ壁チェック
                EnumShapeType frontShape = GetShape(mapX, charaPos.m_mapY, charaPos.m_mapZ - 1);

                if (frontShape.IsBox())
                {
                    return;
                }

                // ブロックのみ補正行う、斜め壁は別途
                EnumShapeType shape = GetShape(mapX, charaPos.m_mapY, charaPos.m_mapZ);

                if (!shape.IsBox())
                {
                    return;
                }


                int newRZ = (charaPos.m_mapZ << PIX_MAP) - 1;

                Debug.Log($"charaPos.m_mapZ : {charaPos.m_mapZ} charaLastPos.m_mapZ {charaLastPos.m_mapZ}");
                charaPos.SetPixZ(newRZ);
            }
Пример #15
0
 // WithIsStmt returns the same location to be marked with DWARF is_stmt=1
 public static XPos WithIsStmt(this XPos p)
 {
     p.lico = p.lico.withIsStmt();
     return(p);
 }
Пример #16
0
 /// Linear interpolation of XPos.
 public static XPos Lerp(this Interpolated <XPos> lerp, float alpha)
 {
     return(XPos.Lerp(alpha, lerp.V0, lerp.V1));
 }
Пример #17
0
 // SameFileAndLine reports whether p and q are positions on the same line in the same file.
 public static bool SameFileAndLine(this XPos p, XPos q)
 {
     return(p.index == q.index && p.lico.SameLine(q.lico));
 }
Пример #18
0
 // SameFile reports whether p and q are positions in the same file.
 public static bool SameFile(this XPos p, XPos q)
 {
     return(p.index == q.index);
 }
Пример #19
0
 public override string ToString()
 {
     return(string.Format("{0}/{1}: {2}", XPos.ToString(), YPos.ToString(), MazeId));
 }
 public virtual void Draw()
 {
     Console.WriteLine(Name + ". X: " + XPos.ToString() + ", Y: " + YPos.ToString() + ".");
 }
Пример #21
0
            private void CheckYWall(XPos xPos, ref CharaPos charaPos, ref CharaLastPos charaLastPos,
                                    ref CharaFlag charaFlag, ref CharaQueue charaQueue)
            {
                // MapX移動が無いときはチェックしない
                if (charaPos.m_mapY == charaLastPos.m_mapY)
                {
                    return;
                }

                int mapX     = 0;
                int sideMapX = 0;

                switch (xPos)
                {
                case XPos.Left:
                    mapX     = charaPos.m_mapXLeft;
                    sideMapX = mapX + 1;
                    break;

                case XPos.Center:
                    mapX     = charaPos.m_mapXCenter;
                    sideMapX = mapX;
                    break;

                case XPos.Right:
                    mapX     = charaPos.m_mapXRight;
                    sideMapX = mapX - 1;
                    break;
                }

                EnumShapeType sideShape = GetShape(sideMapX, charaPos.m_mapY, charaPos.m_mapZ);

                // 横が坂の場合は判定しない
                if (sideShape.IsSlope())
                {
                    return;
                }

                EnumShapeType topShape = GetShape(mapX, charaPos.m_mapY + 1, charaPos.m_mapZ);
                EnumShapeType shape    = GetShape(mapX, charaPos.m_mapY, charaPos.m_mapZ);

                //ひとつ上と同じチップの場合はチェックしない
                if (shape == topShape)
                {
                    return;
                }

                // Yめり込みチェック
                bool isHit = false;

                switch (shape)
                {
                case EnumShapeType.Box:
                    isHit = true;
                    break;

                case EnumShapeType.BSlashWall:
                    isHit = (xPos == XPos.Right) && (charaPos.m_tipXRight >= (TIP_SIZE - 1 - charaPos.m_tipZ));
                    break;

                case EnumShapeType.SlashWall:
                    isHit = (xPos == XPos.Left) && (charaPos.m_tipXLeft <= charaPos.m_tipZ);
                    break;
                }

                if (isHit)
                {
                    int newY = (charaPos.m_mapY + 1) << PIX_MAP;
                    charaPos.SetPixY(newY);
                    QueueLand(ref charaFlag, ref charaQueue);
                }
            }
Пример #22
0
 public override string ToString()
 {
     return(string.Concat(XPos.ToString(), ' ', YPos.ToString()));
 }
Пример #23
0
        private void Process(Entity entity)
        {
            var pose            = this.world.Registry.Get <PoseComponent>(entity);
            var loco            = this.world.Registry.Get <DriveComponent>(entity);
            var position        = pose.Position;
            var facing          = pose.Facing;
            var speedType       = loco.SpeedType;
            var speed           = loco.Speed;
            var state           = loco.State;
            var flowField       = loco.FlowField;
            var movementVector  = loco.MovementVector;
            var destination     = loco.Destination;
            var currentPosition = position.V1;
            var nextPosition    = position.V1;
            var currentCell     = CPos.FromXPos(currentPosition);

            // The PreMove state determines the next cell in the path and whether the
            // final destination has been reached.
            if (state == DriveState.PreMove)
            {
                CardinalDirection dir;

                // destination reached -> Idle
                if (flowField == null || flowField.IsDestination(currentCell))
                {
                    state     = DriveState.Idle;
                    flowField = null;
                }
                // Get the next cell in the path and the movement direction and speed -> Moving
                else if (flowField.TryGetDirection(currentCell, out dir))
                {
                    var dirvec = dir.ToVector();
                    var spd    = flowField.SpeedAt(currentCell, speedType, speed);
                    movementVector = dirvec.Multiply(spd);
                    destination    = XPos.FromCell(currentCell.Translate(dirvec.X, dirvec.Y));
                    facing         = new BinaryAngle(dir);
                    state          = DriveState.Moving;
                }
                // Destination not reached but no next cell found -> Stuck
                else
                {
                    state     = DriveState.Stuck;
                    flowField = null;
                    Console.WriteLine("I'm stuck!");
                }
            }

            // The Moving state moves towards the destination cell at the predetermined speed,
            // then it will transition the state back to PreMove.
            if (state == DriveState.Moving)
            {
                var diff        = XPos.Sub(destination, currentPosition);
                var contheading = true;

                var movlepx = Lepton.FromPixel(movementVector.X);
                var movlepy = Lepton.FromPixel(movementVector.Y);

                // reaching end of cell
                if (Math.Abs(diff.LeptonsX) < Math.Abs(movlepx) || Math.Abs(diff.LeptonsY) < Math.Abs(movlepy))
                {
                    // check if next cell in the path follows the same direction
                    var dirvec = facing.CardinalDirection.ToVector();
                    var next   = currentCell.Translate(dirvec.X, dirvec.Y);
                    CardinalDirection nextdir;
                    var notAtEndOfPath = flowField.TryGetDirection(next, out nextdir);
                    contheading = notAtEndOfPath && (nextdir == facing.CardinalDirection);
                    state       = DriveState.PreMove;
                }

                if (contheading)
                {
                    nextPosition = XPos.Add(currentPosition, XPos.FromLeptons(movlepx, movlepy));
                }
                else
                {
                    nextPosition = destination;
                }
            }

            // Write the new state to the registry.
            position = position.Advance(nextPosition);
            pose     = new PoseComponent(position, facing);
            loco     = new DriveComponent(speedType, speed, state, flowField, movementVector, destination);
            this.world.Registry.Set(entity, pose);
            this.world.Registry.Set(entity, loco);
        }
Пример #24
0
 // AtColumn1 returns the same location but shifted to column 1.
 public static XPos AtColumn1(this XPos p)
 {
     p.lico = p.lico.atColumn1();
     return(p);
 }
Пример #25
0
 public override String ToString()
 {
     return(XPos.ToString() + ", " + YPos.ToString() + ", " + Width + ", " + Height + ", " + NoGoRate + ", " + GoTrial + ", " + Response);
 }
Пример #26
0
 // IsKnown reports whether the position p is known.
 // XPos.IsKnown() matches Pos.IsKnown() for corresponding
 // positions.
 public static bool IsKnown(this XPos p)
 {
     return(p.index != 0L || p.Line() != 0L);
 }
Пример #27
0
 // WithXlogue returns the same location but marked with DWARF function prologue/epilogue
 public static XPos WithXlogue(this XPos p, PosXlogue x)
 {
     p.lico = p.lico.withXlogue(x);
     return(p);
 }
Пример #28
0
            private void CheckXZSlashWall(XPos xPos, ref CharaPos charaPos, ref CharaLastPos charaLastPos,
                                          ref CharaFlag charaFlag, ref CharaQueue charaQueue)
            {
                int mapX    = 0;
                int tipX    = 0;
                int offsetX = 0;

                switch (xPos)
                {
                case XPos.Left:
                    mapX    = charaPos.m_mapXLeft;
                    tipX    = charaPos.m_tipXLeft;
                    offsetX = +1 + SIDE_OFFSET;
                    break;

                case XPos.Center:
                    mapX = charaPos.m_mapXCenter;
                    tipX = charaPos.m_tipXCenter;
                    break;

                case XPos.Right:
                    mapX    = charaPos.m_mapXRight;
                    tipX    = charaPos.m_tipXRight;
                    offsetX = -1 - SIDE_OFFSET;
                    break;
                }

                EnumShapeType shape = GetShape(mapX, charaPos.m_mapY, charaPos.m_mapZ);

                if (!shape.IsSlashWall())
                {
                    return;
                }


                int  moveX    = math.abs(charaPos.m_posX - charaLastPos.m_posX);
                int  moveZ    = math.abs(charaPos.m_posZ - charaLastPos.m_posZ);
                bool isZSlide = (moveX > moveZ);

                if (isZSlide)
                {
                    // 斜め壁座標
                    int  borderX = 0;
                    int  shiftZ  = 0;
                    bool isHit   = false;
                    switch (shape)
                    {
                    case EnumShapeType.SlashWall:
                        borderX = charaPos.m_tipZ;
                        shiftZ  = -(tipX + 1);
                        isHit   = tipX <= borderX;
                        break;

                    case EnumShapeType.BSlashWall:
                        borderX = TIP_SIZE - 1 - charaPos.m_tipZ;
                        shiftZ  = -(TIP_SIZE - tipX);
                        isHit   = tipX >= borderX;
                        break;
                    }

                    if (isHit)
                    {
                        int newZ = ((charaPos.m_mapZ + 1) << PIX_MAP) + shiftZ;
                        charaPos.SetPixZ(newZ);
                    }
                }
                else
                {
                    int borderZ = 0;
                    int shiftX  = 0;
                    switch (shape)
                    {
                    case EnumShapeType.SlashWall:
                        borderZ = tipX;
                        shiftX  = charaPos.m_tipZ + 1;
                        break;

                    case EnumShapeType.BSlashWall:
                        borderZ = TIP_SIZE - 1 - tipX;
                        shiftX  = -(TIP_SIZE - charaPos.m_tipZ);
                        break;
                    }

                    if (charaPos.m_tipZ >= borderZ)
                    {
                        int newX = (mapX << PIX_MAP) + shiftX + offsetX;
                        charaPos.SetPixX(newX);
                    }
                }
            }
Пример #29
0
 public override string ToString()
 {
     return("Y: " + YPos.ToString() + " X: " + XPos.ToString() + " Aim: " + Aim.ToString());
 }
Пример #30
0
 // FileIndex returns a smallish non-negative integer corresponding to the
 // file for this source position.  Smallish is relative; it can be thousands
 // large, but not millions.
 public static int FileIndex(this XPos p)
 {
     return(p.index);
 }