public SpeedBerry(EntityData data, Vector2 offset, EntityID id, bool restored) : base(data, offset, id) { EntityData = data; new DynData <Strawberry>(this)["Golden"] = true; BronzeTime = data.Float("bronzeTime", 15f); SilverTime = data.Float("silverTime", 10f); GoldTime = data.Float("goldTime", 5f); this.restored = restored; Follower.PersistentFollow = true; var listener = new TransitionListener() { OnOutBegin = () => { SceneAs <Level>()?.Session.DoNotLoad.Add(ID); transitionStart = Position; transitionTarget = new Vector2( Calc.Clamp(transitionStart.X, SceneAs <Level>().Bounds.Left + 8f, SceneAs <Level>().Bounds.Right - 8f), Calc.Clamp(transitionStart.Y, SceneAs <Level>().Bounds.Top + 8f, SceneAs <Level>().Bounds.Bottom - 8f)); }, OnOut = percent => { if (SceneAs <Level>()?.Tracker.GetEntity <Player>()?.CollideCheck <SpeedBerryCollectTrigger>() ?? false) { // as soon as the transition is over, the berry will be collected, so be sure to drag it on the new screen // so that the player actually sees it collect. Position = Vector2.Lerp(transitionStart, transitionTarget, Ease.SineOut(percent)); forcePositionToTransitionTarget = true; } } }; Add(listener); if (P_SilverGlow == null) { P_SilverGlow = new ParticleType(P_Glow) { Color = Calc.HexToColor("B3AF9F"), Color2 = Calc.HexToColor("E6DCB5") }; P_BronzeGlow = new ParticleType(P_Glow) { Color = Calc.HexToColor("9A5B3C"), Color2 = Calc.HexToColor("ECAF66") }; P_OrigGoldGlow = P_GoldGlow; } // the speed berry most certainly shouldn't flip the "grabbed golden" switch in session. PlayerCollider collider = Get <PlayerCollider>(); Action <Player> onPlayer = collider.OnCollide; collider.OnCollide = player => { bool bakGrabbedGolden = (Scene as Level).Session.GrabbedGolden; onPlayer(player); (Scene as Level).Session.GrabbedGolden = bakGrabbedGolden; }; }
public SteamWall(float startPosition) { Add(new PlayerCollider(OnPlayer)); Add(new LightOcclude(0.8f)); Add(_loopSfx = new SoundSource()); Depth = -100000; Collider = new Hitbox(16 + startPosition, 0f); Add(new Coroutine(SteamPoofSpawnSequence())); Add(new Coroutine(ThrowDebrisSequence())); Add(new DisplacementRenderHook(RenderDisplacement)); Add(_transitionListener = new TransitionListener()); _transitionListener.OnOut += FadeOutOnTransition; }
public ThrowBox(Vector2 position, bool isMetal, bool tutorial = false, bool isSpecial = false, bool isCrucial = false) : base(position) { Position -= DISPLACEMENT; _starterPosition = Position; Depth = 100; Collider = new Hitbox(8f, 10f, 4f + DISPLACEMENT.X, 6f + DISPLACEMENT.Y); _isMetal = isMetal; IsSpecial = isSpecial; _isCrucial = isCrucial; _tutorial = tutorial; string pathString = isMetal ? "crate_metal0" : "crate0"; Add(_image = new Image(GFX.Game[$"objects/FactoryHelper/crate/{pathString}"])); _image.Position += DISPLACEMENT; if (_isCrucial) { Add(_warningImage = new Image(GFX.Game["objects/FactoryHelper/crate/crucial"])); _warningImage.Position += DISPLACEMENT; } Add(Hold = new Holdable(0.1f)); Hold.PickupCollider = new Hitbox(16f, 16f, DISPLACEMENT.X, DISPLACEMENT.Y); Hold.SlowFall = false; Hold.SlowRun = true; Hold.OnPickup = OnPickup; Hold.OnRelease = OnRelease; Hold.OnHitSpring = HitSpring; Hold.OnHitSpinner = OnHitSpinner; Hold.SpeedGetter = (() => Speed); Add(_transitionListener = new TransitionListener()); _transitionListener.OnOutBegin = () => _isCrucial = false; Add(ConveyorMover = new ConveyorMover()); ConveyorMover.OnMove = MoveOnConveyor; Add(new SteamCollider(OnSteamWall)); LiftSpeedGraceTime = 0.1f; Add(new LightOcclude(0.2f)); Add(new MirrorReflection()); }
public override void Awake(Scene scene) { base.Awake(scene); if (CollideCheck <Player>()) { _tiles.Alpha = 0f; _fade = true; _cutout.Visible = false; if (_playRevealWhenTransitionedInto) { Audio.Play("event:/game/general/secret_revealed", base.Center); } } else { TransitionListener transitionListener = new TransitionListener(); transitionListener.OnOut = OnTransitionOut; transitionListener.OnOutBegin = OnTransitionOutBegin; transitionListener.OnIn = OnTransitionIn; transitionListener.OnInBegin = OnTransitionInBegin; Add(transitionListener); } }
public override void Awake(Scene scene) { base.Awake(scene); awake = true; if (!HasGroup) { MasterOfGroup = true; Group = new List <CaveWall>(); GroupBoundsMin = new Point((int)X, (int)Y); GroupBoundsMax = new Point((int)Right, (int)Bottom); AddToGroupAndFindChildren(this); Rectangle rectangle = new Rectangle(GroupBoundsMin.X / 8, GroupBoundsMin.Y / 8, (GroupBoundsMax.X - GroupBoundsMin.X) / 8 + 1, (GroupBoundsMax.Y - GroupBoundsMin.Y) / 8 + 1); Level level = SceneAs <Level>(); Rectangle tileBounds = level.Session.MapData.TileBounds; VirtualMap <char> virtualMap = level.SolidsData.Clone(); foreach (CaveWall item in Group) { int x = (int)(item.X / 8f) - level.Session.MapData.TileBounds.X; int y = (int)(item.Y / 8f - level.Session.MapData.TileBounds.Y); int tilesX = (int)(item.Width / 8f); int tilesY = (int)(item.Height / 8f); for (int i = x; i < x + tilesX; i++) { for (int j = y; j < y + tilesY; j++) { virtualMap[i, j] = item.fillTile; } } } // Pretend that the CaveWalls are just part of the map, then draw the CaveWalls on top of it // This is a complicated solution to getting the CaveWalls to blend with both the foregroundTiles and each other foreach (CaveWall item in Group) { int x = (int)item.X / 8 - tileBounds.Left; int y = (int)item.Y / 8 - tileBounds.Top; int tilesX = (int)item.Width / 8; int tilesY = (int)item.Height / 8; item.tiles = GFX.FGAutotiler.GenerateOverlay(item.fillTile, x, y, tilesX, tilesY, virtualMap).TileGrid; item.Add(item.tiles); item.Add(new TileInterceptor(item.tiles, highPriority: false)); } } TryToInitPosition(); if (CollideCheck <Player>()) { tiles.Alpha = 0f; fadeOut = true; fadeIn = false; cutout.Visible = false; } TransitionListener transitionListener = new TransitionListener(); transitionListener.OnOut = OnTransitionOut; transitionListener.OnOutBegin = OnTransitionOutBegin; transitionListener.OnIn = OnTransitionIn; transitionListener.OnInBegin = OnTransitionInBegin; Add(transitionListener); }
public void SetTransitionListener(TransitionListener l) { this.listener = l; }
void Initialize(IAttributeSet attrs, int defStyle) { mTouchListener = new OnTouchListener(this); mOnHieratchyChangeListener = new OnHierarchyChangeListener() { OnChildViewAddedAction = (View parent, View child) => { Log.Debug(TAG, "Child is added: " + child); IViewParent scrollView = parent.Parent; if (scrollView != null && scrollView is ScrollView) { ((ScrollView)scrollView).FullScroll(FocusSearchDirection.Down); } if (this.LayoutTransition != null) { View view = child.FindViewById(Resource.Id.card_actionarea); if (view != null) { view.Alpha = 0; } } }, OnChildViewRemovedAction = (View parent, View child) => { Log.Debug(TAG, "Child is removed: " + child); mFixedViewList.Remove(child); } }; mTransitionListener = new TransitionListener() { StartTransitionAction = (LayoutTransition transition, ViewGroup container, View view, LayoutTransitionType transitionType) => { Log.Debug(TAG, "Start LayoutTransition animation: " + transitionType); }, EndTransitionAction = (LayoutTransition transition, ViewGroup container, View view, LayoutTransitionType transitionType) => { Log.Debug(TAG, "End LayoutTransition animation: " + transitionType); if (transitionType == LayoutTransitionType.Appearing) { View area = view.FindViewById(Resource.Id.card_actionarea); if (area != null) { RunShowActionAreaAnimation(container, area); } } } }; float speedFactor = 1f; if (attrs != null) { TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.CardStream, defStyle, 0); if (a != null) { int speedType = a.GetInt(Resource.Styleable.CardStream_animationDuration, 1001); switch (speedType) { case ANIMATION_SPEED_FAST: speedFactor = 0.5f; break; case ANIMATION_SPEED_NORMAL: speedFactor = 1f; break; case ANIMATION_SPEED_SLOW: speedFactor = 2f; break; } string animatorName = a.GetString(Resource.Styleable.CardStream_animators); try { if (animatorName != null) { mAnimators = Class.ClassLoader.LoadClass(animatorName).NewInstance() as CardStreamAnimator; } } catch (Exception e) { Log.Error(TAG, "Failed to load animator: " + animatorName, e); } finally { if (mAnimators == null) { mAnimators = new DefaultCardStreamAnimator(); } } a.Recycle(); } } mAnimators.SpeedFactor = speedFactor; mSwipeSlop = ViewConfiguration.Get(Context).ScaledTouchSlop; SetOnHierarchyChangeListener(mOnHieratchyChangeListener); }
void Initialize (IAttributeSet attrs, int defStyle) { mTouchListener = new OnTouchListener (this); mOnHieratchyChangeListener = new OnHierarchyChangeListener() { OnChildViewAddedAction = (View parent, View child) => { Log.Debug(TAG, "Child is added: " + child); IViewParent scrollView = parent.Parent; if (scrollView != null && scrollView is ScrollView) { ((ScrollView)scrollView).FullScroll(FocusSearchDirection.Down); } if (this.LayoutTransition != null) { View view = child.FindViewById(Resource.Id.card_actionarea); if (view != null) view.Alpha = 0; } }, OnChildViewRemovedAction = (View parent, View child) => { Log.Debug(TAG, "Child is removed: " + child); mFixedViewList.Remove(child); } }; mTransitionListener = new TransitionListener() { StartTransitionAction = (LayoutTransition transition, ViewGroup container, View view, LayoutTransitionType transitionType) => { Log.Debug(TAG, "Start LayoutTransition animation: " + transitionType); }, EndTransitionAction = (LayoutTransition transition, ViewGroup container, View view, LayoutTransitionType transitionType) => { Log.Debug(TAG, "End LayoutTransition animation: " + transitionType); if (transitionType == LayoutTransitionType.Appearing) { View area = view.FindViewById(Resource.Id.card_actionarea); if (area != null) { RunShowActionAreaAnimation(container, area); } } } }; float speedFactor = 1f; if (attrs != null) { TypedArray a = Context.ObtainStyledAttributes (attrs, Resource.Styleable.CardStream, defStyle, 0); if (a != null) { int speedType = a.GetInt (Resource.Styleable.CardStream_animationDuration, 1001); switch (speedType) { case ANIMATION_SPEED_FAST: speedFactor = 0.5f; break; case ANIMATION_SPEED_NORMAL: speedFactor = 1f; break; case ANIMATION_SPEED_SLOW: speedFactor = 2f; break; } string animatorName = a.GetString (Resource.Styleable.CardStream_animators); try { if (animatorName != null) mAnimators = Class.ClassLoader.LoadClass(animatorName).NewInstance() as CardStreamAnimator; } catch (Exception e) { Log.Error (TAG, "Failed to load animator: " + animatorName, e); } finally { if (mAnimators == null) mAnimators = new DefaultCardStreamAnimator (); } a.Recycle (); } } mAnimators.SpeedFactor = speedFactor; mSwipeSlop = ViewConfiguration.Get (Context).ScaledTouchSlop; SetOnHierarchyChangeListener (mOnHieratchyChangeListener); }