예제 #1
0
        public virtual void Update(UpdateArgs args)
        {
            if (Updated)
                return;

            Updated = true;
        }
예제 #2
0
        /// <summary>
        /// Updates the speed meter by a given amount.
        /// </summary>
        public void Update(UpdateArgs args, double amount)
        {
            // Increment the counter
            seconds += args.SecondsSinceLastUpdate;

            while (seconds >= 1)
            {
                // Remove the last bucket from the total
                total -= buckets[span - 1];

                // Move the buckets over
                for (int i = 1; i < span; i++)
                {
                    buckets[i] = buckets[i - 1];
                }

                // Reset the last one
                buckets[0] = 0;

                // Decrement the counter
                seconds -= 1;
            }

            // Add to the bucket to the current bucket
            buckets[0] += amount;
            total += amount;
        }
예제 #3
0
        public void Update(UpdateArgs args)
        {
            if (HandlingKeys)
            {
                MoveSelect(args.Key);

            }
        }
예제 #4
0
파일: Bug.cs 프로젝트: dmoonfire/cutegod
        /// <summary>
        /// Updates the bug and handles the bouncing, if needed.
        /// </summary>
        public void Update(UpdateArgs args)
        {
            // Decrement the time
            timeUntilBounce -= args.SecondsSinceLastUpdate;

            // If we are negative, bounce
            if (timeUntilBounce < 0)
            {
                // Reset the time
                timeUntilBounce = Entropy.NextDouble(
                    Constants.MinimumBugBounce,
                    Constants.MaximumBugBounce);

                // Figure out what the top block is. Also move the bug
                // to the bottom as possible.
                Block b = this;
                float position = -1;

                foreach (Block block in BlockStack)
                {
                    // We don't bounce ourselves
                    if (block == this)
                        continue;

                    // Check for invalid block
                    if (block.Sprite.ID == Constants.ImmobileBlockName &&
                        block.TopPosition > position)
                    {
                        position = block.TopPosition;
                    }

                    // Check the block
                    if (block.BottomPosition > b.BottomPosition)
                        b = block;
                }

                // Bounce this one
                b.Vector += Constants.BugBounceVector;
                b.Mass = Constants.BlockMass;
                BottomPosition = position;
            }

            // Set the visbility
            if (this == BlockStack.TopBlock)
            {
                // We are the only one
                //IsVisible = true;
                return;
            }

            // Make ourselves invisible
            //IsVisible = false;
        }
예제 #5
0
        /// <summary>
        /// Updates the position of the swarm.
        /// </summary>
        public void Update(UpdateArgs args)
        {
            // Reduces the seconds
            float seconds = (float) args.SecondsSinceLastUpdate;
            secondsRemaining -= seconds;

            // Add the gravity
            float dx = TargetX - CurrentX;
            float dy = TargetY - CurrentY;

            // Get the distance to our target
            double distance = Math.Sqrt((dx * dx) + (dy * dy));

            // If we are within range, then just make it disappear
            if (distance < Constants.SwarmTargetRadius ||
                secondsRemaining < 0)
            {
                particleDied = true;
                return;
            }

            // Change the location
            CurrentX += VectorX * seconds;
            CurrentY += VectorY * seconds;

            // Figure out the vector to the target. We slow down the
            // current vector slightly to let gravity take effect,
            // then we include a vector directly toward the target,
            // with the given strength.
            double strength = Constants.SwarmTargetGravity * seconds;
            double angle = Math.Atan2(dy, dx);
            double cos = Math.Cos(angle) * strength;
            double sin = Math.Sin(angle) * strength;

            VectorX /= 1.01f;
            VectorY /= 1.01f;
            VectorX += (float) cos;
            VectorY += (float) sin;
        }
예제 #6
0
 public abstract void   Update(UpdateArgs args);
예제 #7
0
        /// <summary>
        /// Updates the various speech bubbles for all prayers.
        /// </summary>
        private void UpdateSpeechBubbles(UpdateArgs args)
        {
            // Keep a list of keys, so we know which ones to remove
            ArrayList<Prayer> tmpPrayers = new ArrayList<Prayer>();
            tmpPrayers.AddAll(speechSprites.Keys);

            // Loop through our list of speed sprites
            foreach (Prayer prayer in Game.State.Prayers)
            {
                // See if we have one
                PrayerSpeechSprite pss = null;

                if (!speechSprites.Contains(prayer))
                {
                    // We need to construct the speech sprite
                    pss = new PrayerSpeechSprite(prayer);
                    speeches.Add(pss);
                    speechSprites[prayer] = pss;
                }
                else
                {
                    // Pull out the speech sprite
                    pss = speechSprites[prayer];
                    tmpPrayers.Remove(prayer);
                }

                // Update the sprite
                pss.Update(args);
            }

            // Remove everything left since we don't have it anymore
            foreach (Prayer prayer in tmpPrayers)
            {
                // Remove from our sprites
                speeches.Remove(speechSprites[prayer]);
                speechSprites.Remove(prayer);
            }
        }
예제 #8
0
        /// <summary>
        /// Triggers an update of the mode's state.
        /// </summary>
        /// <param name="args"></param>
        public virtual void Update(UpdateArgs args)
        {
            // Update the sprites
            sprites.Update(args);

            // Update the text
            heartText.Text = Game.State.Hearts.ToString();
            starText.Text = Game.State.Stars.ToString();
            chestText.Text = chestCounter.ToString();

            // Figure out the pause after everything is done
            if (countingDown)
            {
                // Reduce the time
                secondsRemaining -= args.SecondsSinceLastUpdate;

                if (secondsRemaining < 0)
                {
                    // Change the mini mode to the new stage
                    Timeout();
                }
            }
        }
예제 #9
0
        public void Update(UpdateArgs args)
        {
            // Lower the countdown
            secondsRemaining -= args.SecondsSinceLastUpdate;

            if (secondsRemaining <= 0)
            {
                Close();
                return;
            }

            // Update the sprites otherwise
            sprites.Update(args);
        }
예제 #10
0
        /// <summary>
        /// Processes the events for the keyboard down before passing
        /// them on.
        /// </summary>
        public override bool Update(UpdateArgs args)
        {
            // Update the audio
            AudioManager.Update(args);

            // Process our keyboard
            float s = (float) args.SecondsSinceLastUpdate;

            if (Core.InputManager.IsActivated(InputTokens.NumPad7))
                State.Player.PhysicsBody.State.Velocity.Angular +=
                    (float) Math.Pow(State.Player.Area, 0.5) * s;
            if (Core.InputManager.IsActivated(InputTokens.NumPad9))
                State.Player.PhysicsBody.State.Velocity.Angular -=
                    (float) Math.Pow(State.Player.Area, 0.5) * s;

            if (Core.InputManager.IsActivated(InputTokens.NumPad6))
                Apply(s, 3);
            if (Core.InputManager.IsActivated(InputTokens.NumPad4))
                Apply(s, 1);
            if (Core.InputManager.IsActivated(InputTokens.NumPad8))
                Apply(s, 4);
            if (Core.InputManager.IsActivated(InputTokens.NumPad2))
                Apply(s, 2);

            if (Core.InputManager.IsActivated(InputTokens.OpenBracket))
                ViewState.Scale *= 1.25f;
            if (Core.InputManager.IsActivated(InputTokens.CloseBracket))
                ViewState.Scale /= 1.25f;

            // Brakes
            if (Core.InputManager.IsActivated(InputTokens.NumPad0))
            {
                State.Player.PhysicsBody.LinearDamping = 0.75f;
            }
            else
            {
                State.Player.PhysicsBody.LinearDamping = 1.00f;
            }

            // Shed
            if (Core.InputManager.IsActivated(InputTokens.NumPadEnter))
            {
                State.Player.EnginePower -= 1f * s;
                State.Player.ContainmentPower -= 1f * s;

                if (State.Player.EnginePower < 10)
                    State.Player.EnginePower = 10;

                if (State.Player.ContainmentPower < 0)
                    State.Player.ContainmentPower = 0;
            }

            // Update the timer
            UpdateTimer(args);

            // Update the distance
            State.Score.Distance = State.JunctionManager.Junction
                .CalculateDistance(State.Player.Point);

            // Update the speed
            if (!ignoreNextUpdate)
            {
                Vector2D vec = State.Player.PhysicsBody.State.Position.Linear;
                double distance = Vector2D.Distance(vec, lastPoint);
                speed.Update(args, distance);
                State.Score.Speed = (float) speed.Average;
            }

            lastPoint = State.Player.PhysicsBody.State.Position.Linear;

            // Call the parent
            ignoreNextUpdate = false;
            return base.Update(args);
        }
예제 #11
0
 protected override void OnUpdate(UpdateArgs args)
 {
 }
예제 #12
0
        /// <summary>
        /// Random grabs or drops a block on the board.
        /// </summary>
        private void ChangeBoard(UpdateArgs args)
        {
            // Loop through the blocks to see if they are too high. If
            // they are, remove them.
            LinkedList <Block> tmpBlocks = new LinkedList <Block>();

            tmpBlocks.AddAll(blocks);

            foreach (Block b in tmpBlocks)
            {
                if (b.BottomPosition > 10)
                {
                    stacks[b].Remove(b);
                    blocks.Remove(b);
                    stacks.Remove(b);
                }
            }

            // Decrement the counter for the timeout
            secondsUntilChange -= args.SecondsSinceLastUpdate;

            if (secondsUntilChange > 0)
            {
                // We aren't changing anything
                return;
            }

            // Reset it
            secondsUntilChange = Entropy.NextDouble() * 2;

            // Pick a random coordinate
            int        x     = Entropy.Next(0, BoardColumns);
            int        y     = Entropy.Next(0, BoardRows);
            BlockStack stack = board[x, y];

            // Make sure we aren't already doing something here
            foreach (Block b in blocks)
            {
                if (stacks[b] == stack)
                {
                    // Don't bother this time
                    return;
                }
            }

            // We have a stack, decide if we are going to drop or grab
            // something from the stack.
            bool drop = Entropy.Next(0, 2) == 0;

            if (stack.Count > 5)
            {
                // Don't go over 5 high
                drop = false;
            }

            if (stack.Count == 1)
            {
                // Don't go below 1 high
                drop = true;
            }

            // Figure out what to do
            if (drop)
            {
                // Create a new block
                Block nb = new Block(RandomBlock());
                nb.BottomPosition = 10;
                nb.Vector         = Constants.DroppedVector;
                nb.Mass           = Constants.BlockMass;
                nb.IsMoving       = true;
                nb.CastsShadows   = true;
                nb.Height         = 1;
                stack.Add(nb);
            }
            else
            {
                // Grab the top block
                Block tb = stack.TopBlock;
                tb.Vector   = -Constants.DroppedVector;
                tb.Mass     = 0;
                tb.IsMoving = true;
            }
        }
예제 #13
0
파일: State.cs 프로젝트: dmoonfire/cutegod
        /// <summary>
        /// Updates the counters and elements for the state.
        /// </summary>
        public void Update(UpdateArgs args)
        {
            // Don't bother if we don't have a timeout
            if (secondsPerTurn > 0)
            {
                // Reduce the time in the round
                secondsRemaining -= args.SecondsSinceLastUpdate;

                // See if we passed the line
                if (secondsRemaining < 0)
                {
                    // Lose a heart and end the turn
                    Game.State.Hearts--;
                    EndTurn();

                    // Update the tick counter
                    secondsRemaining = secondsPerTurn;
                }
            }
        }
예제 #14
0
        /// <summary>
        /// Processes the events for the keyboard down before passing
        /// them on.
        /// </summary>
        public override bool Update(UpdateArgs args)
        {
            // Update the sound manager
            AudioManager.Update(args);

            // Don't let it update since we might be playing a game
            return false;
        }
예제 #15
0
 protected override void OnUpdate(UpdateArgs args)
 {
     // Get value from inner indicator
     SetValue(emaInd.GetValue(0, 0));
 }
예제 #16
0
        /// <summary>
        /// Random grabs or drops a block on the board.
        /// </summary>
        private void ChangeBoard(UpdateArgs args)
        {
            // Loop through the blocks to see if they are too high. If
            // they are, remove them.
            LinkedList<Block> tmpBlocks = new LinkedList<Block>();
            tmpBlocks.AddAll(blocks);

            foreach (Block b in tmpBlocks)
            {
                if (b.BottomPosition > 10)
                {
                    stacks[b].Remove(b);
                    blocks.Remove(b);
                    stacks.Remove(b);
                }
            }

            // Decrement the counter for the timeout
            secondsUntilChange -= args.SecondsSinceLastUpdate;

            if (secondsUntilChange > 0)
                // We aren't changing anything
                return;

            // Reset it
            secondsUntilChange = Entropy.NextDouble() * 2;

            // Pick a random coordinate
            int x = Entropy.Next(0, BoardColumns);
            int y = Entropy.Next(0, BoardRows);
            BlockStack stack = board[x, y];

            // Make sure we aren't already doing something here
            foreach (Block b in blocks)
                if (stacks[b] == stack)
                    // Don't bother this time
                    return;

            // We have a stack, decide if we are going to drop or grab
            // something from the stack.
            bool drop = Entropy.Next(0, 2) == 0;

            if (stack.Count > 5)
                // Don't go over 5 high
                drop = false;

            if (stack.Count == 1)
                // Don't go below 1 high
                drop = true;

            // Figure out what to do
            if (drop)
            {
                // Create a new block
                Block nb = new Block(RandomBlock());
                nb.BottomPosition = 10;
                nb.Vector = Constants.DroppedVector;
                nb.Mass = Constants.BlockMass;
                nb.IsMoving = true;
                nb.CastsShadows = true;
                nb.Height = 1;
                stack.Add(nb);
            }
            else
            {
                // Grab the top block
                Block tb = stack.TopBlock;
                tb.Vector = -Constants.DroppedVector;
                tb.Mass = 0;
                tb.IsMoving = true;
            }
        }
예제 #17
0
        /// <summary>
        /// Triggers an update of the mode's state.
        /// </summary>
        /// <param name="args"></param>
        public void Update(UpdateArgs args)
        {
            // Update the environment
            environment.Update(args);

            // If we are fading in, change the position
            if (secondsFadeIn > 0)
            {
                // Decrement the counter
                secondsFadeIn -= args.SecondsSinceLastUpdate;

                if (secondsFadeIn < 0)
                    secondsFadeIn = 0;

                // Figure out the ratios to use
                float ratio = (float)
                    (secondsFadeIn / Constants.MainMenuFadeIn);
                float inverse = 1 - ratio;
                alpha = (int) (inverse * 255);

                // Figure out the title position and color
                title.Point = new PointF(
                    (ratio * titleStart.X + inverse * titleEnd.X),
                    (ratio * titleStart.Y + inverse * titleEnd.Y));
                title.Tint = Color.FromArgb(alpha, Color.White);
                version.Tint = Color.FromArgb(alpha / 4, Color.White);

                // New Game
                newGame.Point = new PointF(
                    (ratio * newGameStart.X + inverse * newGameEnd.X),
                    (ratio * newGameStart.Y + inverse * newGameEnd.Y));
                newGame.Alpha = alpha;

                // Settings
                settings.Point = new PointF(
                    (ratio * settingsStart.X + inverse * settingsEnd.X),
                    (ratio * settingsStart.Y + inverse * settingsEnd.Y));
                settings.Alpha = alpha;

                // Resume
                resume.Point = new PointF(
                    (ratio * resumeStart.X + inverse * resumeEnd.X),
                    (ratio * resumeStart.Y + inverse * resumeEnd.Y));
                resume.Alpha = alpha;

                // Help
                help.Point = new PointF(
                    (ratio * helpStart.X + inverse * helpEnd.X),
                    (ratio * helpStart.Y + inverse * helpEnd.Y));
                help.Alpha = alpha;

                // High Scores
                scores.Point = new PointF(
                    (ratio * scoresStart.X + inverse * scoresEnd.X),
                    (ratio * scoresStart.Y + inverse * scoresEnd.Y));
                scores.Alpha = alpha;

                // Credits
                credits.Point = new PointF(
                    (ratio * creditsStart.X + inverse * creditsEnd.X),
                    (ratio * creditsStart.Y + inverse * creditsEnd.Y));
                credits.Alpha = alpha;

                // Quit
                quit.Point = new PointF(
                    (ratio * quitStart.X + inverse * quitEnd.X),
                    (ratio * quitStart.Y + inverse * quitEnd.Y));
                quit.Alpha = alpha;
            }
            else
            {
                // Set everything into the proper place
                title.Point = titleEnd;
                title.Tint = Color.White;
                version.Tint = Color.FromArgb(64, Color.White);

                newGame.Point = newGameEnd;
                newGame.Alpha = 255;

                settings.Point = settingsEnd;
                settings.Alpha = 255;

                resume.Point = resumeEnd;
                resume.Alpha = 255;

                help.Point = helpEnd;
                help.Alpha = 255;

                scores.Point = scoresEnd;
                scores.Alpha = 255;

                credits.Point = creditsEnd;
                credits.Alpha = 255;

                quit.Point = quitEnd;
                quit.Alpha = 255;
            }

            // Change the board around
            ChangeBoard(args);

            // Update the sprites and the viewport
            board.Update(args);
            sprites.Update(args);
            viewport.Update(args);
        }
예제 #18
0
        protected override async Task UpdateAsync(UpdateArgs args, UpdateResult result)
        {
            await Data.UpdateAsync(args.Row);

            result.IsHandled = true;
        }
        /// <summary>
        /// Gets the view models.
        /// </summary>
        /// <param name="entity">The entity object.</param>
        /// <returns>The generated view models.</returns>
        public async Task <IList <ItemGroup> > GetViewModels(SitefinityDataEntity entity)
        {
            var viewModels = new List <ItemGroup>();
            var itemType   = "pressreleases";
            var provider   = "OpenAccessProvider";

            // when using the OData client, the url is automatically prefixed with the value of web the service and the sitefinity instance url
            // we use an expand the get the related image

            var getAllArgs = new GetAllArgs
            {
                // required parameter, specifies the items to work with
                Type = itemType
            };

            // optional parameter, specifies the fields to be returned, if not specified
            // the default service response fields will be returned
            getAllArgs.Fields.Add("Title");

            // "*" returns all the fields, even those that are available when requesting a single item only
            // getAllArgs.Fields.Add("*");

            // specifies the related fields to be included in the response (like related data or parent relationships)
            if (!entity.HideImage)
            {
                getAllArgs.Fields.Add("RelatedMediaSingle");
            }

            // optional parameter, specifies the maximum items to be returned
            getAllArgs.Take = 20;

            // optional parameter, specifies the items to be skipped
            getAllArgs.Skip = 0;

            // optional paramteter, specifies an ordering clause
            getAllArgs.OrderBy.Add(new OrderBy()
            {
                Name = "Title",
                Type = OrderType.Ascending
            });

            // optional parameter, specifies if the total count of the items should be returned
            getAllArgs.Count = true;

            // optional parameter, if nothing is specified, the default for the site will be used
            getAllArgs.Provider = provider;

            // The generic parameter here is a plain DTO for a one to one relationship with the model on the server
            // It contains a representation for every kind of field that is currently supported by the system
            getAllArgs.Filter = null;
            var responseWithoutFilter = await this.service.GetItems <Item>(getAllArgs).ConfigureAwait(true);

            viewModels.Add(new ItemGroup()
            {
                Name  = "Items without filter",
                Items = responseWithoutFilter.Items.Select(x => this.GetItemViewModel(x)).ToArray(),
            });

            getAllArgs.Filter = new FilterClause()
            {
                FieldName  = "Title",
                FieldValue = "test",
                Operator   = FilterClause.Operators.Equal
            };

            var responseWithBasicFilter = await this.service.GetItems <Item>(getAllArgs).ConfigureAwait(true);

            viewModels.Add(new ItemGroup()
            {
                Name  = "Items with simple filter",
                Items = responseWithBasicFilter.Items.Select(x => this.GetItemViewModel(x)).ToArray(),
            });

            var filterTitle = new FilterClause()
            {
                FieldName  = "Title",
                FieldValue = "test",
                Operator   = FilterClause.Operators.Equal,
            };

            var filterTitle2 = new FilterClause()
            {
                FieldName  = "Title",
                FieldValue = "test",
                Operator   = FilterClause.Operators.NotEqual,
            };

            var filterTitle3 = new FilterClause()
            {
                FieldName  = "Title",
                FieldValue = "test",
                Operator   = FilterClause.StringOperators.StartsWith,
            };

            var filterTitle4 = new FilterClause()
            {
                FieldName  = "Title",
                FieldValue = "test",
                Operator   = FilterClause.StringOperators.EndsWith,
            };

            var filtersByTitle = new CombinedFilter()
            {
                Operator     = CombinedFilter.LogicalOperators.Or,
                ChildFilters = new FilterClause[] { filterTitle, filterTitle2 },
            };

            var filtersByTitleWithStringOperators = new CombinedFilter()
            {
                Operator     = CombinedFilter.LogicalOperators.Or,
                ChildFilters = new FilterClause[] { filterTitle3, filterTitle4 },
            };

            var multipleFiltersCombined = new CombinedFilter
            {
                Operator     = CombinedFilter.LogicalOperators.And,
                ChildFilters = new CombinedFilter[] { filtersByTitle, filtersByTitleWithStringOperators },
            };

            getAllArgs.Filter = multipleFiltersCombined;
            var responseWithComplexFilter = await this.service.GetItems <Item>(getAllArgs).ConfigureAwait(true);

            viewModels.Add(new ItemGroup()
            {
                Name  = "Items with complex filter",
                Items = responseWithComplexFilter.Items.Select(x => this.GetItemViewModel(x)).ToArray(),
            });

            // in order to execute /create/read/update operations a token must be acquired from the web server
            var createItemArgs = new CreateArgs()
            {
                // required parameter, specifies the items to work with
                Type = itemType,

                // required parameter, specifies the data to be passed to the server
                Data = new Item()
                {
                    Title                = "Test",
                    DateAndTime          = DateTime.UtcNow,
                    Number               = 123456,
                    ChoicesSingle        = SingleChoice.FirstChoice,
                    ChociesMultiple      = MultipleChoice.FirstChoice | MultipleChoice.SecondChoice,
                    LongText             = "LongText",
                    ShortText            = "ShortText",
                    ArrayOfGuids         = new [] { Guid.NewGuid() },
                    GUIDField            = Guid.NewGuid(),
                    MetaTitle            = "Test",
                    MetaDescription      = "Test",
                    OpenGraphDescription = "Test",
                    OpenGraphTitle       = "Test",
                    Tags    = new [] { Guid.NewGuid() },
                    UrlName = "test" + Guid.NewGuid().ToString(),
                    YesNo   = true,

                    // related, properties are added through relation request
                    // RelatedMediaSingle
                },

                // optional parameter, if nothing is specified, the default for the site will be used
                Provider = provider
            };

            try
            {
                // reference to documentation on how to retrieve bearer tokens
                // https://www.progress.com/documentation/sitefinity-cms/request-access-token-for-calling-web-services
                var token = "Bearer ...";
                createItemArgs.AdditionalHeaders.Add(HeaderNames.Authorization, token);

                var createResponse = await this.service.CreateItem <Item>(createItemArgs);

                var getSingleArgs = new GetItemArgs()
                {
                    // required parameter, specifies the id of the item to update
                    Id = createResponse.Id.ToString(),

                    // required parameter, specifies the items to work with
                    Type = itemType,

                    // optional parameter, if nothing is specified, the default for the site will be used
                    Provider = provider
                };

                var getSingleResponse = await this.service.GetItem <Item>(getSingleArgs);

                var updateArgs = new UpdateArgs()
                {
                    // required parameter, specifies the id of the item to update
                    Id = getSingleResponse.Id.ToString(),

                    // required parameter, specifies the items to work with
                    Type = itemType,

                    // required parameter, specifies the data to be passed to the server
                    Data = new Item()
                    {
                        Title = "updated title",
                    },

                    // optional parameter, if nothing is specified, the default for the site will be used
                    Provider = provider
                };
                updateArgs.AdditionalHeaders.Add(HeaderNames.Authorization, token);

                await this.service.UpdateItem(updateArgs);

                var deleteArgs = new DeleteArgs()
                {
                    // required parameter, specifies the id of the item to update
                    Id = getSingleResponse.Id.ToString(),

                    // required parameter, specifies the items to work with
                    Type = itemType,

                    // optional parameter, if nothing is specified, the default for the site will be used
                    Provider = provider
                };

                deleteArgs.AdditionalHeaders.Add(HeaderNames.Authorization, token);

                await this.service.DeleteItem(deleteArgs);
            }
            catch (ErrorCodeException error)
            {
                this.logger.LogError($"Cannot create/update/delete items. Actual error is {error.Message}");
            }

            return(viewModels);
        }
예제 #20
0
        public void Update(UpdateArgs args)
        {
            // See if we have a new category
            if (currentCategory == null)
            {
                // Create a category and force the first credit to show
                ChooseCategory();
                Debug("Starting category: {0}", currentCategory);
                newSeconds = 0;
            }

            // If we don't have a category, we are done
            if (currentCategory == null)
            {
                Game.GameMode = new MainMenuMode();
                return;
            }

            // Update any of the displayed ones
            LinkedList <CreditsLine> tmpList = new LinkedList <CreditsLine>();

            tmpList.AddAll(displayed);

            foreach (CreditsLine cl in tmpList)
            {
                // Add the time
                cl.SecondsDisplayed += args.SecondsSinceLastUpdate;

                // If we exceeded the life, kill it
                if (cl.SecondsDisplayed > cl.SecondsToLive)
                {
                    displayed.Remove(cl);
                    sprites.Remove(cl.Sprite);
                    Debug("Removing credit line: {0}", cl.Name);
                }
            }

            // If the displayed and pending list are empty, then we
            // are done
            if (displayed.Count == 0 && pending.Count == 0)
            {
                Debug("Finished category: {0}", currentCategory);
                currentCategory = null;
                return;
            }

            // See if we are showing a new one
            newSeconds -= args.SecondsSinceLastUpdate;

            if (slots > 0 && newSeconds <= 0 && pending.Count > 0)
            {
                // Reset the counter
                newSeconds = 0.2;

                // See if we have too many
                if (displayed.Count <= slots)
                {
                    // Pick a random location for this
                    int kill = slots * 2;

                    while (true)
                    {
                        // Check the kill
                        if (kill-- < 0)
                        {
                            break;
                        }

                        // Set up some variables
                        int   row   = Entropy.Next(0, slots);
                        float y     = row * CreditsLine.FontSize + FontSize * 2;
                        bool  found = false;

                        foreach (CreditsLine cl0 in displayed)
                        {
                            if (cl0.Point.Y == y)
                            {
                                found = true;
                                break;
                            }
                        }

                        // If we found something, try again
                        if (found)
                        {
                            continue;
                        }

                        // Add a new one
                        CreditsLine cl = pending.RemoveFirst();
                        displayed.Add(cl);
                        cl.Point = new PointF(
                            Entropy.NextFloat(sprites.Size.Width
                                              - cl.Sprite.Size.Width - 160) + 80,
                            y);
                        sprites.Add(cl.Sprite);
                        break;
                    }
                }
            }

            // Update the sprites
            sprites.Update(args);
        }
예제 #21
0
 public void RaiseUpdated(UpdateArgs <TS, TT> data) => Updated?.Invoke(data);
예제 #22
0
 /// <summary>
 /// Updates the Update label in the Sections list
 /// </summary>
 /// <param name="args"></param>
 private void UpdateFollowedPosts(UpdateArgs args)
 {
     UpdateFollowedPosts(args, true);
 }
예제 #23
0
 protected void OnUpdate(UpdateArgs <Class> e)
 {
     UpdateEntity?.Invoke(this, e);
 }
예제 #24
0
        /// <summary>
        /// This method is called to update the player's position and
        /// to potentially switch junctions.
        /// </summary>
        public void Update(UpdateArgs args)
        {
            // Ignore if we don't have a player or a junctin
            if (State.Player == null || junction == null)
                return;

            // Go through the segments and find the distance
            PointF playerPoint = State.Player.Point;

            LinkedList<Junction> preload = new LinkedList<Junction>();
            LinkedList<Junction> build = new LinkedList<Junction>();

            foreach (Segment s in junction.Segments)
            {
                // Get our distance from the player's position
                float distance = Geometry
                    .CalculateDistance(playerPoint, s.ChildJunctionPoint);

                // See if we are in switch range
                if (distance <= Constants.JunctionSwitchDistance)
                {
                    // Switching junctions!
                    Junction = s.ChildJunction;
                    return;
                }

                // See if we are in preload distance and we haven't
                // already started the preload.
                if (distance <= Constants.OverlapConnectionDistance &&
                    !preloadedJunctions.Contains(s.ChildJunction))
                {
                    preload.Add(s.ChildJunction);
                    continue;
                }

                // See if we are close enough to start building out
                // the children.
                if (distance <= Constants.MinimumConnectionDistance)
                    build.Add(s.ChildJunction);
            }

            // If we got this far, we aren't in the switching distance
            // but we have some junctions that might need preloading.
            if (preload.Count == 0 && build.Count == 0)
                return;

            // Go through the junctions and start the preloading
            foreach (Junction j in preload)
            {
                JunctionManagerPreload jmp = new JunctionManagerPreload(j);
                preloadedJunctions[j] = jmp;
                jmp.ThreadPreload();
            }

            // Also trigger the normal updates
            foreach (Junction j in build)
            {
                // Fire off a background thread
                ThreadPool.QueueUserWorkItem(
                    new WaitCallback(UpdateJunction), j);
            }
        }
예제 #25
0
        public void Update(UpdateArgs args)
        {
            // User input
            this.DecodeInput();

            // Damage
            if (this.isLastDamaged)
            {

                // effect
                var effect = this.Core.Effect.GenerateRequest();

                var y = this.ViewParameters.VerticalPosition + 0.9f + (this.Random.Next(12) - 6) * 0.05f;
                var x = this.ViewParameters.HorizontalPosition
                    + ((this.ViewParameters.HorizontalPosition > this.LastDamage.SourcePositionHorizontal)
                    ? -1f : 1f) * 0.04f + (this.Random.Next(12) - 6) * 0.05f;

                //var rxx=rx.



                effect.Z = 0;
                effect.Y = y;
                effect.X = x;

                //this.Core.Log($"{effect.X}, {effect.Y}, {effect.Z}");

                if (this.LastDamage.Id == this.guardingAttack)
                {
                    this.DesiredParameters.IsGuarding = true;
                    this.DesiredParameters.IsDamaged = false;

                    effect.Type = EffectType.Shock;
                }
                else
                {
                    this.Life.Value += (int)this.LastDamage.Power;

                    this.DesiredParameters.IsGuarding = false;
                    this.DesiredParameters.IsDamaged = true;
                    this.DesiredParameters.DamageType = this.LastDamage.Type;



                    effect.Type = this.LastDamage.Effect;// EffectType.Burst;


                }
                effect.Commit();
                this.isLastDamaged = false;
                this.LastDamage.Power = 0f;
                this.DesiredParameters.BackDamage = this.ViewParameters.Direction
                    * (this.ViewParameters.HorizontalPosition - this.LastDamage.SourcePositionHorizontal) < 0;
                //AppCore.GetEnvironment(null).Log
                //    (this.DesiredParameters.BackDamage.ToString());
            }
            else
            {

                this.DesiredParameters.IsGuarding = false;
                this.DesiredParameters.IsDamaged = false;
            }

            // Update View
            this.UpdatedSubject.OnNext(Unit.Default);
        }
예제 #26
0
 static void dm_NoUpdateAvailable(object sender, UpdateArgs e)
 {
     Console.WriteLine("[{0}] -> up-to-date!", e.UpdateName);
 }
예제 #27
0
파일: Game.cs 프로젝트: mbahar94/fracture
        private void ParallelUpdateOrbs (int partitionIndex, int partitionCount, UpdateArgs args) {
            var rng = GetRNG();

            Orb orb;
            using (var e = Orbs.GetParallelEnumerator(partitionIndex, partitionCount))
            while (e.GetNext(out orb)) {
                orb.Update(rng, args.Now);
                e.SetCurrent(ref orb);
            }

            ReleaseRNG(rng);
        }
예제 #28
0
 /// <summary>
 /// Processes the events for the keyboard down before passing
 /// them on.
 /// </summary>
 public override bool Update(UpdateArgs args)
 {
     // We don't allow anything else to update
     return false;
 }
예제 #29
0
        public void Update(UpdateArgs args)
        {
            // See if we are done
            if (AssetLoader.Instance.IsFinishedLoading)
            {
                //Game.GameMode = new NewGameMode();
                Game.GameMode = new MainMenuMode();
                return;
            }

            // Load some assets
            AssetLoader.Instance.Update(args.SecondsSinceLastUpdate);

            // Set the color
            int value = (int) (255.0 * AssetLoader.Instance.Pending);
            text.Tint = Color.FromArgb(value, value, value);
            text2.Tint = text.Tint;

            // Update the percentage
            text2.Text = String
                .Format("{0:N0}%", AssetLoader.Instance.Pending * 100);

            // Update the sprites
            sprites.Update(args);
        }
        /// <summary>
        /// Updates the physics engine
        /// </summary>
        public override bool Update(UpdateArgs args)
        {
            // Update it
            State.Physics.Update(args);
            State.JunctionManager.Update(args);

            // Call the parent
            return base.Update(args);
        }
예제 #31
0
 public override void Update(UpdateArgs args)
 {
     _currentRenderer?.Update(args, Location);
 }
예제 #32
0
        public override void Update(UpdateArgs args)
        {
            // Figure out what color we should be. We change every 10
            // seconds from the heart color to the star color and
            // back.
            double sec = ((double) DateTime.UtcNow.Ticks / 10000000.0) % 2.0;
            double range = Math.Abs(sec - 1.0);
            double ratio = (double) range / 1;
            double inverse = 1 - ratio;

            Color c = Color.FromArgb(
                (int) (Constants.HeartColor.R * ratio
                    + Constants.StarColor.R * inverse),
                (int) (Constants.HeartColor.G * ratio
                    + Constants.StarColor.G * inverse),
                (int) (Constants.HeartColor.B * ratio
                    + Constants.StarColor.B * inverse));

            // We change our state based on our active status
            if (Clicked == null)
            {
                Tint = Color.FromArgb(64, Color.White);
            }
            else if (IsActive)
            {
                Tint = Color.FromArgb(Alpha, c);
            }
            else
            {
                int a = (int) ((float) Alpha * 0.8f);
                Tint = Color.FromArgb(a, c);
            }
        }
예제 #33
0
        /// <summary>
        /// Triggers an update of the mode's state.
        /// </summary>
        /// <param name="args"></param>
        public void Update(UpdateArgs args)
        {
            // Update the environment
            environment.Update(args);

            // Update the blocks
            Game.State.Board.Update(args);
            UpdateSpeechBubbles(args);
            UpdateSwarms(args);
            Game.State.Prayers.Update(args);
            Game.State.Bugs.Update(args);

            // See if we need to update our minor mode
            if (minorMode != null)
            {
                // Update the minor mode
                minorMode.Update(args);
            }
            else
            {
                // Only update the state if we don't have a minor mode
                Game.State.Update(args);
            }
        }
예제 #34
0
파일: PlayingState.cs 프로젝트: K4mey/Alex
        protected override void OnUpdate(GameTime gameTime)
        {
            MiniMap.PlayerLocation = World.Player.KnownPosition;

            var args = new UpdateArgs()
            {
                Camera         = World.Camera,
                GraphicsDevice = Graphics,
                GameTime       = gameTime
            };

            _playingHud.CheckInput = Alex.GuiManager.ActiveDialog == null;

            //	if (Alex.IsActive)
            {
                var newAspectRatio = Graphics.Viewport.AspectRatio;
                if (AspectRatio != newAspectRatio)
                {
                    World.Camera.UpdateAspectRatio(newAspectRatio);
                    AspectRatio = newAspectRatio;
                }

                UpdateRayTracer(Alex.GraphicsDevice, World);

                if (!_playingHud.Chat.Focused)
                {
                    World.Player.Controller.CheckMovementInput = Alex.IsActive && Alex.GuiManager.ActiveDialog == null;
                    World.Player.Controller.CheckInput         = Alex.IsActive;

                    if (Alex.GuiManager.ActiveDialog == null)
                    {
                        CheckInput(gameTime);
                    }
                }
                else
                {
                    World.Player.Controller.CheckInput = false;
                }

                if (AlwaysDay)
                {
                    World.SetTime(1200);
                }

                World.Update(args);

                var now = DateTime.UtcNow;
                if (now - _previousMemUpdate > TimeSpan.FromSeconds(5))
                {
                    _previousMemUpdate = now;

                    //Task.Run(() =>
                    {
                        _ramUsage = Environment.WorkingSet;

                        ThreadPool.GetMaxThreads(out int maxThreads, out int maxCompletionPorts);
                        ThreadPool.GetAvailableThreads(out int availableThreads, out int availableComplPorts);
                        _threadsUsed   = maxThreads - availableThreads;
                        _complPortUsed = maxCompletionPorts - availableComplPorts;

                        _maxThreads    = maxThreads;
                        _maxComplPorts = maxCompletionPorts;

                        var pos     = World.Player.KnownPosition.GetCoordinates3D();
                        var biomeId = World.GetBiome(pos.X, pos.Y, pos.Z);
                        var biome   = BiomeUtils.GetBiomeById(biomeId);
                        _currentBiomeId = biomeId;
                        _currentBiome   = biome;
                    }                    //);
                }
            }
            base.OnUpdate(gameTime);
        }
예제 #35
0
        /// <summary>
        /// Updates the position of the swarms.
        /// </summary>
        private void UpdateSwarms(UpdateArgs args)
        {
            // Draw the hearts if we have something
            LinkedList<SwarmParticle> list = new LinkedList<SwarmParticle>();

            if (heartSwarm.Count > 0)
            {
                // Draw out the swarm
                foreach (SwarmParticle sp in heartSwarm)
                {
                    // Update the particle
                    sp.Update(args);

                    // Remove it if died
                    if (sp.Died)
                    {
                        list.Add(sp);
                        Game.State.Hearts++;
                    }
                }

                // Remove the list
                foreach (SwarmParticle sp1 in list)
                    heartSwarm.Remove(sp1);
            }

            // Draw the hearts if we have something
            if (starSwarm.Count > 0)
            {
                // Draw out the swarm
                list.Clear();

                foreach (SwarmParticle sp in starSwarm)
                {
                    // Update the particle
                    sp.Update(args);

                    // Remove it if died
                    if (sp.Died)
                    {
                        list.Add(sp);
                        Game.State.Stars++;
                    }
                }

                // Remove the list
                foreach (SwarmParticle sp1 in list)
                    starSwarm.Remove(sp1);
            }
        }
예제 #36
0
        /// <summary>
        /// Triggers an update of the mode's state.
        /// </summary>
        /// <param name="args"></param>
        public void Update(UpdateArgs args)
        {
            // Update the environment
            environment.Update(args);

            // If we are fading in, change the position
            if (secondsFadeIn > 0)
            {
                // Decrement the counter
                secondsFadeIn -= args.SecondsSinceLastUpdate;

                if (secondsFadeIn < 0)
                {
                    secondsFadeIn = 0;
                }

                // Figure out the ratios to use
                float ratio = (float)
                              (secondsFadeIn / Constants.MainMenuFadeIn);
                float inverse = 1 - ratio;
                alpha = (int)(inverse * 255);

                // Figure out the title position and color
                title.Point = new PointF(
                    (ratio * titleStart.X + inverse * titleEnd.X),
                    (ratio * titleStart.Y + inverse * titleEnd.Y));
                title.Tint   = Color.FromArgb(alpha, Color.White);
                version.Tint = Color.FromArgb(alpha / 4, Color.White);

                // New Game
                newGame.Point = new PointF(
                    (ratio * newGameStart.X + inverse * newGameEnd.X),
                    (ratio * newGameStart.Y + inverse * newGameEnd.Y));
                newGame.Alpha = alpha;

                // Settings
                settings.Point = new PointF(
                    (ratio * settingsStart.X + inverse * settingsEnd.X),
                    (ratio * settingsStart.Y + inverse * settingsEnd.Y));
                settings.Alpha = alpha;

                // Resume
                resume.Point = new PointF(
                    (ratio * resumeStart.X + inverse * resumeEnd.X),
                    (ratio * resumeStart.Y + inverse * resumeEnd.Y));
                resume.Alpha = alpha;

                // Help
                help.Point = new PointF(
                    (ratio * helpStart.X + inverse * helpEnd.X),
                    (ratio * helpStart.Y + inverse * helpEnd.Y));
                help.Alpha = alpha;

                // High Scores
                scores.Point = new PointF(
                    (ratio * scoresStart.X + inverse * scoresEnd.X),
                    (ratio * scoresStart.Y + inverse * scoresEnd.Y));
                scores.Alpha = alpha;

                // Credits
                credits.Point = new PointF(
                    (ratio * creditsStart.X + inverse * creditsEnd.X),
                    (ratio * creditsStart.Y + inverse * creditsEnd.Y));
                credits.Alpha = alpha;

                // Quit
                quit.Point = new PointF(
                    (ratio * quitStart.X + inverse * quitEnd.X),
                    (ratio * quitStart.Y + inverse * quitEnd.Y));
                quit.Alpha = alpha;
            }
            else
            {
                // Set everything into the proper place
                title.Point  = titleEnd;
                title.Tint   = Color.White;
                version.Tint = Color.FromArgb(64, Color.White);

                newGame.Point = newGameEnd;
                newGame.Alpha = 255;

                settings.Point = settingsEnd;
                settings.Alpha = 255;

                resume.Point = resumeEnd;
                resume.Alpha = 255;

                help.Point = helpEnd;
                help.Alpha = 255;

                scores.Point = scoresEnd;
                scores.Alpha = 255;

                credits.Point = creditsEnd;
                credits.Alpha = 255;

                quit.Point = quitEnd;
                quit.Alpha = 255;
            }

            // Change the board around
            ChangeBoard(args);

            // Update the sprites and the viewport
            board.Update(args);
            sprites.Update(args);
            viewport.Update(args);
        }
예제 #37
0
        /// <summary>
        /// Processes the sound generation for background music.
        /// </summary>
        public static void Update(UpdateArgs args)
        {
            // Don't bother if we don't have any
            if (loopChunks.Count == 0)
                return;

            if (!AreBackgroundSamplesPaused)
            {
                // Add to the counters
                lastBeat += args.SecondsSinceLastUpdate;
                lastAlter += args.SecondsSinceLastUpdate;

                // If we exceeded the time for altering, update something
                if (lastAlter >= Constants.AudioUpdateSpeed)
                {
                    // Decrement it so we only change on occasion
                    lastAlter -= Constants.AudioUpdateSpeed;

                    // Alter something
                    int index = random.Next(0, Constants.MaximumAudioSamples);
                    int bit = random.Next(0, Constants.MaximumBeatsPerLoop);

                    // We basically XOR the random bit
                    loopRhythms[index] = loopRhythms[index] ^ (1 << bit);
                }

                // See if we need to update our beat samples
                if (lastBeat >= SecondsPerBeat)
                {
                    // Make a bit of noise
                    //Log.Debug("--- BEAT ---");

                    // Decrement it
                    lastBeat -= SecondsPerBeat;

                    // Go through and start playing the samples
                    int bitIndex = 1 << beatIndex;

                    for (int i = 0; i < Constants.MaximumAudioSamples; i++)
                    {
                        // See if we are set
                        if ((loopRhythms[i] & bitIndex) != 0)
                        {
                            // Start playing it
                            int results =
                                SdlMixer.Mix_PlayChannel(-1, loopChunks[i], 0);

                            if (results == -1)
                            {
                                // We had a problem
                                Log.Info("Cannot start sample {0}: {1}",
                                    i, SdlMixer.Mix_GetError());
                            }
                        }
                    }

                    // Increment the index
                    int maxBeats = (int) BeatsPerLoop;
                    beatIndex = (beatIndex + 1) % maxBeats;
                }
            }
        }
예제 #38
0
        /// <summary>
        /// Triggers an update of the mode's state.
        /// </summary>
        /// <param name="args"></param>
        public override void Update(UpdateArgs args)
        {
            // See if we have any chests left
            if (chestInfo == null && ChestCounter == 0)
            {
                // We don't, so finish up
                Timeout();
                return;
            }

            // If the chest is null, we need to start up a new chest
            if (chestInfo == null)
            {
                // Create a new chest
                ChestCounter--;
                chestInfo = ChestBonusInfo.Random;

                // Give it a time to live
                chestSeconds = Constants.ChestOpenFadeSpeed;

                // Create the sprites and direction
                bonusSprite = AssetLoader.Instance
                              .CreateSprite(chestInfo.BlockKey);
                bonusSprite.Point = ChestSprite.Point;
                fadeIn            = true;
                pause             = false;

                // Set up the text
                Title = chestInfo.Title;
                Text  = String.Format(chestInfo.Description,
                                      Game.State.SecondsPerTurn,
                                      Game.State.BugCount,
                                      Game.State.GrabCost,
                                      Game.State.Board.Columns);

                // Add it to the sprites
                Sprites.Add(bonusSprite);
            }
            else
            {
                // Increment the pointer
                chestSeconds -= args.SecondsSinceLastUpdate;

                // If we are negative, then we change mode
                if (chestSeconds < 0)
                {
                    // Switch mode
                    if (pause)
                    {
                        // Fade out
                        pause  = false;
                        fadeIn = false;
                    }
                    else if (fadeIn)
                    {
                        // Pause it
                        pause = true;

                        // Apply the value
                        chestInfo.Apply(bonusSprite.Point);
                    }
                    else
                    {
                        // Remove it
                        Sprites.Remove(bonusSprite);
                        chestInfo   = null;
                        bonusSprite = null;
                        return;
                    }

                    // Update the counter
                    chestSeconds = Constants.ChestOpenFadeSpeed;
                }
            }

            // Figure out the ratios (1 is just start, 0 is done)
            double timeRatio     = chestSeconds / Constants.ChestOpenFadeSpeed;
            float  positionRatio = (float)(timeRatio * BlockHeight);
            int    alpha         = (int)(255 * timeRatio);

            // Figure out the chest position
            if (pause)
            {
                // We aren't doing anything until the seconds change
                bonusSprite.Point = new PointF(
                    ChestSprite.Point.X,
                    ChestSprite.Point.Y - BlockHeight);
                tint = Color.White;
            }
            else if (fadeIn)
            {
                // Change the position based on the ratio
                bonusSprite.Point = new PointF(
                    ChestSprite.Point.X,
                    ChestSprite.Point.Y - BlockHeight + positionRatio);

                // Change the alpha based on the ratio
                tint = Color.FromArgb(255 - alpha, Color.White);
            }
            else
            {
                // Change the position based on the ratio
                bonusSprite.Point = new PointF(
                    ChestSprite.Point.X,
                    ChestSprite.Point.Y - 2 * BlockHeight + positionRatio);

                // Change the alpha based on the ratio
                tint = Color.FromArgb(alpha, Color.White);
            }

            // Move the sprite
            bonusSprite.Tint = tint;

            // Call the base
            base.Update(args);
        }
예제 #39
0
        public void Update(UpdateArgs args)
        {
            // See if we have a new category
            if (currentCategory == null)
            {
                // Create a category and force the first credit to show
                ChooseCategory();
                Debug("Starting category: {0}", currentCategory);
                newSeconds = 0;
            }

            // If we don't have a category, we are done
            if (currentCategory == null)
            {
                Game.GameMode = new MainMenuMode();
                return;
            }

            // Update any of the displayed ones
            LinkedList<CreditsLine> tmpList = new LinkedList<CreditsLine>();
            tmpList.AddAll(displayed);

            foreach (CreditsLine cl in tmpList)
            {
                // Add the time
                cl.SecondsDisplayed += args.SecondsSinceLastUpdate;

                // If we exceeded the life, kill it
                if (cl.SecondsDisplayed > cl.SecondsToLive)
                {
                    displayed.Remove(cl);
                    sprites.Remove(cl.Sprite);
                    Debug("Removing credit line: {0}", cl.Name);
                }
            }

            // If the displayed and pending list are empty, then we
            // are done
            if (displayed.Count == 0 && pending.Count == 0)
            {
                Debug("Finished category: {0}", currentCategory);
                currentCategory = null;
                return;
            }

            // See if we are showing a new one
            newSeconds -= args.SecondsSinceLastUpdate;

            if (slots > 0 && newSeconds <= 0 && pending.Count > 0)
            {
                // Reset the counter
                newSeconds = 0.2;

                // See if we have too many
                if (displayed.Count <= slots)
                {
                    // Pick a random location for this
                    int kill = slots * 2;

                    while (true)
                    {
                        // Check the kill
                        if (kill-- < 0)
                            break;

                        // Set up some variables
                        int row = Entropy.Next(0, slots);
                        float y = row * CreditsLine.FontSize + FontSize * 2;
                        bool found = false;

                        foreach (CreditsLine cl0 in displayed)
                        {
                            if (cl0.Point.Y == y)
                            {
                                found = true;
                                break;
                            }
                        }

                        // If we found something, try again
                        if (found)
                            continue;

                        // Add a new one
                        CreditsLine cl = pending.RemoveFirst();
                        displayed.Add(cl);
                        cl.Point = new PointF(
                            Entropy.NextFloat(sprites.Size.Width
                                - cl.Sprite.Size.Width - 160) + 80,
                            y);
                        sprites.Add(cl.Sprite);
                        break;
                    }
                }
            }

            // Update the sprites
            sprites.Update(args);
        }
예제 #40
0
        /// <summary>
        /// Handles the update code for all the elements.
        /// </summary>
        /// <param name="args"></param>
        public override void Update(UpdateArgs args)
        {
            // Update the viewport
            base.Update(args);

            // Update our text
            heartScore.Text = Game.State.Hearts.ToString();
            starScore.Text = Game.State.Stars.ToString();

            // Visbility of the clock
            if (Game.State.SecondsPerTurn > 0)
            {
                clock.Visible = true;
                clockScore.Visible = true;
                clockScore.Text =
                    ((int) Game.State.SecondsRemaining).ToString();
            }
            else
            {
                clock.Visible = false;
                clockScore.Visible = false;
            }

            // Visible bugs
            if (Game.State.BugCount > 0)
            {
                bug.Visible = true;
                bugScore.Visible = true;
                bugScore.Text = Game.State.BugCount.ToString();
            }
            else
            {
                bug.Visible = false;
                bugScore.Visible = false;
            }
        }
예제 #41
0
 public override void Update(UpdateArgs args)
 {
     foreach (var uiElement in ChildList)
     {
         uiElement.Update(args);
     }
 }
예제 #42
0
        /// <summary>
        /// Updates the environment state.
        /// </summary>
        public void Update(UpdateArgs args)
        {
            // Figure out the time of day (0 is midnight, 0.5 is noon)
            double sec = ((double) DateTime.UtcNow.Ticks / 10000000.0)
                % dayInSeconds;
            time = sec / dayInSeconds;

            // Figure out the day and night cycles
            night = Math.Abs(time - 0.5) * 2;
            day = 1 - night;

            // Figure out dawn
            dawn = dusk = 0;

            if (time >= 0.2 && time <= 0.4)
            {
                // Dawn
                dawn = time - 0.2;
                dawn *= 5;
                dawn = 1 - Math.Abs(dawn - 0.5) * 2;
            }
            else if (time >= 0.6 && time <= 0.8)
            {
                // Dusk
                dusk = time - 0.6;
                dusk *= 5;
                dusk = 1 - Math.Abs(dusk - 0.5) * 2;
            }

            // Update the sprites
            for (int i = 0; i < 4; i++)
                sprites[i].Update(args);

            // Update the start alpha
            if (night > 0)
            {
                foreach (ISprite ds in sprites[0])
                {
                    int alpha = ds.Tint.A;
                    alpha += Entropy.Next(-3, 3);
                    alpha = Math.Min(alpha, 128);
                    alpha = Math.Max(alpha, 64);
                    ds.Tint = Color.FromArgb(alpha, ds.Tint);
                }
            }
        }
예제 #43
0
        /// <summary>
        /// Updates the arguments to handle the speech bubble fading.
        /// </summary>
        public override void Update(UpdateArgs args)
        {
            if (secondsLeft >= 0)
            {
                // Keep track of the number of seconds
                secondsLeft -= args.SecondsSinceLastUpdate;

                // Move the top down
                if (topDown != null)
                {
                    topDown.Point = new PointF(
                        topDown.Point.X,
                        topDown.Point.Y -
                        (float) (Constants.PrayerSpeechRise
                            * args.SecondsSinceLastUpdate));
                }
            }
        }
예제 #44
0
        private void UpdateTimer(UpdateArgs args)
        {
            // Don't bother if we aren't active
            if (!isCountingDown)
                return;

            // See if we should ignore the first one
            if (ignoreNextUpdate)
            {
                // We use this to prevent the update from giving a
                // large one at once.
                return;
            }

            // Calculate the amount of time remaining
            double seconds =
                args.SecondsSinceLastUpdate * State.Score.CountdownMultiplier;
            seconds /= 1 + Math.Log(State.Player.ContainmentPower);
            State.Score.Countdown -= (float) seconds;

            // If we are less than zero, boom.
            if (State.Score.Countdown < 0)
            {
                // Reset it to make it pretty
                State.Score.Countdown = 0;
                isCountingDown = false;

                // Start up the end of game mode on top of us
                GameModeManager.Push(new EndOfGameMode());
            }
        }
예제 #45
0
 /// <summary>
 /// Overrides the update event to send events into the game
 /// state.
 /// </summary>
 /// <param name="args"></param>
 public override void Update(UpdateEventArgs args)
 {
     UpdateArgs uArgs = new UpdateArgs();
     uArgs.TicksSinceLastUpdate = args.ElapsedMilliseconds * 10000;
     Game.Update(uArgs);
 }
예제 #46
0
 protected override Task UpdateAsync(UpdateArgs args, UpdateResult result)
 {
     LoginUserList[0] = args.Row;
     result.IsHandled = true;
     return(base.UpdateAsync(args, result));
 }