Example #1
0
 /// <summary>
 /// Bind a function Callback(Core:FlxCore,X:uint,Y:uint,Tile:uint) to a range of tiles.
 /// Temporarily deprecated.
 /// </summary>
 /// <param name="Tile">The tile to trigger the callback.</param>
 /// <param name="Callback">The function to trigger.  Parameters should be <code>(Core:FlxCore,X:uint,Y:uint,Tile:uint)</code>.</param>
 /// <param name="Range">If you want this callback to work for a bunch of different tiles, input the range here.  Default value is 1.</param>
 public void setCallback(int Tile, int Callback, int Range)
 {
     FlxG.log("WARNING: FlxTilemap.setCallback()\nhas been temporarily deprecated.");
     //if(Range <= 0) return;
     //for(var i:uint = Tile; i < Tile+Range; i++)
     //	_callbacks[i] = Callback;
 }
Example #2
0
 /// <summary>
 /// Allows the FlxConsole to run commands.
 /// </summary>
 /// <param name="Cheat">Name of the cheat you want to run.</param>
 public static void runCheat(string Cheat)
 {
     if (Cheat.StartsWith("whatisgame"))
     {
         FlxG.log("Four Chambers");
     }
     else if (Cheat.StartsWith("bigmoney"))
     {
         FlxG.score += 20000;
     }
     else if (Cheat.StartsWith("nobugs"))
     {
         FlxG.debug = false;
     }
     else if (Cheat == "bounds")
     {
         FlxG.showBounds = true;
     }
     else if (Cheat == "nobounds")
     {
         FlxG.showBounds = false;
     }
     else if (Cheat.StartsWith("level"))
     {
         FlxG.level = Convert.ToInt32(Cheat.Substring(5).ToString());
     }
     cheatString = Cheat;
 }
Example #3
0
 /// <summary>
 /// If you don't like to access the data object directly, you can use this to read from it.
 /// </summary>
 /// <param name="FieldName">The name of the data field you want to read</param>
 /// <returns>The value of the data field you are reading (null if it doesn't exist).</returns>
 public string read(string FieldName)
 {
     if (_so == null)
     {
         FlxG.log("WARNING: You must call FlxSave.bind()\nbefore calling FlxSave.read().");
         return(null);
     }
     return(data[FieldName]);
 }
Example #4
0
 /// <summary>
 /// If you don't like to access the data object directly, you can use this to write to it.
 /// </summary>
 /// <param name="FieldName">The name of the data field you want to create or overwrite.</param>
 /// <param name="FieldValue">The data you want to store.</param>
 /// <param name="MinFileSize">If you need X amount of space for your save, specify it here.</param>
 /// <returns>Whether or not the write and flush were successful.</returns>
 public bool write(string FieldName, string FieldValue, uint MinFileSize)
 {
     if (_so == null)
     {
         FlxG.log("WARNING: You must call FlxSave.bind()\nbefore calling FlxSave.write().");
         return(false);
     }
     data[FieldName] = FieldValue;
     return(forceSave(MinFileSize));
 }
Example #5
0
        /**
         * Useful for finding out how long it takes to execute specific blocks of code.
         *
         * @param	Start	A <code>uint</code> created by <code>FlxU.startProfile()</code>.
         * @param	Name	Optional tag (for debug console display).  Default value is "Profiler".
         * @param	Log		Whether or not to log this elapsed time in the debug console.
         *
         * @return	A <code>uint</code> to be passed to <code>FlxU.endProfile()</code>.
         */
        static public uint endProfile(uint Start, string Name, bool Log)
        {
            uint t = FlxG.getTimer;

            if (Log)
            {
                FlxG.log(Name + ": " + ((t - Start) / 1000) + "s");
            }
            return(t);
        }
Example #6
0
 /// <summary>
 /// Erases everything stored in the local shared object.
 /// </summary>
 /// <param name="MinFileSize">If you need X amount of space for your save, specify it here.</param>
 /// <returns>Whether or not the clear and flush was successful.</returns>
 public bool erase(uint MinFileSize)
 {
     if (_so == null)
     {
         FlxG.log("WARNING: You must call FlxSave.bind()\nbefore calling FlxSave.erase().");
         return(false);
     }
     _savedata = null;
     forceSave(MinFileSize);
     _savedata = new FlxSaveData();
     return(true);
 }
Example #7
0
        /// <summary>
        /// Automatically creates or reconnects to locally saved data.
        /// </summary>
        /// <param name="Name">The name of the object (should be the same each time to access old data).</param>
        /// <returns>Whether or not you successfully connected to the save data.</returns>
        public bool bind(string Name)
        {
            _so  = null;
            name = Name;



            try
            {
                _savedata = new FlxSaveData();

                // Open a storage container.
                IAsyncResult result =
                    _device.BeginOpenContainer(Name, null, null);
                // Wait for the WaitHandle to become signaled.
                result.AsyncWaitHandle.WaitOne();

                _so = _device.EndOpenContainer(result);

                // Close the wait handle.
                result.AsyncWaitHandle.Close();

                // Check to see whether the save exists.
                if (!_so.FileExists(_savefile))
                {
                    // If not, dispose of the container and return new blank data.
                    _so.Dispose();
                    _savedata = new FlxSaveData();
                    return(true);
                }
                // Open the file.
                Stream stream = _so.OpenFile(_savefile, FileMode.Open);

                _savedata.deserialize(stream);

                // Close the file.
                stream.Close();
                // Dispose the container.
                _so.Dispose();
            }
            catch
            {
                FlxG.log("WARNING: There was a problem binding to\nthe shared object data from FlxSave.");
                name      = null;
                _so       = null;
                _savedata = null;
                return(false);
            }


            return(true);
        }
Example #8
0
 public void start(bool Explode, float Delay, int Quantity)
 {
     if (members.Count <= 0)
     {
         FlxG.log("WARNING: there are no sprites loaded in your emitter.\nAdd some to FlxEmitter.members or use FlxEmitter.createSprites().");
         return;
     }
     _explode = Explode;
     if (!_explode)
     {
         _counter = 0;
     }
     if (!exists)
     {
         _particle = 0;
     }
     exists  = true;
     visible = true;
     active  = true;
     dead    = false;
     on      = true;
     _timer  = 0;
     if (quantity == 0)
     {
         quantity = Quantity;
     }
     else if (Quantity != 0)
     {
         quantity = Quantity;
     }
     if (Delay != 0)
     {
         delay = Delay;
     }
     if (delay < 0)
     {
         delay = -delay;
     }
     if (delay == 0)
     {
         if (Explode)
         {
             delay = 3;                          //default value for particle explosions
         }
         else
         {
             delay = 0.1f;                    //default value for particle streams
         }
     }
 }
Example #9
0
        /// <summary>
        /// Writes the local shared object to disk immediately.
        /// </summary>
        /// <param name="MinFileSize">If you need X amount of space for your save, specify it here.</param>
        /// <returns>Whether or not the flush was successful.</returns>
        public bool forceSave(uint MinFileSize)
        {
            if (_so == null)
            {
                FlxG.log("WARNING: You must call FlxSave.bind()\nbefore calling FlxSave.forceSave().");
                return(false);
            }
            try
            {
                // Open a storage container.
                IAsyncResult result =
                    _device.BeginOpenContainer(name, null, null);
                // Wait for the WaitHandle to become signaled.
                result.AsyncWaitHandle.WaitOne();
                _so = _device.EndOpenContainer(result);
                // Close the wait handle.
                result.AsyncWaitHandle.Close();

                // Check to see whether the save exists.
                if (_so.FileExists(_savefile))
                {
                    // Delete it so that we can create one fresh.
                    _so.DeleteFile(_savefile);
                }

                // Create the file.
                Stream stream = _so.CreateFile(_savefile);
                // Convert the object to XML data and put it in the stream.
                _savedata.serialize(stream);
                // Close the file.
                stream.Close();
                // Dispose the container, to commit changes.
                _so.Dispose();
            }
            catch
            {
                FlxG.log("WARNING: There was a problem flushing\nthe shared object data from FlxSave.");
                return(false);
            }
            return(true);
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="PointsX"></param>
        /// <param name="PointsY"></param>
        public void addPointsUsingStrings(string PointsX, string PointsY, int OffsetX, int OffsetY)
        {
            string[] splX = PointsX.Split(',');
            string[] splY = PointsY.Split(',');

            if (splX.Length != splY.Length)
            {
                FlxG.log("Length of both paths does not match");

                return;
            }


            for (int i = 0; i < splX.Length; i++)
            {
                //Console.WriteLine(splX[i]);

                if (splX[i] != "" || splY[i] != "")
                {
                    add(float.Parse(splX[i]) + OffsetX, float.Parse(splY[i]) + OffsetY);
                }
            }
        }
Example #11
0
 /**
  * Bind a function Callback(Core:FlxCore,X:uint,Y:uint,Tile:uint) to a range of tiles.
  *
  * @param	Tile		The tile to trigger the callback.
  * @param	Callback	The function to trigger.  Parameters should be <code>(Core:FlxCore,X:uint,Y:uint,Tile:uint)</code>.
  * @param	Range		If you want this callback to work for a bunch of different tiles, input the range here.  Default value is 1.
  */
 public void setCallback(int Tile, int Callback, int Range)
 {
     FlxG.log("WARNING: FlxTilemap.setCallback()\nhas been temporarily deprecated.");
 }