Example #1
0
        public static string GetPuPosString()
        {
            var marioAddress = Config.Mario.StructAddress;

            // Get Mario position
            float marioX, marioZ;

            marioX = Config.Stream.GetSingle(marioAddress + Config.Mario.XOffset);
            marioZ = Config.Stream.GetSingle(marioAddress + Config.Mario.ZOffset);

            // Update PU
            int puX = PuUtilities.GetPUFromCoord(marioX);
            int puZ = PuUtilities.GetPUFromCoord(marioZ);

            return(string.Format("[{0}:{1}]", puX, puZ));
        }
Example #2
0
        public static string GetPuPosString(ProcessStream stream)
        {
            var marioAddress = Config.Mario.StructAddress;

            // Get Mario position
            float marioX, marioZ;

            marioX = BitConverter.ToSingle(stream.ReadRam(marioAddress + Config.Mario.XOffset, 4), 0);
            marioZ = BitConverter.ToSingle(stream.ReadRam(marioAddress + Config.Mario.ZOffset, 4), 0);

            // Update PU
            int puX = PuUtilities.GetPUFromCoord(marioX);
            int puZ = PuUtilities.GetPUFromCoord(marioZ);

            return(string.Format("[{0}:{1}]", puX, puZ));
        }
Example #3
0
        public static bool MoveToPu(int newPuX, int newPuY, int newPuZ)
        {
            var marioAddress = Config.Mario.StructAddress;

            // Get Mario position
            float marioX, marioY, marioZ;

            marioX = Config.Stream.GetSingle(marioAddress + Config.Mario.XOffset);
            marioY = Config.Stream.GetSingle(marioAddress + Config.Mario.YOffset);
            marioZ = Config.Stream.GetSingle(marioAddress + Config.Mario.ZOffset);


            // Get Camera Position
            float cameraX, cameraY, cameraZ;

            cameraX = Config.Stream.GetSingle(Config.Camera.CameraStructAddress + Config.Camera.XOffset);
            cameraY = Config.Stream.GetSingle(Config.Camera.CameraStructAddress + Config.Camera.YOffset);
            cameraZ = Config.Stream.GetSingle(Config.Camera.CameraStructAddress + Config.Camera.ZOffset);

            // Calculate new coordinates
            float newMarioX, newMarioY, newMarioZ;

            newMarioX = PuUtilities.GetRelativePuPosition(marioX) + newPuX * PuSize;
            newMarioY = PuUtilities.GetRelativePuPosition(marioY) + newPuY * PuSize;
            newMarioZ = PuUtilities.GetRelativePuPosition(marioZ) + newPuZ * PuSize;

            float newCamX, newCamY, newCamZ;

            newCamX = PuUtilities.GetRelativePuPosition(cameraX) + newPuX * PuSize;
            newCamY = PuUtilities.GetRelativePuPosition(cameraY) + newPuY * PuSize;
            newCamZ = PuUtilities.GetRelativePuPosition(cameraZ) + newPuZ * PuSize;

            // Set new mario + camera position
            bool success = true;

            success &= Config.Stream.SetValue(newMarioX, marioAddress + Config.Mario.XOffset);
            success &= Config.Stream.SetValue(newMarioY, marioAddress + Config.Mario.YOffset);
            success &= Config.Stream.SetValue(newMarioZ, marioAddress + Config.Mario.ZOffset);
            if (Config.MoveCameraWithPu)
            {
                success &= Config.Stream.SetValue(newCamX, Config.Camera.CameraStructAddress + Config.Camera.XOffset);
                success &= Config.Stream.SetValue(newCamY, Config.Camera.CameraStructAddress + Config.Camera.YOffset);
                success &= Config.Stream.SetValue(newCamZ, Config.Camera.CameraStructAddress + Config.Camera.ZOffset);
            }
            return(success);
        }
Example #4
0
        public static bool MoveToPu(ProcessStream stream, int newPuX, int newPuY, int newPuZ)
        {
            var marioAddress = Config.Mario.StructAddress;

            // Get Mario position
            float marioX, marioY, marioZ;

            marioX = BitConverter.ToSingle(stream.ReadRam(marioAddress + Config.Mario.XOffset, 4), 0);
            marioY = BitConverter.ToSingle(stream.ReadRam(marioAddress + Config.Mario.YOffset, 4), 0);
            marioZ = BitConverter.ToSingle(stream.ReadRam(marioAddress + Config.Mario.ZOffset, 4), 0);


            // Get Camera Position
            float cameraX, cameraY, cameraZ;

            cameraX = BitConverter.ToSingle(stream.ReadRam(Config.CameraX, 4), 0);
            cameraY = BitConverter.ToSingle(stream.ReadRam(Config.CameraY, 4), 0);
            cameraZ = BitConverter.ToSingle(stream.ReadRam(Config.CameraZ, 4), 0);

            // Calculate new coordinates
            float newMarioX, newMarioY, newMarioZ;

            newMarioX = PuUtilities.GetRelativePuPosition(marioX) + newPuX * PuSize;
            newMarioY = PuUtilities.GetRelativePuPosition(marioY) + newPuY * PuSize;
            newMarioZ = PuUtilities.GetRelativePuPosition(marioZ) + newPuZ * PuSize;

            float newCamX, newCamY, newCamZ;

            newCamX = PuUtilities.GetRelativePuPosition(cameraX) + newPuX * PuSize;
            newCamY = PuUtilities.GetRelativePuPosition(cameraY) + newPuY * PuSize;
            newCamZ = PuUtilities.GetRelativePuPosition(cameraZ) + newPuZ * PuSize;

            // Set new mario + camera position
            bool success = true;

            success &= stream.WriteRam(BitConverter.GetBytes(newMarioX), marioAddress + Config.Mario.XOffset);
            success &= stream.WriteRam(BitConverter.GetBytes(newMarioY), marioAddress + Config.Mario.YOffset);
            success &= stream.WriteRam(BitConverter.GetBytes(newMarioZ), marioAddress + Config.Mario.ZOffset);
            if (Config.MoveCameraWithPu)
            {
                success &= stream.WriteRam(BitConverter.GetBytes(newCamX), Config.CameraX);
                success &= stream.WriteRam(BitConverter.GetBytes(newCamY), Config.CameraY);
                success &= stream.WriteRam(BitConverter.GetBytes(newCamZ), Config.CameraZ);
            }
            return(success);
        }