Ejemplo n.º 1
0
            protected override void AddLayer(ActorLayer layer)
            {
                // 让角色渐进式出现
                FadeTo fade = FadeOut();

                fade.SetActionListener(new RotationAction());
            }
Ejemplo n.º 2
0
        internal static bool PatchMethods()
        {
            try
            {
                // Left room
                MethodInfo onLeftRoomMethod = typeof(NetworkManager).GetMethod(
                    nameof(NetworkManager.OnLeftRoom),
                    BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly,
                    null,
                    Type.EmptyTypes,
                    null);
                origOnLeftRoom = Patch <OnLeftRoom>(onLeftRoomMethod, GetDetour(nameof(OnLeftRoomPatch)));
            }
            catch (Exception e)
            {
                MelonLogger.Error("Failed to patch OnLeftRoom\n" + e.Message);
                return(false);
            }

            try
            {
                // Faded to and joined and initialized room
                MethodInfo fadeMethod = typeof(VRCUiManager).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).First(
                    m => m.Name.StartsWith("Method_Public_Void_String_Single_Action_") &&
                    m.Name.IndexOf("PDM", StringComparison.OrdinalIgnoreCase) == -1 &&
                    m.GetParameters().Length == 3);
                origFadeTo = Patch <FadeTo>(fadeMethod, GetDetour(nameof(FadeToPatch)));
            }
            catch (Exception e)
            {
                MelonLogger.Error("Failed to patch FadeTo\n" + e.Message);
                return(false);
            }

            if (Utilities.IsInVR)
            {
                try
                {
                    // Fixes spinning issue
                    // TL;DR Prevents the tracking manager from applying rotational force
                    MethodInfo applyPlayerMotionMethod = typeof(VRCTrackingManager).GetMethods(BindingFlags.Public | BindingFlags.Static)
                                                         .Where(
                        m => m.Name.StartsWith("Method_Public_Static_Void_Vector3_Quaternion") &&
                        !m.Name.Contains("_PDM_")).First(
                        m => XrefScanner.UsedBy(m).Any(
                            xrefInstance => xrefInstance.Type == XrefType.Method &&
                            xrefInstance.TryResolve()?.ReflectedType
                            ?.Equals(typeof(VRC_StationInternal))
                            == true));
                    origApplyPlayerMotion = Patch <ApplyPlayerMotion>(applyPlayerMotionMethod, GetDetour(nameof(ApplyPlayerMotionPatch)));
                }
                catch (Exception e)
                {
                    MelonLogger.Error("Failed to patch ApplyPlayerMotion\n" + e.Message);
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        protected override void OnFrameRun(float deltaTime, float realDeltaTime)
        {
            FadeTo.RunFrame(deltaTime);

            transform.position = CalculateNewPosition(Player.Instance.transform.position);

            FireTimer.Increment(deltaTime);
        }
        //public override int ReflectedDamage => throw new NotImplementedException();

        protected override void OnEnemyBulletInit()
        {
            float maxAlpha = Alpha;

            Alpha = 0f;

            FadeIn          = new FadeTo(this, maxAlpha, FadeInTime);
            DeactivateTimer = new FrameTimer(FadeInTime + FullBrightTime);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 让指定对象执行FadeTo事件
        /// </summary>
        ///
        /// <param name="o"></param>
        /// <param name="type"></param>
        /// <param name="speed"></param>
        /// <returns></returns>
        public FadeTo CallFadeTo(Loon.Action.ActionBind o, int type, int speed)
        {
            if (isClose)
            {
                return(null);
            }
            FadeTo fade = new FadeTo(type, speed);

            AddActionEvent(fade, o);
            return(fade);
        }
Ejemplo n.º 6
0
        public void Activate()
        {
            gameObject.SetActive(true);

            FireTimer.Reset();
            FireTimer.TotalTime = -FadeInTime - FadeInTimeFireDelay;

            var targetAlpha = Alpha;

            Alpha  = 0;
            FadeTo = new FadeTo(this, targetAlpha, FadeInTime);
        }
        protected override void OnPlayerBulletInit()
        {
            Collider = GetComponent <CircleCollider2D>();

            ActivateCollider = new FuncAfterDelay(this, () => Collider.enabled = true, EntranceAnimationTime);
            var fadeIn = new FadeTo(this, 0, Alpha, EntranceAnimationTime);

            VelocityChange = new VelocityChange(this, Vector2.zero, Vector2.zero, EntranceAnimationTime);
            var easeVelocityOut = new EaseOut(VelocityChange);

            EntranceAnimation = new ConcurrentGameTask(fadeIn, easeVelocityOut, ActivateCollider);
        }
Ejemplo n.º 8
0
        private void InitAnimation()
        {
            const float FinalAlpha = 1.0f;

            ScaleTo grow = new ScaleTo(this, InitialScale, FinalScale, AnimationTime);

            FadeTo   fadeIn       = new FadeTo(this, InitialAlpha, FinalAlpha, FadeTime);
            Delay    fadeDelay    = new Delay(this, AnimationTime - (2 * FadeTime));
            FadeTo   fadeOut      = new FadeTo(this, FinalAlpha, 0, FadeTime);
            Sequence fadeSequence = new Sequence(fadeIn, fadeDelay, fadeOut);

            Animation = new ConcurrentGameTask(grow, fadeSequence);
            Animation.FinishSelf();
        }
Ejemplo n.º 9
0
        private void Activate(float xPosition)
        {
            gameObject.SetActive(true);

            float newY = SpaceUtil.WorldMap.Bottom.y + OffsetFromBottom;

            transform.position = new Vector3(xPosition, newY, 0);
            VelocityX          = Speed;

            var fadeIn = new FadeTo(this, 0, Alpha, FadeInTime);

            RunTask(fadeIn);
            Alpha              = 0;
            FireTimer.Elapsed -= FadeInTime;
        }
Ejemplo n.º 10
0
        protected override void OnPlayerBulletInit()
        {
            float worldHeight = SpaceUtil.WorldMap.Height;

            var spriteHeight = Sprite.size.y;
            var heightScale  = worldHeight / spriteHeight;

            transform.localScale = new Vector3(1, heightScale, 1);

            var delay        = new Delay(this, FullBrightTime);
            var removeActive = new GameTaskFunc(this, () => HitBoxActive = false);
            var fadeTo       = new FadeTo(this, 0.0f, FadeTime);
            var deactivate   = GameTaskFunc.DeactivateSelf(this);

            Behavior = new Sequence(delay, removeActive, fadeTo, deactivate);
        }
Ejemplo n.º 11
0
            public override void Action(long t)
            {
                // 触发精灵事件
                hpBar.Update(t);
                if (hp <= 0 && !removeFlag)
                {
                    // 设定死亡时渐变
                    FadeTo fade = FadeIn();
                    // 渐变时间为30毫秒
                    fade.SetSpeed(30);
                    // 监听渐变过程
                    fade.SetActionListener(new RemoveAction(this));

                    this.removeFlag = true;
                }
            }
Ejemplo n.º 12
0
        protected sealed override void OnPlayerBulletInit()
        {
            const float BlinkAlpha    = 0.5f;
            const float BlinkDelay    = 0.05f;
            var         blinkOut      = new GameTaskFunc(this, () => Alpha = BlinkAlpha);
            var         blinkDelay    = new Delay(this, BlinkDelay);
            var         blinkIn       = new GameTaskFunc(this, () => Alpha = 1.0f);
            var         turnOffDamage = new GameTaskFunc(this, () => DamageActive = false);

            var fade       = new FadeTo(this, 0f, 1.0f);
            var deactivate = new GameTaskFunc(this, DeactivateSelf);

            FadeOutSequence = new Sequence(blinkOut, blinkDelay, blinkIn, blinkDelay,
                                           blinkOut, blinkDelay, blinkIn, turnOffDamage, fade, deactivate);

            OnSmiteBulletInit();
        }
Ejemplo n.º 13
0
        internal static bool PatchMethods()
        {
            try
            {
                // Faded to and joined and initialized room
                MethodInfo fadeMethod = typeof(VRCUiManager).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).First(
                    m => m.Name.StartsWith("Method_Public_Void_String_Single_Action_") &&
                    m.Name.IndexOf("PDM", StringComparison.OrdinalIgnoreCase) == -1 &&
                    m.GetParameters().Length == 3);
                origFadeTo = Patch <FadeTo>(fadeMethod, GetDetour(nameof(FadeToPatch)));
            }
            catch (Exception e)
            {
                MelonLogger.Error("Failed to patch FadeTo\n" + e.Message);
                return(false);
            }

            return(true);
        }
        protected override void OnInit()
        {
            var initialSize = GetComponent <Renderer>().bounds.size;

            float spawnMinX = SpaceUtil.WorldMap.Left.x + initialSize.x;
            float spawnMinY = (SpaceUtil.WorldMap.Bottom.y + SpaceUtil.WorldMap.Center.y) * 0.5f;

            SpawnMin = new Vector2(spawnMinX, spawnMinY);

            float spawnMaxX = SpaceUtil.WorldMap.Right.x - initialSize.x;
            float spawnMaxY = (SpaceUtil.WorldMap.Center.y + SpaceUtil.WorldMap.Top.y) * 0.5f;

            SpawnMax = new Vector2(spawnMaxX, spawnMaxY);

            var activateCanCollide = new GameTaskFunc(this, () => CanCollide = true);

            float fullBrightAlpha = Alpha;

            var entranceFadeIn   = new FadeTo(this, 0f, fullBrightAlpha, FadeTime);
            var entranceScaleIn  = new ScaleTo(this, float.Epsilon, LocalScale, FadeTime);
            var entranceSequence = new Sequence(entranceFadeIn, entranceScaleIn, activateCanCollide);

            var fadeOut            = new FadeTo(this, fullBrightAlpha, TravelAlpha, FadeTime);
            var fadeOutEase        = new EaseIn3(fadeOut);
            var scaleOut           = new ScaleTo(this, LocalScale, TravelSizeScale, FadeTime);
            var scaleOutEase       = new EaseIn3(scaleOut);
            var fadeOutConcurrence = new ConcurrentGameTask(fadeOutEase, scaleOutEase);

            TravelMove     = MoveTo.Default(this, 1.0f);
            TravelMoveEase = new EaseInOut(TravelMove);

            var fadeIn            = new FadeTo(this, TravelAlpha, fullBrightAlpha, FadeTime);
            var scaleIn           = new ScaleTo(this, TravelSizeScale, LocalScale, FadeTime);
            var fadeInConcurrence = new ConcurrentGameTask(fadeIn, scaleIn);

            TravelSequence = new Sequence(fadeOutConcurrence, TravelMoveEase, fadeInConcurrence, activateCanCollide);

            CanCollide         = false;
            LocalScale         = float.Epsilon;
            transform.position = SpaceUtil.WorldMap.Center;
            RunTask(entranceSequence);
        }
Ejemplo n.º 15
0
        protected override void OnEnemyBulletInit()
        {
            LaserColor = SpriteColor;

            float worldHeight = SpaceUtil.WorldMap.Height;

            LocalScaleX = worldHeight * MathUtil.Sqrt2;

            var sprite = GetComponent <SpriteRenderer>();

            WidthHalf = sprite.size.x * 0.5f * transform.localScale.x;

            var fadeIn           = new FadeTo(this, 0f, PrefireColor.a, FadeInTime);
            var prefireDelay     = new Delay(this, PrefireFullBrightTime);
            var activateCollider = new GameTaskFunc(this, ActivateCollider);
            var postfireDelay    = new Delay(this, FullBrightTime);
            var fadeTo           = new FadeTo(this, 0.0f, FadeTime);
            var deactivate       = GameTaskFunc.DeactivateSelf(this);

            Behavior = new Sequence(fadeIn, prefireDelay, activateCollider, postfireDelay, fadeTo, deactivate);
        }
Ejemplo n.º 16
0
        //private Delay DeactivateDelay { get; set; }
        //private Sequence FallbackDeactivate { get; set; }

        //public float FallbackDeactivationTime
        //{
        //    get => _fallbackDeactivationTime;
        //    set
        //    {
        //        const float TimeDelta = 5f / 60f;

        //        if (_fallbackDeactivationTime != value)
        //        {
        //            _fallbackDeactivationTime = value;
        //            DeactivateDelay.Duration = (value - FadeInTime) + TimeDelta;
        //            FallbackDeactivate.RecalculateDuration();
        //        }
        //    }
        //}

        protected override void OnPlayerBulletInit()
        {
            float worldHeight = SpaceUtil.WorldMap.Height;

            float spriteHeight = Sprite.size.y;
            float heightScale  = worldHeight / spriteHeight;

            transform.localScale = new Vector3(0f, heightScale, 1f);

            Alpha = 0f;

            Vector3 scaleInitial = new Vector3(0f, heightScale, 1f);
            Vector3 scaleFinal   = new Vector3(1f, heightScale, 1f);

            ScaleIn = new ScaleTo(this, scaleInitial, scaleFinal, FadeInTime);
            var fadeIn = new FadeTo(this, MaxAlpha, float.Epsilon); //  FadeInTime * 0.25f

            SpawnAnimation = new ConcurrentGameTask(ScaleIn, fadeIn);

            //DeactivateDelay = new Delay(this, FallbackDeactivationTime - FadeInTime);
            //var deactivate = new GameTaskFunc(this, DeactivateSelf);
            //FallbackDeactivate = new Sequence(concurrence, DeactivateDelay, deactivate);
        }
Ejemplo n.º 17
0
        protected override void OnPermanentVelocityBulletInit()
        {
            Scale = SpaceUtil.WorldMap.Height;

            var scaleIn   = new ScaleTo(this, float.Epsilon, Scale, ScaleInTime);
            var scaleEase = new EaseIn3(scaleIn);

            MoveToCenter = new MoveTo(this, Vector3.zero, new Vector3(1f, 1f), ScaleInTime);

            var scaleAndMove = new ConcurrentGameTask(scaleEase, MoveToCenter);

            var calmExplosion = new GameTaskFunc(this, () => IsExploding = false);

            var fade     = new FadeTo(this, 0, FadeTime);
            var fadeEase = new EaseOut(fade);

            Sequence = new Sequence(scaleAndMove, calmExplosion, fadeEase);

            //ManagedMiscSprites = new List<ValkyrieSprite>();
            ManagedEnemies       = new TrackedPooledObjectSet <Enemy>();
            ManagedEnemyBullets  = new TrackedPooledObjectSet <EnemyBullet>();
            ManagedPlayerBullets = new TrackedPooledObjectSet <PlayerBullet>();
            ManagedPickups       = new TrackedPooledObjectSet <Pickup>();
        }
Ejemplo n.º 18
0
        private void StartFadeIn()
        {
            FadeTo fadeIn = new FadeTo(this, Alpha, 1.0f, AnimationTime);

            RunTask(fadeIn);
        }