コード例 #1
0
        public void createBlockEntity(float x, float y)
        {
            if (level.getCollisionSystem().findObjectsBetweenPoints(x - spawnBlockSize / 2, y - spawnBlockSize / 2, x + spawnBlockSize / 2, y + spawnBlockSize / 2).Count > 0)
            {
                return;
            }
            if (level.getCollisionSystem().findObjectsBetweenPoints(x - spawnBlockSize / 2, y + spawnBlockSize / 2, x + spawnBlockSize / 2, y - spawnBlockSize / 2).Count > 0)
            {
                return;
            }

            if (spawnBlocks.Count >= maxNumSpawnBlocks)
            {
                spawnBlockEntity   old      = spawnBlocks.Dequeue();
                DrawComponent      drawComp = ( DrawComponent )old.getComponent(GlobalVars.DRAW_COMPONENT_NAME);
                AnimationComponent animComp = ( AnimationComponent)old.getComponent(GlobalVars.ANIMATION_COMPONENT_NAME);
                if (animComp != null && drawComp != null)
                {
                    ColliderComponent colComp = (ColliderComponent)old.getComponent(GlobalVars.COLLIDER_COMPONENT_NAME);
                    colComp.colliderType = GlobalVars.DESTROYING_SPAWN_BLOCK_COLLIDER_TYPE;
                    drawComp.setSprite(old.blockAnimationName);
                    animComp.animationOn = true;
                }
                else
                {
                    level.removeEntity(old);
                }
            }
            //Entity newEntity = new [YOUR ENTITY HERE](level, x, y);
            spawnBlockEntity newEntity = new spawnBlockEntity(level, x, y);

            level.addEntity(newEntity.randId, newEntity);   //This should just stay the same
            spawnBlocks.Enqueue(newEntity);
        }
コード例 #2
0
        public void blockEntity(float x, float y)
        {
            //Entity newEntity = new [YOUR ENTITY HERE](level, x, y);
            Entity newEntity = new spawnBlockEntity(level, x, y);

            level.addEntity(newEntity.randId, newEntity); //This should just stay the same
        }