Пример #1
0
        private void UpdateEntities(double deltaTime)
        {
            Renderables.Clear();
            ToDestroy.Clear();

            for (int i = Entities.Count - 1; i >= 0; i--)
            {
                var entity = Entities[i];
                entity.Update(deltaTime);

                if (entity.MarkedForDestruction)
                {
                    ToDestroy.Add(entity);
                }
                else
                {
                    var renderables = entity.GetComponents <IRenderable>();
                    foreach (var renderable in renderables)
                    {
                        Renderables.Add(renderable);
                    }
                }
            }

            foreach (var destroyedEntity in ToDestroy)
            {
                Entities.Remove(destroyedEntity);
                destroyedEntity.Dispose();
            }
        }
        protected void Update()
        {
            ToDestroy
            .Clear();

            if (SpawnTimer > 0)
            {
                SpawnTimer -= Time.deltaTime;
                if (SpawnTimer <= 0)
                {
                    SpawnTimer = 0;
                }
            }

            CheckInput();

            // TODO - CHANGE FOR TESTING
            //float moveSpeed = BaseMoveSpeed + 800;

            float moveSpeed = BaseMoveSpeed + (LevelManager.LevelNumber * MoveSpeedPerLevel);

            moveSpeed *= Time.deltaTime;

            SpawnX -= moveSpeed;
            if (SpawnX <= 1200)
            {
                SpawnX = 1200;
            }

            foreach (var keyboardKey in KeyboardKeys)
            {
                var pos = keyboardKey.Image.rectTransform.anchoredPosition;

                pos.x -= moveSpeed;

                if (pos.x <= -80 && !keyboardKey.HasBeenActivated)
                {
                    ActivateButton(keyboardKey, false);
                }

                keyboardKey.Image.rectTransform.anchoredPosition = pos;

                if (pos.x <= -1200)
                {
                    ToDestroy
                    .Add(keyboardKey);
                }
            }

            foreach (var keyboardKey in ToDestroy)
            {
                KeyboardKeys
                .Remove(keyboardKey);

                Destroy(keyboardKey);
            }

            if (IsCheckingForOver)
            {
                CheckForOver();
            }
        }