private static void MyId_DataChanged(object sender, GlobalEventData <Guid> e)
        {
            if (e.isDefault)
            {
                // Initialized, no other Globals with this name yet
                return;
            }

            using (gPlantData = new Global <PlantData>(e.Data.ToString()))
            {
                // Create a random generator helping to simulate the data
                Random r = new Random();
                for (int i = 0; i < 100; i++)
                {
                    var pd = new PlantData()
                    {
                        ID    = i + 1,
                        Class = (int)(r.NextDouble() * 4),
                        LA    = r.NextDouble() * 100
                    };

                    Console.WriteLine("Sending: " + pd);

                    // The actual sending
                    gPlantData.Value = pd;
                }
            }
        }
 private static void GPlantData_DataChanged(object sender, GlobalEventData <PlantData> e)
 {
     if (!e.isInitialValue)
     {
         Console.WriteLine("Received: " + e.Data);
     }
 }
        private static void Start_DataChanged(object sender, GlobalEventData <bool> e)
        {
            if (e.isDefault)
            {   // initialization completed.
                // No other Globals with the same name yet
                return;
            }
            if (e.Data)
            {
                // Create a random generator helping to simulate the data
                Random r = new Random();
                for (int i = 0; i < 100; i++)
                {
                    var pd = new PlantData()
                    {
                        ID    = i + 1,
                        Class = (int)(r.NextDouble() * 4),
                        LA    = r.NextDouble() * 100
                    };


                    Console.WriteLine("Sending: " + pd);

                    // The actual sending
                    gPlantData.Value = pd;
                }
            }
        }
 private static void Id_DataChanged(object sender, GlobalEventData <Guid> e)
 {
     if (!e.isInitialValue && e.Data == messageId)
     {
         Console.WriteLine("Message delivery is confirmed!");
     }
 }
Exemple #5
0
        private static void FileTransfer_DataChanged(object sender, GlobalEventData <FileData> e)
        {
            if (e.isDefault)
            {
                // In that case: no other Globals yet, object gets the default value (is this case: null)
                return;
            }

            if (e.fromSelf)
            {
                Console.WriteLine(e.Data.filename + " sent!");
            }
            else
            {
                Console.WriteLine("File " + e.Data.filename + " received from " + e.Data.Name);

                // Create dest dir, if non existent
                if (!Directory.Exists(ToReceive))
                {
                    Directory.CreateDirectory(ToReceive);
                }

                // Write file
                string destFile = (Path.Combine(ToReceive, e.Data.filename));
                using (var fs = new FileStream(destFile, FileMode.Create, FileAccess.Write))
                {
                    fs.Write(e.Data.data, 0, e.Data.data.Length);
                }

                Console.WriteLine("File " + e.Data.filename + " written to " + destFile);
            }
        }
 private static void MyText_DataChanged(object sender, GlobalEventData <string> e)
 {
     if (!e.isInitialValue && !e.fromSelf)
     {
         Console.WriteLine(e.Data);
     }
 }
        private static void MyText_DataChanged(object sender, GlobalEventData <string> e)
        {
            if (e.isInitialValue || e.fromSelf)
            {
                return;
            }

            Console.WriteLine(e.Data);

            // Automatic Hi! response for new members:
            int index = e.Data.IndexOf(" has entered the building");

            if (index > -1)
            {
                string newName = e.Data.Substring(0, e.Data.Length - " has entered the building".Length);
                if (newName != _name)
                {
                    MyText.Value = _name + " says: Hi " + newName + "!";
                }
            }

            // Automatic Bey! response for left members:
            index = e.Data.IndexOf(" has left the building");
            if (index > -1)
            {
                string newName = e.Data.Substring(0, e.Data.Length - " has left the building".Length);
                if (newName != _name)
                {
                    MyText.Value = _name + " says: Bye " + newName + "!";
                }
            }
        }
Exemple #8
0
        private void ServerOnline_DataChanged(object sender, GlobalEventData <bool> e)
        {
            if (e.isDefault)
            {
                return;
            }

            HandleInMainThread2(lbYes, e);
        }
Exemple #9
0
 private void HandleInMainThread(Control c, GlobalEventData <int> e)
 {
     if (c.InvokeRequired)
     {
         c.BeginInvoke(new HandleInMainThreadDelegate(HandleInMainThread), new object[] { c, e });
     }
     else
     {
         c.Text = e.Data.ToString();
     }
 }
Exemple #10
0
 private void HandleInMainThread2(Control c, GlobalEventData <bool> e)
 {
     if (c.InvokeRequired)
     {
         c.BeginInvoke(new HandleInMainThreadDelegate2(HandleInMainThread2), new object[] { c, e });
     }
     else
     {
         Enable(e.Data);
     }
 }
Exemple #11
0
        private static void Message_DataChanged(object sender, GlobalEventData <Envellope> e)
        {
            if (!e.isDefault)
            {
                // Received!
                Console.WriteLine(e.Data.Data);

                // Confirming...
                using (var Id = new Global <Guid>("IdCheck"))
                {
                    Id.Value = e.Data.ID;
                };
            }
        }
Exemple #12
0
        private void Yes_DataChanged(object sender, GlobalEventData <bool> e)
        {
            if (e.isInitialValue)
            {
                return;
            }

            if (e.Data)
            {
                TotalYes.Value = ++_totalYes;
                HandleInMainThread(lbYesCnt, _totalYes);
            }
            else
            {
                TotalNo.Value = ++_totalNo;
                HandleInMainThread(lbNoCnt, _totalNo);
            }
        }
 private static void SomeText_DataChanged(object sender, GlobalEventData <string> e)
 {
     // The data is received here!
     Console.WriteLine(e.Data);
 }
Exemple #14
0
 private void TotalYes_DataChanged(object sender, GlobalEventData <int> e)
 {
     HandleInMainThread(lbYesCnt, e);
 }
Exemple #15
0
    /*
    ============================================================================
    Init functions
    ============================================================================
    */
    public void Init()
    {
        // first init languages
        languages = new LanguageData();

        statusValues = new  StatusValueData();
        elements = new  ElementData();
        races = new RaceData();
        sizes = new SizeData();
        areaNames = new AreaNameData();
        armors = new ArmorData();
        cameraPositions = new  CameraPositionData();
        attacks = new BaseAttackData();
        characters = new  CharacterData();
        classes = new  ClassData();
        colors = new  ColorData();
        dialoguePositions = new  DialoguePositionData();
        battleAIs = new  BattleAIData();
        enemies = new  EnemyData();
        equipParts = new  EquipmentPartData();
        formulas = new  FormulaData();
        gameSettings = new  GameSettingsData();
        items = new  ItemData();
        itemTypes = new  ItemTypeData();
        loadSaveHUD = new LoadSaveHUDData();
        mainMenu = new MainMenuData();
        skillTypes = new  SkillTypeData();
        effects = new  StatusEffectData();
        skills = new  SkillData();
        weapons = new  WeaponData();
        music = new MusicData();
        huds = new HUDData();
        recipes = new ItemRecipeData();
        fonts = new FontData();
        globalEvents = new GlobalEventData();
        teleports = new TeleportData();
        difficulties = new DifficultyData();

        // battle system
        battleAnimations = new BattleAnimationData();
        battleSystem = new BattleSystemData();
    }