void Update()
    {
        if (newEntities.Count > 0)
        {
            int num = newEntities.Count;
            for (int i = 0; i < num; ++i)
            {
                entities.Add(newEntities.Dequeue());
            }
        }

        foreach (Entity entity in entities)
        {
            //Debug.Log("GameWorld.Update, tag:" + entity.identity.tag);
            inputSystem.Update(entity.inputComponent);
            aiSystem.Update(entity.identity, entity.aiComponent, entity.inputComponent);
            controllerSystem.Update(entity.tankComponent, entity.inputComponent, entity.moveComponent, entity.gameobjectComponent);
            gunSystem.Update(entity.gunComponent, entity.inputComponent, entity.gameobjectComponent);
            bulletSystem.Update(entity.identity, entity.bulletComponent, entity.moveComponent, entity.gameobjectComponent);
            buffSystem.Update(entity.buffComponent);
            moveSystem.Update(entity.moveComponent, entity.gameobjectComponent);
        }

        if (expiredEntities.Count > 0)
        {
            Entity entity = null;
            int    num    = expiredEntities.Count;
            for (int i = 0; i < num; ++i)
            {
                entity = expiredEntities.Dequeue();
                entity.gameobjectComponent.Destroy();
                entities.Remove(entity);
            }
        }
    }
Exemple #2
0
        public void Update(TimingInfo timingInfo)
        {
            _inputSystem.Update(timingInfo);
            _graphicsSystem.Update(timingInfo);
            _playerSystem.Update(timingInfo);
            _particleSystem.Update(timingInfo);
            _physicsSystem.Update(timingInfo);
            _colliderSystem.Update(timingInfo);
            _dustParticleEmitterSystem.Update(timingInfo);
            _particleEmitterSystem.Update(timingInfo);

            // If we still have collisions, resolve them now!
            _colliderSystem.ResolveCollisions(timingInfo);
            _moveSystem.Update(timingInfo);
        }
    void Update()
    {
        //遍历所有Entity并执行所有相关System
        foreach (Entity item in entitys)
        {
            if (item.destroyed)
            {
                continue;
            }

            gameObjectSystem.Update(item.gameObject, item.position, item.size, item.color);
        }
        //多对多关系
        foreach (MoveAbleEntity player in playerEntitys)
        {
            if (player.destroyed)
            {
                continue;
            }

            inputSystem.Update(player.speed, player.position);
            foreach (Entity item in entitys)
            {
                if (item == player || item.destroyed)
                {
                    continue;
                }

                if (item.team.id == 0) //是食物,执行吃逻辑
                {
                    eatSystem.Update(player.position, player.size, item.position, item.size, item);
                }
                else if (item.team.id == 1) //是玩家控制角色,执行圆推挤逻辑
                {
                    circlePushSystem.Update(player.position, player.size, item.position, item.size);
                }
            }
        }
        //单独遍历某些Component
        foreach (SpeedComponent speed in speeds)
        {
            if (speed.destroyed)
            {
                continue;
            }

            Entity enity = speed.entity;
            moveSystem.Update(speed, enity.position, enity.size);
        }
        //和Entity无关的Component
        foreach (EatingComponent item in eatings)
        {
            if (item.destroyed)
            {
                continue;
            }

            eatingSystem.Update(item);
        }

        ApplyDelayCommands();
    }