예제 #1
0
 private void onBeforeRender(object sender, AGSEventArgs args)
 {
     if (_room.Room != null && _room.Room != _game.State.Room) return;
     if (_withCaret.TreeNode.Parent == null) _withCaret.TreeNode.SetParent(_tree.TreeNode);
     bool isVisible = IsFocused;
     if (isVisible)
     {
         _caretFlashCounter--;
         if (_caretFlashCounter < 0)
         {
             isVisible = false;
             if (_caretFlashCounter < -CaretFlashDelay)
             {
                 _caretFlashCounter = (int)CaretFlashDelay;
             }                    
         }
     }
     _withCaret.Visible = isVisible;
     _withCaret.Text = _textComponent.Text;
     _withCaret.TextConfig = _textComponent.TextConfig;
     var renderer = _withCaret.CustomRenderer as ILabelRenderer;
     if (renderer != null)
     {
         renderer.CaretPosition = CaretPosition;
         renderer.BaseSize = _textComponent.LabelRenderSize;
         renderer.RenderCaret = true;
     }
     _textComponent.TextVisible = !isVisible;
     renderer = _imageComponent.CustomRenderer as ILabelRenderer;
     if (renderer != null)
     {
         renderer.CaretPosition = CaretPosition;
     }
 }
예제 #2
0
		private void onSavedGameLoad(object sender, AGSEventArgs args)
		{
			_state.Rooms.OnListChanged.Unsubscribe(onRoomsChange);
			foreach (var fader in _map.Values)
			{
				fader.Dispose();
			}
			foreach (var room in _state.Rooms)
			{
				_map.TryAdd(room.ID, new RoomCrossFader (this, room));
			}
			_state = _game.State;
			_state.Rooms.OnListChanged.Subscribe(onRoomsChange);
		}
예제 #3
0
		private void onBeforeRender(object sender, AGSEventArgs args)
		{
			var shader = _shakeShader;
			if (shader != null) shader = shader.Compile();
			if (shader == null || shader != getActiveShader())
			{
				_shakeShader = null;
				AGSGame.Game.Events.OnBeforeRender.Unsubscribe(onBeforeRender);
				return;
			}
			shader.Bind();
			shader.SetVariable("time", (float)args.TimesInvoked);
			var currentStrength = _strength + MathUtils.Random().Next(1000) / 1000000f; //Adding a little jerkiness
			shader.SetVariable("strength", currentStrength);
			_strength = _strength * _decay;
		}
예제 #4
0
        private void onRepeatedlyExecute(object sender, AGSEventArgs args)
        {
            if (!IsCurrentlyDragged) return;
            if (!IsDragEnabled || !_input.LeftMouseButtonDown)
            {
                IsCurrentlyDragged = false;
                return;
            }            

            float mouseX = _input.MouseX;
            float mouseY = _input.MouseY;

            if (DragMinX != null && mouseX < DragMinX.Value) return;
            if (DragMaxX != null && mouseX > DragMaxX.Value) return;
            if (DragMinY != null && mouseY < DragMinY.Value) return;
            if (DragMaxY != null && mouseY > DragMaxY.Value) return;

            _transform.X = _dragObjectStartX + (mouseX - _dragMouseStartX);
            _transform.Y = _dragObjectStartY + (mouseY - _dragMouseStartY);
        }        
예제 #5
0
		private void onRepeatedlyExecute (object sender, AGSEventArgs args)
		{
            var target = TargetBeingFollowed;
			var currentWalk = _currentWalk;
			var followSettings = _followSettings;
			if (target == null || followSettings == null) 
			{
				if (currentWalk != null) _walk.StopWalking ();
				return;
			}
			if (target == _lastTarget) 
			{
				if (currentWalk != null && !currentWalk.IsCompleted) return;
			}
			_lastTarget = target;
			if (_counter > 0) 
			{
				if (_hasRoom.Room != target.Room && _newRoomX == null) 
				{
					_newRoomX = target.X;
					_newRoomY = target.Y;
				}
				_counter--;
				return;
			}
			_counter = MathUtils.Random ().Next (_followSettings.MinWaitBetweenWalks, _followSettings.MaxWaitBetweenWalks);
			if (_hasRoom.Room != target.Room) 
			{
				if (_followSettings.FollowBetweenRooms) 
				{
					_hasRoom.ChangeRoom (target.Room, _newRoomX, _newRoomY);
					_walk.PlaceOnWalkableArea ();
					_newRoomX = null;
					_newRoomY = null;
				}
				return;
			}
			setNextWalk (target, followSettings);
		}
예제 #6
0
 private void onRepeatedlyExecute(object sender, AGSEventArgs e)
 {
     var state = _game.State;
     IObject hotspot = state.Room.GetObjectAt(_game.Input.MouseX, _game.Input.MouseY);
     if (hotspot == null)
     {
         turnOffObjectSpecificCursor();
         return;
     }
     IHasCursorComponent specialCursor = hotspot.GetComponent<IHasCursorComponent>();
     if (specialCursor == null)
     {
         turnOffObjectSpecificCursor();
         return;
     }
     if (_game.Input.Cursor != specialCursor.SpecialCursor)
     {
         _lastCursor = _game.Input.Cursor;
         _game.Input.Cursor = specialCursor.SpecialCursor;
     }
     _showingObjectSpecificCursor = true;
 }
예제 #7
0
		private void onBeforeFadeIn(object sender, AGSEventArgs args)
		{
			_player.PlaceOnWalkableArea();
		}
예제 #8
0
		private static void firstSetupVignette(object sender, AGSEventArgs args)
		{
			setVignetteResolution();
			AGSGame.Game.Events.OnBeforeRender.Unsubscribe(firstSetupVignette);
			AGSGame.Game.Events.OnScreenResize.Subscribe(onVignetteShaderResize);
		}
예제 #9
0
		private async Task lookOnWindow(object sender, AGSEventArgs args)
		{
			_room.Viewport.Camera.Enabled = false;

			float scaleX = _room.Viewport.ScaleX;
			float scaleY = _room.Viewport.ScaleY;
			float angle = _room.Viewport.Angle;
			float x = _room.Viewport.X;
			float y = _room.Viewport.Y;

			Tween zoomX = _room.Viewport.TweenScaleX(4f, 2f);
			Tween zoomY = _room.Viewport.TweenScaleY(4f, 2f);
			Task rotate = _room.Viewport.TweenAngle(0.1f, 1f, Ease.QuadOut).Task.
				ContinueWith(t => _room.Viewport.TweenAngle(angle, 1f, Ease.QuadIn).Task);
			Tween translateX = _room.Viewport.TweenX(240f, 2f);
			Tween translateY = _room.Viewport.TweenY(100f, 2f);

			await Task.WhenAll(zoomX.Task, zoomY.Task, rotate, translateX.Task, translateY.Task);
			await Task.Delay(100);
			await _player.SayAsync("Hmmm, nobody seems to be home...");
			await Task.Delay(100);

			zoomX = _room.Viewport.TweenScaleX(scaleX, 2f);
			zoomY = _room.Viewport.TweenScaleY(scaleY, 2f);
			rotate = _room.Viewport.TweenAngle(0.1f, 1f, Ease.QuadIn).Task.
				ContinueWith(t => _room.Viewport.TweenAngle(angle, 1f, Ease.QuadOut).Task);
			translateX = _room.Viewport.TweenX(x, 2f);
			translateY = _room.Viewport.TweenY(y, 2f);

			await Task.WhenAll(zoomX.Task, zoomY.Task, rotate, translateX.Task, translateY.Task);
			_room.Viewport.Camera.Enabled = true;
		}
예제 #10
0
		private void onRightEdgeCrossed(object sender, AGSEventArgs args)
		{
			_player.ChangeRoom(Rooms.TrashcanStreet.Result, 30);
		}
예제 #11
0
		private void onRepeatedlyExecute(object sender, AGSEventArgs args)
		{
            if (_player == null) return;
			if (_lastInventoryItem == _player.Inventory.ActiveItem) return;

			_lastInventoryItem = _player.Inventory.ActiveItem;

			if (_lastInventoryItem != null)
			{
				_inventoryItemIcon.Image = _lastInventoryItem.CursorGraphics.Image;
				_inventoryItemIcon.Animation.Sprite.Anchor = new AGS.API.PointF (0.5f, 0.5f);
				_inventoryItemIcon.ScaleTo(15f, 15f);
			}
			_inventoryItemIcon.Visible = (_lastInventoryItem != null);
		}
예제 #12
0
		private void onBottleInteract(object sender, AGSEventArgs args)
		{
			_bottleEffectClip.Play();
			_bottle.ChangeRoom(null);
			_player.Inventory.Items.Add(InventoryItems.Bottle);
		}
예제 #13
0
 private void onComponentsInitialized(object sender, AGSEventArgs args)
 {
     var skin = Skin;
     if (skin == null) return;
     skin.Apply(_entity);
 }
예제 #14
0
		private void onAfterFadeIn (object sender, AGSEventArgs args)
		{
			if (args.TimesInvoked == 1) 
			{
                _game.State.RoomTransitions.Transition = AGSRoomTransitions.Dissolve ();
			}
		}
예제 #15
0
		private void onRepeatedlyExecute(object sender, AGSEventArgs args)
		{
			visit();
		}
		private void onRepeatedlyExecute(object sender, AGSEventArgs args)
		{
			if (Inventory == null) return;
			if (!isRefreshNeeded()) return;
			_refreshNeeded = false;

			foreach (var obj in _inventoryItems)
			{
                obj.Visible = false;				
			}
			List<IObject> items = new List<IObject> (Inventory.Items.Count);
			foreach (var item in Inventory.Items)
			{
				items.Add(item.Graphics);
			}
			_inventoryItems = items;

			int topItem = TopItem;
			int count = Math.Min(topItem + RowCount * ItemsPerRow, items.Count);
			float stepX = ItemSize.Width;
			float stepY = ItemSize.Height;
			float x = stepX/2f;
			float y = _scale.Height - stepY/2;
			for (int item = topItem; item < count; item++)
			{
				IObject obj = items[item];
				obj.X = x;
				obj.Y = y;
                
                _tree.TreeNode.AddChild(obj);
                if (!_state.UI.Contains(obj))
                {
                    _state.UI.Add(obj);
                }
                obj.Visible = true;

				x += stepX;
				if (x >= _scale.Width)
				{
					x = stepX/2f;
					y -= stepY;
				}
			}
		}
예제 #17
0
		private void onRepeatedlyExecute(object sender, AGSEventArgs args)
		{
			if (_game.State.Paused) return;
            var obj = Translate;
            var hasRoom = HasRoom;

			foreach (var sound in _playingSounds)
			{
				if (sound.Value.Sound.HasCompleted)
				{
					EmittedSound value;
					_playingSounds.TryRemove(sound.Key, out value);
					continue;
				}
				if (obj == null) continue;
				if (AutoPan)
				{
					float pan = MathUtils.Lerp(0f, -1f, _game.Settings.VirtualResolution.Width, 1f, obj.Location.X);
					sound.Value.Sound.Panning = pan;
				}
				if (AutoAdjustVolume)
				{
                    if (hasRoom == null) continue;
                    var room = _game.State.Room;
                    if (room != hasRoom.Room) return;
                    foreach (var area in room.GetMatchingAreas(obj.Location.XY, EntityID))
					{
                        var scalingArea = area.GetComponent<IScalingArea>();
                        if (scalingArea == null || !scalingArea.ScaleVolume) continue;
						float scale = scalingArea.GetScaling(obj.Y);
						sound.Value.Sound.Volume = AudioClip.Volume * scale;
					}
				}
			}
		}
예제 #18
0
		private void onSavedGameLoad(object sender, AGSEventArgs e)
		{
			_currentMode = 0;
			setCursor();
			RotatingEnabled = true;
		}
예제 #19
0
		private void onRepeatedlyExecute(object sender, AGSEventArgs args)
		{
			if (!_visible.Visible || !_enabled.Enabled || _collider.BoundingBox == null || !_input.LeftMouseButtonDown || Graphics == null || Graphics.BoundingBox == null ||
			    !Graphics.CollidesWith(_input.MouseX, _input.MouseY) || HandleGraphics == null)
			{
				if (_isSliding)
				{
					_isSliding = false;
					onValueChanged();
				}
				return;
			}
			_isSliding = true;
			if (IsHorizontal) setValue(getSliderValue(MathUtils.Clamp(_input.MouseX - _collider.BoundingBox.MinX, 0f, Graphics.Width)));
			else setValue(getSliderValue(MathUtils.Clamp(_input.MouseY - _collider.BoundingBox.MinY
				, 0f, Graphics.Height)));
		}
예제 #20
0
			private void onBeforeFadeIn(object sender, AGSEventArgs args)
			{
				var room = Room;
				if (room == null) return;
				var clip = room.MusicOnLoad;
				if (clip == null) return;
				if (!_crossFading.FadeIn)
				{
					_music = clip.Play(shouldLoop: true);
					return;
				}
				float endVolume = clip.Volume;
				var music = clip.Play(0f, shouldLoop: true);
				_music = music;
				music.TweenVolume(endVolume, _crossFading.FadeInSeconds, _crossFading.EaseFadeIn);
			}
예제 #21
0
		private static void onVignetteShaderResize(object sender, AGSEventArgs args)
		{
			setVignetteResolution();
		}
예제 #22
0
			private void onBeforeFadeOut(object sender, AGSEventArgs args)
			{
				var music = _music;
				if (music == null || music.HasCompleted) return;
				if (!_crossFading.FadeOut)
				{
					music.Stop();
					return;
				}
				music.TweenVolume(0f, _crossFading.FadeOutSeconds, _crossFading.EaseFadeOut).Task.ContinueWith(_ =>
				{
					music.Stop();
				});
			}
예제 #23
0
 private bool canCompleteRoomTransition(AGSEventArgs args)
 {
     return _roomTransitions.State == RoomTransitionState.NotInTransition;
 }
예제 #24
0
		private void onLeftEdgeCrossed(object sender, AGSEventArgs args)
		{
			_player.ChangeRoom(Rooms.DarsStreet.Result, 490);
		}
예제 #25
0
        private void onRepeatedlyExecute(object sender, AGSEventArgs args)
        {
            WalkLineInstruction currentLine = _currentWalkLine;
            if (currentLine == null) return;

            if (currentLine.CancelToken.IsCancellationRequested || currentLine.NumSteps <= 1f)
            {
                _currentWalkLine = null; //Possible race condition here? If so, need to replace with concurrent queue
                _lastFrame = null;
                _compensateScrollX = _compensateScrollY = 0f;
                currentLine.OnCompletion.TrySetResult(null);                
                return;
            }
            if (_cutscene.IsSkipping)
            {
                _obj.X = currentLine.Destination.X;
                _obj.Y = currentLine.Destination.Y;

                _currentWalkLine = null; //Possible race condition here? If so, need to replace with concurrent queue
                _lastFrame = null;
                _compensateScrollX = _compensateScrollY = 0f;
                currentLine.OnCompletion.TrySetResult(null);
                return;
            }
            PointF walkSpeed = adjustWalkSpeed(WalkStep);
            float xStep = currentLine.XStep * walkSpeed.X;
            float yStep = currentLine.YStep * walkSpeed.Y;
            if (MovementLinkedToAnimation && _animation != null && _animation.Animation.Frames.Count > 1 && 
                _animation.Animation.Sprite == _lastFrame)
            {
                //If the movement is linked to the animation and the animation speed is slower the the viewport movement, it can lead to flickering
                //so we do a smooth movement for this scenario.
                _obj.X += compensateForViewScrollIfNeeded(_obj.Room.Viewport.X, xStep, ref _compensateScrollX, ref _lastViewportX);
                _obj.Y += compensateForViewScrollIfNeeded(_obj.Room.Viewport.Y, yStep, ref _compensateScrollY, ref _lastViewportY);
                return;
            }
            if (_animation != null) _lastFrame = _animation.Animation.Sprite;
            _lastViewportX = _obj.Room.Viewport.X;

            currentLine.NumSteps -= Math.Abs(currentLine.IsBaseStepX ? xStep : yStep);
			if (currentLine.NumSteps >= 0f)
			{
                _obj.X += (xStep - _compensateScrollX);
                _obj.Y += (yStep - _compensateScrollY);
			}
            _compensateScrollX = _compensateScrollY = 0f;
        }