コード例 #1
0
        public override void Initialize()
        {
            Instance = this;

            Assembly randoDLL = GetType().Assembly;

            foreach (string res in randoDLL.GetManifestResourceNames())
            {
                if (res.EndsWith("Turret.png"))
                {
                    // Read bytes of image
                    Stream imageStream = randoDLL.GetManifestResourceStream(res);
                    byte[] buffer      = new byte[imageStream.Length];
                    imageStream.Read(buffer, 0, buffer.Length);
                    imageStream.Dispose();

                    // Create texture from bytes
                    Texture2D tex = new Texture2D(1, 1);
                    tex.LoadImage(buffer, true);

                    // Create sprite from texture
                    turretSprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
                }
            }

            ModHooks.Instance.AttackHook             += KillDamage;
            ModHooks.Instance.BeforeSavegameSaveHook += RestoreDamage;
            ModHooks.Instance.HeroUpdateHook         += SpawnShadeOrb;
            On.HutongGames.PlayMaker.Actions.SpawnObjectFromGlobalPool.OnEnter += SpawnTurret;

            Enemies.BeginTracking();
        }