Exemplo n.º 1
0
        protected override void SetupOnBeforeImageLoading(TaskParameter imageLoader)
        {
            base.SetupOnBeforeImageLoading(imageLoader);

    #if __IOS__
            int width  = (int)this.Bounds.Width;
            int height = (int)this.Bounds.Height;
    #elif __ANDROID__
            int width  = this.Width;
            int height = this.Height;
    #endif

            if ((!string.IsNullOrWhiteSpace(ImagePath) && ImagePath.Contains("svg", StringComparison.OrdinalIgnoreCase)) || ImageStream != null)
            {
                imageLoader.WithCustomDataResolver(new SvgDataResolver(width, height, true, ReplaceStringMap));
            }
            if (!string.IsNullOrWhiteSpace(LoadingPlaceholderImagePath) && LoadingPlaceholderImagePath.Contains("svg", StringComparison.OrdinalIgnoreCase))
            {
                imageLoader.WithCustomLoadingPlaceholderDataResolver(new SvgDataResolver(width, height, true, ReplaceStringMap));
            }
            if (!string.IsNullOrWhiteSpace(ErrorPlaceholderImagePath) && ErrorPlaceholderImagePath.Contains("svg", StringComparison.OrdinalIgnoreCase))
            {
                imageLoader.WithCustomErrorPlaceholderDataResolver(new SvgDataResolver(width, height, true, ReplaceStringMap));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method is responsible for performing the act of eating the pigeon.
        /// Note that eating the food requires interacting with the environment and with the food.
        /// This interaction is not done here, but delegated through the actuator.
        /// In other words, the Food and Environment classes that listen to the pigeon thread will know when it ate and perform the appropriate action.
        /// </summary>
        private void EatFood(int newPosition)
        {
            String currentDirection = ImagePath;

            if (ImagePath.Contains("left"))
            {
                ImagePath = String.Format("Assets\\pigeon{0}_left_nham.png", index);
            }
            else
            {
                ImagePath = String.Format("Assets\\pigeon{0}_right_nham.png", index);
            }

            actuator.TriggerEatPigeon(newPosition);
            actuator.TriggerChangePigeon();

            Thread.Sleep(Config.pigeonActionDelay);

            ImagePath = currentDirection;

            actuator.TriggerChangePigeon();

            pigeonAction = PigeonAction.Waiting;
        }