public static void AddGUID(this IServiceCollection services)
 {
     services.AddSingleton <IGenerator>((serviceProvider) =>
     {
         var provider = new GUIDGenerator();
         return(provider);
     });
 }
Example #2
0
        public AssetReferenceGameObject Build()
        {
            this.AssetGUID = GUIDGenerator.GenerateDeterministicGUID(this.AssetID);
            var assetRef = new AssetReferenceGameObject();

            AccessTools.Field(typeof(AssetReferenceGameObject), "m_debugName").SetValue(assetRef, this.AssetLoadingInfo.FilePath);
            AccessTools.Field(typeof(AssetReferenceGameObject), "m_AssetGUID").SetValue(assetRef, this.AssetGUID);
            return(assetRef);
        }
Example #3
0
        public static List <Player> LoadAll()
        {
            List <Player> players = DeserializeFile <List <Player> >(FileDb);

            if (players != null)
            {
                GUIDGenerator.SetGUID(players.Max(p => p.PlayerId));
            }
            return(players ?? new List <Player>());
        }
Example #4
0
        public void TestMethod1()
        {
            var connectionString = new ConnectionString
                                   (
                properties: new NameValueCollection
            {
                { "userid", "sa" },
                { "password", "eq123!@#" },
                { "passwordKey", "" },
                { "database", "JAC" },
                { "datasource", "192.168.1.200" }
            },
                connectionToken: "Password=${password};Persist Security Info=True;User ID=${userid};Initial Catalog=${database};Data Source=${datasource};pooling=true;min pool size=5;max pool size=10"
                                   );
            //data source=192.168.16.122;initial catalog=NNEV;persist security info=True;user id=sa;password=P@ssw0rd;

            var provider = new DbProvider
            {
                ProviderName = "System.Data.SqlClient.SqlClientFactory, System.Data.SqlClient",
                //ProviderName = "MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data",
                //ProviderName = "Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess.Core",
                //ParameterPrefix = "@",
                ParameterPrefix = ":",
                SelectKey       = "SELECT @@IDENTITY;"
            };
            var guidGenerator           = new GUIDGenerator();
            var sqlServerPagerGenerator = new SqlServerPagerGenerator();

            var dbContext = new DbContext
                            (
                dbProvider: provider,
                connectionString: connectionString,
                generator: guidGenerator,
                pagerGenerator: sqlServerPagerGenerator
                            );

            var loggerFactory = new LoggerFactory();

            loggerFactory.AddConsole();

            var service = new SysConfigurationService(dbContext, loggerFactory);

            var list = service.GetEntityList(w => w.Category == "aviOperation");

            //using (var trans = service.GetTransaction())
            //{
            //    service.UpdateEntity(() => new SysConfiguration { Category = "aa" },w=>w.IsDelete==false, trans);
            //    trans.Rollback();
            //    trans.Commit();
            //}

            var count = list.Count;

            Assert.IsNotNull(list);
        }
 public void ResetGUIDTest()
 {
     for (int i = 0; i < 100; i++)
     {
         string number = i.ToString("X");
         GUIDGenerator.ResetProvider();
         string result1 = GUIDGenerator.GenerateDeterministicGUID(number);
         GUIDGenerator.ResetProvider();
         string result2 = GUIDGenerator.GenerateDeterministicGUID(number);
         Assert.AreEqual(result1, result2);
     }
 }
 public void ConsistencyTest()
 {
     GUIDGenerator.ResetProvider();
     for (int i = 0; i < 100; i++)
     {
         string genKey = i.ToString("X");
         string gen    = GUIDGenerator.GenerateDeterministicGUID(genKey);
         for (int j = 0; j < 100; j++)
         {
             string gen2 = GUIDGenerator.GenerateDeterministicGUID(genKey);
             Assert.AreEqual(gen, gen2);
         }
     }
 }
Example #7
0
        public static Dictionary <int, AccountData> LoadAll()
        {
            Dictionary <int, AccountData> accounts = new Dictionary <int, AccountData>();

            foreach (var a in MysqlDB.SelectAll(new MysqlQuery(SELECT_QUERY)))
            {
                AccountData data = new AccountData()
                {
                    Id          = Convert.ToInt32(a["guid"]),
                    Login       = Convert.ToString(a["username"]),
                    Password    = Convert.ToString(a["password"]),
                    AccessLevel = Convert.ToInt32(a["access_level"])
                };
                GUIDGenerator.SetGUID(data.Id);
                accounts.Add(data.Id, data);
            }
            return(accounts);
        }
        /// <summary>
        /// Get the relic data corresponding to the given ID
        /// </summary>
        /// <param name="relicID">ID of the relic to get</param>
        /// <returns>The relic data for the given ID</returns>
        public static CollectableRelicData GetRelicDataByID(string relicID)
        {
            // Search for custom relic matching ID
            var guid = GUIDGenerator.GenerateDeterministicGUID(relicID);

            if (CustomRelicData.ContainsKey(guid))
            {
                return(CustomRelicData[guid]);
            }

            // No custom relic found; search for vanilla relic matching ID
            var vanillaRelic = ProviderManager.SaveManager.GetAllGameData().FindCollectableRelicData(relicID);

            if (vanillaRelic == null)
            {
                Trainworks.Log(LogLevel.All, "Couldn't find relic: " + relicID + " - This will cause crashes.");
            }
            return(vanillaRelic);
        }
        /// <summary>
        /// Get the card data corresponding to the given ID
        /// </summary>
        /// <param name="cardID">ID of the card to get</param>
        /// <returns>The card data for the given ID</returns>
        public static CardData GetCardDataByID(string cardID)
        {
            // Search for custom card matching ID
            var guid = GUIDGenerator.GenerateDeterministicGUID(cardID);

            if (CustomCardData.ContainsKey(guid))
            {
                return(CustomCardData[guid]);
            }

            // No custom card found; search for vanilla card matching ID
            var vanillaCard = ProviderManager.SaveManager.GetAllGameData().FindCardData(cardID);

            if (vanillaCard == null)
            {
                Trainworks.Log(LogLevel.All, "Couldn't find card: " + cardID + " - This will cause crashes.");
            }
            return(vanillaCard);
        }
        /// <summary>
        /// Get the character data corresponding to the given ID
        /// </summary>
        /// <param name="characterID">ID of the character to get</param>
        /// <returns>The character data for the given ID</returns>
        public static CharacterData GetCharacterDataByID(string characterID)
        {
            // Search for custom character matching ID
            var guid = GUIDGenerator.GenerateDeterministicGUID(characterID);

            if (CustomCharacterData.ContainsKey(guid))
            {
                return(CustomCharacterData[guid]);
            }

            // No custom card found; search for vanilla character matching ID
            var vanillaChar = ProviderManager.SaveManager.GetAllGameData().GetAllCharacterData().Find((chara) => {
                return(chara.GetID() == characterID);
            });

            if (vanillaChar == null)
            {
                Trainworks.Log(LogLevel.All, "Couldn't find character: " + characterID + " - This will cause crashes.");
            }
            return(vanillaChar);
        }
Example #11
0
            public bool UpdateEntity(ConfigurationEntity entity, string moduleName)
            {
                bool          result        = false;
                GUIDGenerator guidGenerator = new GUIDGenerator();

                entity.NewConfigurationId = guidGenerator.GenerateGUIDString(guidGenerator.ExtractUniqueId(entity.ConfigurationId), entity);
                string           commandText           = "UPDATE [tbl_config_detail] SET CONFIG_ID= @NEW_CONFIG_ID, DISPLAY_NAME = @DISPLAY_NAME, DEFAULT_VALUE = @DEFAULT_VALUE, ALLOWED_VALUE = @ALLOWED_VALUE, ALLOWED_PLACE_HOLDER = @ALLOWED_PLACE_HOLDER, Description = @Description, MODULE_NAME=@MODULE_NAME, LASTMODIFIED_TIMESTAMP=GETDATE() WHERE CONFIG_ID=@CONFIG_ID";
                int              affectedRows          = 0;
                TalentDataAccess talentSqlAccessDetail = new TalentDataAccess();
                ErrorObj         err = new ErrorObj();

                //Construct The Call
                talentSqlAccessDetail.Settings = settings;
                talentSqlAccessDetail.CommandElements.CommandExecutionType = CommandExecution.ExecuteNonQuery;
                talentSqlAccessDetail.CommandElements.CommandText          = commandText;
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@NEW_CONFIG_ID", entity.NewConfigurationId));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@DISPLAY_NAME", entity.DisplayName));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@DEFAULT_VALUE", entity.DefaultValue));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@ALLOWED_VALUE", entity.AllowedValues));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@ALLOWED_PLACE_HOLDER", entity.AllowedPlaceHolders));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@Description", entity.Description));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@CONFIG_ID", entity.ConfigurationId));
                talentSqlAccessDetail.CommandElements.CommandParameter.Add(Utilities.ConstructParameter("@MODULE_NAME", moduleName));
                //Execute
                err = talentSqlAccessDetail.SQLAccess(DestinationDatabase.TALENT_CONFIG);
                if ((!(err.HasError)) && (!(talentSqlAccessDetail.ResultDataSet == null)))
                {
                    affectedRows = System.Convert.ToInt32(talentSqlAccessDetail.ResultDataSet.Tables[0].Rows[0][0]);
                }
                talentSqlAccessDetail = null;
                if (affectedRows > 0)
                {
                    if (entity.ConfigurationId == entity.NewConfigurationId)
                    {
                        entity.NewConfigurationId = string.Empty;
                    }
                    return(true);
                }
                return(false);
            }
Example #12
0
        public static void CreateNewCharacter(Connection connection, CharacterData playerData)
        {
            var cached = new Player
            {
                AccountId     = connection.AccountInfo.Id,
                CharacterData = playerData
            };

            lock (PlayersLock)
            {
                if (Players.Exists(s => s.CharacterData.Name == playerData.Name))
                {
                    new SpFailCreateCharacter().Send(connection);
                    return;
                }
                cached.PlayerId = GUIDGenerator.NextGUID();
                cached.Level    = 1;
                Players.Add(cached);
            }
            new SpCreateCharacter(cached, connection).Send(connection, 1);
            Log.Info("New character created!");
        }
        public void UUIDVersion4Test()
        {
            Random random = new Random();

            for (int i = 0; i < 100; i++)
            {
                byte[] buffer = new byte[16];
                random.NextBytes(buffer);
                string conversion = System.Text.Encoding.UTF8.GetString(buffer);
                string gen        = GUIDGenerator.GenerateDeterministicGUID(conversion);

                // Check if Index 14 is 4
                Assert.AreEqual(gen[14], '4');

                // Check if Index 19 is a,b,8,or 9
                char testchar = gen[19];
                if (testchar != 'a' && testchar != 'b' && testchar != '8' && testchar != '9')
                {
                    Assert.IsTrue(testchar == 'a' || testchar == 'b' || testchar == '8' || testchar == '9');
                }
            }
        }
Example #14
0
    public static FighterData GenerateFighter()
    {
        FighterData newFighter = new FighterData();

        newFighter.id = GUIDGenerator.NewGuid();

        GachaDatabase gachaDatabase = GameDatabase.gachaDatabase;

        newFighter.name = gachaDatabase.GetRandomName();

        // TODO: Implement readonly interface for data.
        ClassData classData = gachaDatabase.GetRandomClass();

        newFighter.fighterClass = classData.fighterClass;

        newFighter.ATK            = classData.baseATK;
        newFighter.HP             = classData.baseHP;
        newFighter.fighterElement = gachaDatabase.GetRandomElement();


        // TEMP. TODO: Must define isRanged in Data.
        if (newFighter.fighterClass == Class.Warrior)
        {
            newFighter.isRanged = false;
        }
        else
        {
            newFighter.isRanged = true;
        }


        RandomizeEquipment(newFighter);
//		RandomizeSkin (newFighter);

        return(newFighter);
    }
Example #15
0
        public static string SetTokenForAccount(string account, string passwd)
        {
            var acc = _accounts.FirstOrDefault(ai => ai.Value.Login == account && ai.Value.Password == Funcs.CalculateMd5Hash(passwd)).Value;

            if (acc == null)
            {
                if (_accounts.Values.Any(inf => inf.Login.ToLower() == account.ToLower()))
                {
                    return(null);
                }
                lock (AccountsLock)
                {
                    acc = new AccountData {
                        Id = GUIDGenerator.NextGUID(), Login = account, Password = Funcs.CalculateMd5Hash(passwd)
                    };
                    _accounts.Add(acc.Id, acc);
                    AccountDB.Insert(acc);
                    Log.Info("Account '{0}' created", account);
                }
            }
            string token    = TokenGenerator.GenerateByAccount(acc);
            int    gameHash = TokenGenerator.GenerateSessionHash();

            if (_gameHashes.ContainsKey(acc.Id))
            {
                _gameHashes.Remove(acc.Id);
            }

            _gameHashes.Add(acc.Id, gameHash);
            _tokens.Add(token, acc);

            Log.Info("Set token '{0}' from account: {1}", token, account);
            Log.Info("Set GameHash '{0}' from account: {1}", gameHash, account);

            return(token);
        }
        /// <summary>
        /// Builds the CharacterData represented by this builder's parameters recursively;
        /// all Builders represented in this class's various fields will also be built.
        /// </summary>
        /// <returns>The newly created CharacterData</returns>
        public CharacterData Build()
        {
            CharacterData characterData = ScriptableObject.CreateInstance <CharacterData>();

            characterData.name = this.CharacterID;

            foreach (var builder in this.TriggerBuilders)
            {
                this.Triggers.Add(builder.Build());
            }
            foreach (var builder in this.RoomModifierBuilders)
            {
                this.RoomModifiers.Add(builder.Build());
            }

            var guid = GUIDGenerator.GenerateDeterministicGUID(this.CharacterID);

            AccessTools.Field(typeof(CharacterData), "id").SetValue(characterData, guid);
            AccessTools.Field(typeof(CharacterData), "animationController").SetValue(characterData, this.AnimationController);
            AccessTools.Field(typeof(CharacterData), "ascendsTrainAutomatically").SetValue(characterData, this.AscendsTrainAutomatically);
            AccessTools.Field(typeof(CharacterData), "attackDamage").SetValue(characterData, this.AttackDamage);
            AccessTools.Field(typeof(CharacterData), "attackTeleportsToDefender").SetValue(characterData, this.AttackTeleportsToDefender);
            AccessTools.Field(typeof(CharacterData), "bossActionGroups").SetValue(characterData, this.BossActionGroups);
            AccessTools.Field(typeof(CharacterData), "bossRoomSpellCastVFX").SetValue(characterData, this.BossRoomSpellCastVFX);
            AccessTools.Field(typeof(CharacterData), "bossSpellCastVFX").SetValue(characterData, this.BossSpellCastVFX);
            AccessTools.Field(typeof(CharacterData), "canAttack").SetValue(characterData, this.CanAttack);
            AccessTools.Field(typeof(CharacterData), "canBeHealed").SetValue(characterData, this.CanBeHealed);
            AccessTools.Field(typeof(CharacterData), "characterChatterData").SetValue(characterData, this.CharacterChatterData);
            AccessTools.Field(typeof(CharacterData), "characterLoreTooltipKeys").SetValue(characterData, this.CharacterLoreTooltipKeys);
            if (this.CharacterPrefabVariantRef == null)
            {
                if (this.CharacterPrefabVariantRefBuilder == null)
                {
                    if (this.BundleLoadingInfo != null)
                    {
                        this.BundleLoadingInfo.PluginPath     = this.BaseAssetPath;
                        this.CharacterPrefabVariantRefBuilder = new AssetRefBuilder
                        {
                            AssetLoadingInfo = this.BundleLoadingInfo
                        };
                    }
                    else
                    {
                        var assetLoadingInfo = new AssetLoadingInfo()
                        {
                            FilePath   = this.AssetPath,
                            PluginPath = this.BaseAssetPath,
                            AssetType  = AssetRefBuilder.AssetTypeEnum.Character
                        };
                        this.CharacterPrefabVariantRefBuilder = new AssetRefBuilder
                        {
                            AssetLoadingInfo = assetLoadingInfo
                        };
                    }
                }
                this.CharacterPrefabVariantRef = this.CharacterPrefabVariantRefBuilder.BuildAndRegister();
            }
            AccessTools.Field(typeof(CharacterData), "characterPrefabVariantRef").SetValue(characterData, this.CharacterPrefabVariantRef);
            AccessTools.Field(typeof(CharacterData), "characterSoundData").SetValue(characterData, this.CharacterSoundData);
            AccessTools.Field(typeof(CharacterData), "characterSpriteCache").SetValue(characterData, this.CharacterSpriteCache);
            AccessTools.Field(typeof(CharacterData), "deathSlidesBackwards").SetValue(characterData, this.DeathSlidesBackwards);
            AccessTools.Field(typeof(CharacterData), "deathType").SetValue(characterData, this.DeathType);
            AccessTools.Field(typeof(CharacterData), "deathVFX").SetValue(characterData, this.DeathVFX);
            AccessTools.Field(typeof(CharacterData), "fallbackData").SetValue(characterData, this.FallBackData);
            AccessTools.Field(typeof(CharacterData), "health").SetValue(characterData, this.Health);
            AccessTools.Field(typeof(CharacterData), "impactVFX").SetValue(characterData, this.ImpactVFX);
            AccessTools.Field(typeof(CharacterData), "isMiniboss").SetValue(characterData, this.IsMiniboss);
            AccessTools.Field(typeof(CharacterData), "isOuterTrainBoss").SetValue(characterData, this.IsOuterTrainBoss);
            BuilderUtils.ImportStandardLocalization(this.NameKey, this.Name);
            AccessTools.Field(typeof(CharacterData), "nameKey").SetValue(characterData, this.NameKey);
            AccessTools.Field(typeof(CharacterData), "projectilePrefab").SetValue(characterData, this.ProjectilePrefab);
            AccessTools.Field(typeof(CharacterData), "roomModifiers").SetValue(characterData, this.RoomModifiers);
            AccessTools.Field(typeof(CharacterData), "size").SetValue(characterData, this.Size);
            AccessTools.Field(typeof(CharacterData), "startingStatusEffects").SetValue(characterData, this.StartingStatusEffects);
            AccessTools.Field(typeof(CharacterData), "statusEffectImmunities").SetValue(characterData, this.StatusEffectImmunities);
            //AccessTools.Field(typeof(CardData), "stringBuilder").SetValue(cardData, this.);
            if (this.PriorityDraw)
            {
                this.SubtypeKeys.Add("SubtypesData_Chosen");
            }
            AccessTools.Field(typeof(CharacterData), "subtypeKeys").SetValue(characterData, this.SubtypeKeys);
            AccessTools.Field(typeof(CharacterData), "triggers").SetValue(characterData, this.Triggers);

            return(characterData);
        }
Example #17
0
        /// <summary>
        /// Builds the ClassData represented by this builder's parameters recursively;
        /// all Builders represented in this class's various fields will also be built.
        /// </summary>
        /// <returns>The newly created ClassData</returns>
        public ClassData Build()
        {
            ClassData classData = ScriptableObject.CreateInstance <ClassData>();

            classData.name = this.ClassID;

            AccessTools.Field(typeof(ClassData), "id").SetValue(classData, GUIDGenerator.GenerateDeterministicGUID(this.ClassID));
            AccessTools.Field(typeof(ClassData), "cardStyle").SetValue(classData, this.CardStyle);
            AccessTools.Field(typeof(ClassData), "classUnlockCondition").SetValue(classData, this.ClassUnlockCondition);
            AccessTools.Field(typeof(ClassData), "classUnlockParam").SetValue(classData, this.ClassUnlockParam);
            AccessTools.Field(typeof(ClassData), "classUnlockPreviewTexts").SetValue(classData, this.ClassUnlockPreviewTexts);
            BuilderUtils.ImportStandardLocalization(this.DescriptionLoc, this.Description);
            AccessTools.Field(typeof(ClassData), "descriptionLoc").SetValue(classData, this.DescriptionLoc);
            var icons = new List <Sprite>();

            foreach (string iconPath in this.IconAssetPaths)
            {
                icons.Add(CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + iconPath));
            }
            Type iconSetType = AccessTools.Inner(typeof(ClassData), "IconSet");
            var  iconSet     = Activator.CreateInstance(iconSetType);

            AccessTools.Field(iconSetType, "small").SetValue(iconSet, icons[0]);
            AccessTools.Field(iconSetType, "medium").SetValue(iconSet, icons[1]);
            AccessTools.Field(iconSetType, "large").SetValue(iconSet, icons[2]);
            AccessTools.Field(iconSetType, "silhouette").SetValue(iconSet, icons[3]);
            AccessTools.Field(typeof(ClassData), "icons").SetValue(classData, iconSet);
            AccessTools.Field(typeof(ClassData), "champions").SetValue(classData, this.Champions);
            BuilderUtils.ImportStandardLocalization(this.SubclassDescriptionLoc, this.SubclassDescription);
            AccessTools.Field(typeof(ClassData), "subclassDescriptionLoc").SetValue(classData, this.SubclassDescriptionLoc);
            BuilderUtils.ImportStandardLocalization(this.TitleLoc, this.Name);
            AccessTools.Field(typeof(ClassData), "titleLoc").SetValue(classData, this.TitleLoc);
            AccessTools.Field(typeof(ClassData), "uiColor").SetValue(classData, this.UiColor);
            AccessTools.Field(typeof(ClassData), "uiColorDark").SetValue(classData, this.UiColorDark);
            //AccessTools.Field(typeof(ClassData), "UNLOCK_KEYS").SetValue(classData, this.);


            // Card Frame
            if (this.CardFrameSpellPath != null && this.CardFrameUnitPath != null)
            {
                Sprite cardFrameSpellSprite = CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.CardFrameSpellPath);
                Sprite cardFrameUnitSprite  = CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.CardFrameUnitPath);
                CustomClassManager.CustomClassFrame.Add(GUIDGenerator.GenerateDeterministicGUID(this.ClassID), new List <Sprite>()
                {
                    cardFrameUnitSprite, cardFrameSpellSprite
                });
            }

            // Draft Icon
            if (this.DraftIconPath != null)
            {
                Sprite draftIconSprite = CustomAssetManager.LoadSpriteFromPath(this.BaseAssetPath + "/" + this.DraftIconPath);
                CustomClassManager.CustomClassDraftIcons.Add(GUIDGenerator.GenerateDeterministicGUID(this.ClassID), draftIconSprite);
            }
            // Class select character IDs
            CustomClassManager.CustomClassSelectScreenCharacterIDsMain.Add(GUIDGenerator.GenerateDeterministicGUID(this.ClassID), this.ClassSelectScreenCharacterIDsMain);
            CustomClassManager.CustomClassSelectScreenCharacterIDsSub.Add(GUIDGenerator.GenerateDeterministicGUID(this.ClassID), this.ClassSelectScreenCharacterIDsSub);


            return(classData);
        }
Example #18
0
    // Use this for initialization
    void Start()
    {
        // The total of drones should be divisible by the number of spawn locations;
        if (drone_number % spawn_locations.Length == 0)
        {
            drones_per_location = drone_number / spawn_locations.Length;
        }
        else
        {
            Debug.LogError("Number of Drones is not devisable by amount of spawn locations");
        }

        destination = new Transform[spawn_locations.Length];
        //Find the corresponding destination locations
        // In case we have a checkpoint, the destination becomes that checkpoint,
        //  Else we will just use end position
        if (checkpoint == null)
        {
            GameObject[] candidates = GameObject.FindGameObjectsWithTag("Mothership");
            if (candidates.Length > 1)
            {
                DroneSpawn s;
                // Check for both objects if it is the mothership we want
                if (candidates[0].transform == this.transform)
                {
                    s = candidates[1].GetComponent<DroneSpawn>();
                }
                else
                {
                    s = candidates[0].GetComponent<DroneSpawn>();
                }

                Transform[] temp_spawn = s.spawn_locations;

                // Copy the spawn locations on the opposing mothership
                // as the destination of our mothership
                for (int i = 0; i < temp_spawn.Length; i++)
                {
                    destination[temp_spawn.Length - 1 - i] = temp_spawn[i];
                }

            }
            else
            {
                Debug.LogError("No Destination Mothership in scene");
            }
        }
        else
        {
            for (int i = 0; i < destination.Length; i++)
                {
                    destination[i] = checkpoint.transform;
                }
        }
        // Start the spawn calls in startTime seconds
        InvokeRepeating("SpawnDrones", startTime, repeatTime);

        ///
        /// Network Code Below
        ///
        if (!GlobalSettings.SinglePlayer)
        {
            this.networkControl = GameObject.Find("NetworkControl").GetComponent<NetworkControl>();
            this.guidGenerator = this.networkControl.GetComponent<GUIDGenerator>();
            this.ownObjectSync = this.GetComponent<ObjectSync>();
            this.objectTables = GameObject.Find("PlayerObjectTable").GetComponent<PlayerObjectTable>();
        }
        ///
        /// End Network Code
        ///
    }
 public User()
 {
     UserId = GUIDGenerator.Generate();
 }
Example #20
0
        public void Initialize()
        {
            Trainworks.Trainworks.Log("Initializing");
            Harmony harmony = new Harmony("io.github.crazyjackel.Stoker");

            harmony.PatchAll();
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Initializing AssetBundle");
            //Load Assets
            var assembly = Assembly.GetExecutingAssembly();

            PluginManager.PluginGUIDToPath.TryGetValue("io.github.crazyjackel.Stoker", out basePath);
            info = new BundleAssetLoadingInfo
            {
                PluginPath = basePath,
                FilePath   = bundleName,
            };
            BundleManager.RegisterBundle(GUIDGenerator.GenerateDeterministicGUID(info.FullPath), info);
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Loaded AssetBundle");

            //Instantiate then Hide Canvas
            var GameObj = BundleManager.LoadAssetFromBundle(info, assetName_Canvas) as GameObject;

            Logger.Log(BepInEx.Logging.LogLevel.Info, "Loaded Main Asset: " + GameObj.name);
            Canvas = GameObject.Instantiate(GameObj);
            DontDestroyOnLoad(Canvas);
            Canvas.SetActive(false);

            //Load Prefab to Instantiate Later
            SelectionButtonPrefab = BundleManager.LoadAssetFromBundle(info, assetName_SelectionButton) as GameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Loaded Button Prefab");

            //Find local Buttons and add Listeners
            //Load Content where to add Selection Buttons
            DeckContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Deck Content");
            CardDatabaseContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground2}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Card Database Content");
            RelicDatabaseContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground3}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Relic Database Content");
            RelicContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground4}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Relic Content");
            UpgradeContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground5}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Upgrade Content");
            UpgradeDatabaseContent = Canvas.transform.Find($"{name_mainBackground}/{name_secondaryBackground6}/{name_viewport}/{name_content}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Upgrade Database Content");

            //Get Buttons and Input Fields
            RemoveButton = Canvas.transform.Find($"{name_mainBackground}/{name_removeBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Remove Button");
            RemoveButton.GetComponent <Button>().onClick.AddListener(AttemptToRemoveSelectedCard);
            AddButton = Canvas.transform.Find($"{name_mainBackground}/{name_addBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Add Button");
            AddButton.GetComponent <Button>().onClick.AddListener(AttemptToAddSelectedCardData);
            DuplicateButton = Canvas.transform.Find($"{name_mainBackground}/{name_duplicateBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Duplication Button");
            DuplicateButton.GetComponent <Button>().onClick.AddListener(AttemptToDuplicateSelectedCard);
            AddRelicButton = Canvas.transform.Find($"{name_mainBackground}/{name_addRelicBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Add Relic Button");
            AddRelicButton.GetComponent <Button>().onClick.AddListener(AttemptToAddSelectedRelicData);
            RemoveRelicButton = Canvas.transform.Find($"{name_mainBackground}/{name_removeRelicBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Remove Relic Button");
            RemoveRelicButton.GetComponent <Button>().onClick.AddListener(AttemptToRemoveSelectedRelic);
            AddUpgradeButton = Canvas.transform.Find($"{name_mainBackground}/{name_addUpgradeBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Add Upgrade Button");
            AddUpgradeButton.GetComponent <Button>().onClick.AddListener(AttemptToUpgradeCardState);
            RemoveUpgradeButton = Canvas.transform.Find($"{name_mainBackground}/{name_removeUpgradeBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Remove Upgrade Button");
            RemoveUpgradeButton.GetComponent <Button>().onClick.AddListener(AttemptToRemoveUpgradeState);
            ImportButton = Canvas.transform.Find($"{name_mainBackground}/{name_importBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Import Button");
            ImportButton.GetComponent <Button>().onClick.AddListener(LoadFromTxtFile);
            ExportButton = Canvas.transform.Find($"{name_mainBackground}/{name_exportBackground}/{name_Button}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Export Button");
            ExportButton.GetComponent <Button>().onClick.AddListener(ExportStateToTxtFile);
            SearchBar = Canvas.transform.Find($"{name_mainBackground}/{name_searchBarBackground}/{name_searchBar}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Search Bar");
            SearchBar.GetComponent <InputField>().onValueChanged.AddListener(UpdateDatabases);
            FileNameBar = Canvas.transform.Find($"{name_mainBackground}/{name_presetNameBackground}/{name_searchBar}").gameObject;
            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found File Name Bar");
            FileNameBar.GetComponent <InputField>().onValueChanged.AddListener(UpdateFileName);

            Logger.Log(BepInEx.Logging.LogLevel.Info, "Found Elements");
            //Subscribe as Client
            DepInjector.AddClient(this);
            this.Logger.LogInfo("Stoker Plugin Initialized");
        }
Example #21
0
        /// <summary>
        /// Builds the CardData represented by this builder's parameters recursively;
        /// i.e. all CardEffectBuilders in EffectBuilders will also be built.
        /// </summary>
        /// <returns>The newly created CardData</returns>
        public CardData Build()
        {
            foreach (var builder in this.EffectBuilders)
            {
                this.Effects.Add(builder.Build());
            }
            foreach (var builder in this.TraitBuilders)
            {
                this.Traits.Add(builder.Build());
            }
            foreach (var builder in this.EffectTriggerBuilders)
            {
                this.EffectTriggers.Add(builder.Build());
            }
            foreach (var builder in this.TriggerBuilders)
            {
                this.Triggers.Add(builder.Build());
            }

            var allGameData = ProviderManager.SaveManager.GetAllGameData();

            if (this.LinkedClass == null)
            {
                this.LinkedClass = CustomClassManager.GetClassDataByID(this.ClanID);
            }
            CardData cardData = ScriptableObject.CreateInstance <CardData>();
            var      guid     = GUIDGenerator.GenerateDeterministicGUID(this.CardID);

            AccessTools.Field(typeof(CardData), "id").SetValue(cardData, guid);
            cardData.name = this.CardID;
            if (this.CardArtPrefabVariantRef == null)
            {
                if (this.CardArtPrefabVariantRefBuilder == null)
                {
                    if (this.BundleLoadingInfo != null)
                    {
                        this.BundleLoadingInfo.PluginPath   = this.BaseAssetPath;
                        this.CardArtPrefabVariantRefBuilder = new AssetRefBuilder
                        {
                            AssetLoadingInfo = this.BundleLoadingInfo
                        };
                    }
                    else
                    {
                        var assetLoadingInfo = new AssetLoadingInfo()
                        {
                            FilePath   = this.AssetPath,
                            PluginPath = this.BaseAssetPath,
                            AssetType  = AssetRefBuilder.AssetTypeEnum.CardArt
                        };
                        this.CardArtPrefabVariantRefBuilder = new AssetRefBuilder
                        {
                            AssetLoadingInfo = assetLoadingInfo
                        };
                    }
                }
                this.CardArtPrefabVariantRef = this.CardArtPrefabVariantRefBuilder.BuildAndRegister();
            }
            AccessTools.Field(typeof(CardData), "cardArtPrefabVariantRef").SetValue(cardData, this.CardArtPrefabVariantRef);
            AccessTools.Field(typeof(CardData), "cardLoreTooltipKeys").SetValue(cardData, this.CardLoreTooltipKeys);
            AccessTools.Field(typeof(CardData), "cardType").SetValue(cardData, this.CardType);
            AccessTools.Field(typeof(CardData), "cost").SetValue(cardData, this.Cost);
            AccessTools.Field(typeof(CardData), "costType").SetValue(cardData, this.CostType);
            AccessTools.Field(typeof(CardData), "effects").SetValue(cardData, this.Effects);
            AccessTools.Field(typeof(CardData), "effectTriggers").SetValue(cardData, this.EffectTriggers);
            AccessTools.Field(typeof(CardData), "fallbackData").SetValue(cardData, this.FallbackData);
            AccessTools.Field(typeof(CardData), "ignoreWhenCountingMastery").SetValue(cardData, this.IgnoreWhenCountingMastery);
            AccessTools.Field(typeof(CardData), "linkedClass").SetValue(cardData, this.LinkedClass);
            AccessTools.Field(typeof(CardData), "linkedMasteryCard").SetValue(cardData, this.LinkedMasteryCard);
            if (this.Name != null)
            {
                // Use Name field for all languages
                // This should be changed in the future to add proper localization support to custom content
                CustomLocalizationManager.ImportSingleLocalization(this.NameKey, "Text", "", "", "", "", this.Name, this.Name, this.Name, this.Name, this.Name, this.Name);
            }
            AccessTools.Field(typeof(CardData), "nameKey").SetValue(cardData, this.NameKey);
            if (this.Description != null)
            {
                // Use Description field for all languages
                // This should be changed in the future to add proper localization support to custom content
                CustomLocalizationManager.ImportSingleLocalization(this.OverrideDescriptionKey, "Text", "", "", "", "", this.Description, this.Description, this.Description, this.Description, this.Description, this.Description);
            }
            AccessTools.Field(typeof(CardData), "overrideDescriptionKey").SetValue(cardData, this.OverrideDescriptionKey);
            AccessTools.Field(typeof(CardData), "rarity").SetValue(cardData, this.Rarity);
            AccessTools.Field(typeof(CardData), "sharedMasteryCards").SetValue(cardData, this.SharedMasteryCards);
            if (this.SpriteCache != null)
            {
                AccessTools.Field(typeof(CardData), "spriteCache").SetValue(cardData, this.SpriteCache);
            }
            AccessTools.Field(typeof(CardData), "startingUpgrades").SetValue(cardData, this.StartingUpgrades);
            AccessTools.Field(typeof(CardData), "targetless").SetValue(cardData, this.Targetless);
            AccessTools.Field(typeof(CardData), "targetsRoom").SetValue(cardData, this.TargetsRoom);
            foreach (CardTraitData cardTraitData in this.Traits)
            {
                AccessTools.Field(typeof(CardTraitData), "paramCardData").SetValue(cardTraitData, cardData);
            }
            AccessTools.Field(typeof(CardData), "traits").SetValue(cardData, this.Traits);
            AccessTools.Field(typeof(CardData), "triggers").SetValue(cardData, this.Triggers);
            AccessTools.Field(typeof(CardData), "unlockLevel").SetValue(cardData, this.UnlockLevel);

            return(cardData);
        }
Example #22
0
 public UserRegister()
 {
     RegisterId = GUIDGenerator.Generate();
 }
    public static HttpCookie GetCookie(User user)
    {
        CustomPrincipalSerializeModel serializeModel = new CustomPrincipalSerializeModel {
            user_id = user.UserId, username = user.Username, roles = user.Roles, session_token = GUIDGenerator.ToAlphaNumerical()
        };
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        string userData = serializer.Serialize(serializeModel);
        FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1,
                                                                             user.UserId.ToString(),
                                                                             DateTime.Now,
                                                                             DateTime.Now.AddMinutes(30),
                                                                             false,
                                                                             userData);

        string encTicket = FormsAuthentication.Encrypt(authTicket);

        return(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
    }